PainelPosicoes.java 7.75 KB
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * painelposicoes.java
 *
 * Created on 13/08/2010, 16:51:28
 */
package gerador;

import javax.swing.JDialog;
import javax.swing.JTable;

/**
 *
 * @author felipel
 */
public class PainelPosicoes extends javax.swing.JPanel {

    JTable tab;
    private JDialog janela;

    /** Creates new form painelposicoes */
    public PainelPosicoes(JTable tabl) {
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        this.setBounds((screenSize.width - 303) / 2, (screenSize.height - 244) / 2, 303, 244);
        initComponents();
        tab = tabl;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Dx = new javax.swing.JLabel();
        displayx = new javax.swing.JTextField();
        Dy = new javax.swing.JLabel();
        displayy = new javax.swing.JTextField();
        Dl = new javax.swing.JLabel();
        displayl = new javax.swing.JTextField();
        displayc = new javax.swing.JTextField();
        Dc = new javax.swing.JLabel();
        ok = new javax.swing.JButton();
        cancel = new javax.swing.JButton();

        setBackground(new java.awt.Color(251, 214, 65));

        Dx.setText("Display X:");

        displayx.setText("170");

        Dy.setText("Display Y:");

        displayy.setText("220");

        Dl.setText("Display (Largura):");

        displayl.setText("640");

        displayc.setText("280");

        Dc.setText("Display (Comprimento):");

        ok.setText("Ok");
        ok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okActionPerformed(evt);
            }
        });

        cancel.setText("Cancel");
        cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(Dx)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(displayx, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(Dy)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(displayy, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(Dl)
                        .addGap(18, 18, 18)
                        .addComponent(displayl, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(Dc)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(displayc, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cancel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(ok, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Dx)
                    .addComponent(displayx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ok))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Dy)
                    .addComponent(displayy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cancel))
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Dl)
                    .addComponent(displayl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Dc)
                    .addComponent(displayc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
        // TODO add your handling code here:
        tab.setValueAt("(" + displayx.getText() + "," + displayy.getText() + ") " + "(" + displayl.getText() + "," + displayc.getText() + ")", 0, 2);
        janela.dispose();
}//GEN-LAST:event_okActionPerformed

    private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
        // TODO add your handling code here:
        janela.dispose();
}//GEN-LAST:event_cancelActionPerformed

    public void setJanela(JDialog dialogo) {
        janela = dialogo;
    }

    public void setDisplayX(String dx) {
        displayx.setText(dx);
    }

    public void setDisplayY(String dy) {
        displayy.setText(dy);
    }

    public void setDisplayL(String dl) {
        displayl.setText(dl);
    }

    public void setDisplayC(String dc) {
        displayc.setText(dc);
    }

    public void setaTudo() {
        tab.setValueAt("(" + displayx.getText() + "," + displayy.getText() + ") " + "(" + displayl.getText() + "," + displayc.getText() + ")", 0, 2);
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Dc;
    private javax.swing.JLabel Dl;
    private javax.swing.JLabel Dx;
    private javax.swing.JLabel Dy;
    private javax.swing.JButton cancel;
    private javax.swing.JTextField displayc;
    private javax.swing.JTextField displayl;
    private javax.swing.JTextField displayx;
    private javax.swing.JTextField displayy;
    private javax.swing.JButton ok;
    // End of variables declaration//GEN-END:variables
}