/Users/detro/workspace-nb/JAEBI-SwingClient/src/clientswing/UI/OptionPanel.java

Vai alla documentazione di questo file.
00001 package clientswing.UI;
00002 
00003 import javax.swing.*;
00004 import java.util.*;
00005 import java.awt.*;
00006 import java.awt.event.*;
00007 import clientswing.model.*;
00008 
00014 public class OptionPanel
00015     extends BaseForm {
00017   JLabel[] labels =null;
00021   JLabel errore = new JLabel();
00023   JTextField[] textFields=null;
00025   Column[] columns=new Column[3];
00027    JButton invia = new JButton("invia");
00029   JTextField columnNumSet;
00031   boolean isError;
00032 
00036   public OptionPanel(JTextField columnNumSet) {
00037 
00038     Toolkit kit = Toolkit.getDefaultToolkit();
00039     Dimension screenSize = kit.getScreenSize();
00040 
00041     int screenHeight = screenSize.height;
00042     int screenWidth = screenSize.width;
00043     // centra il frame sullo schermo
00044     setSize(screenWidth / 2, screenHeight / 2);
00045     setLocation(screenWidth / 4 + 350, screenHeight / 4);
00046 
00047     this.getContentPane().setLayout(null);
00048 
00049     int num = 0;
00050     isError=false;
00051      try {
00052        num = Integer.parseInt(columnNumSet.getText());
00053        try {
00054          labels = new JLabel[num];
00055          textFields = new JTextField[num];
00056 
00057        }
00058        catch (Exception ex1) {
00059          columnNumSet.setBackground(Color.pink);
00060          labels = new JLabel[num];
00061          textFields = new JTextField[num];
00062 
00063        /*  errore.setBounds(new Rectangle(10, 40, 130, 20));
00064          errore.setForeground(Color.red);
00065          errore.setText("errore");*/
00066        JOptionPane.showMessageDialog(null, "errore di inserimento", "errore di inserimento", JOptionPane.WARNING_MESSAGE);
00067        isError=true;
00068 
00069 
00070        }
00071      }
00072      catch (NumberFormatException ex) {
00073       columnNumSet.setBackground(Color.pink);
00074       labels = new JLabel[num];
00075       textFields = new JTextField[num];
00076 
00077       JOptionPane.showMessageDialog(null, "errore di inserimento", "errore di inserimento", JOptionPane.WARNING_MESSAGE);
00078        invia.setVisible(false);
00079         isError=true;
00080      }
00081 
00082      int i;
00083      // columnErrore.setVisible(true);
00084      // columnName.setText("Inserisci la colonna");
00085       columnNumSet.setBackground(Color.white);
00086      for (i = 0; i < labels.length; i++) {
00087 
00088 
00089        labels[i] = new JLabel();
00090        labels[i].setText("Inserisci la colonna");
00091 
00092        labels[i].setBounds(new Rectangle(10, 40 + 25 * i, 130, 20));
00093        labels[i].setForeground(Color.black);
00094        textFields[i] = new JTextField();
00095        textFields[i].setBounds(new Rectangle(200, 40 + 25 * i, 70, 20));
00096        this.getContentPane().add(labels[i]);
00097        this.getContentPane().add(textFields[i]);
00098      }
00099      int height = 140 + num * 20;
00100      this.setSize(350, height);
00101      invia.setBounds(new Rectangle(150, 45 + 25 * i, 80, 20));
00102      invia.setBackground(Color.white);
00103      invia.setForeground(Color.gray);
00104      this.getContentPane().add(invia);
00105      this.getContentPane().add(errore);
00106      //catturo l'evento
00107       invia.addMouseListener(new OptionPanel_invia_mouseAdapter(this));
00108 
00109 
00110 
00111 
00112   }
00114    void invia_mouseClicked(MouseEvent e) {
00115 
00116     System.out.println("num="+labels.length+"\n");
00117     columns = new Column[labels.length];
00118     for (int i=0;i<labels.length;i++)
00119     {
00120        columns[i] = new Column(textFields[i].getText());
00121      }
00122     this.hide();
00123   }
00124  public boolean getIsError()
00125  {
00126    return isError;
00127  }
00128   public Column[] getColumns(){
00129     return columns;
00130  }
00131 }
00132 
00133 
00134 class OptionPanel_invia_mouseAdapter extends java.awt.event.MouseAdapter {
00135   OptionPanel adaptee;
00136 
00137   OptionPanel_invia_mouseAdapter(OptionPanel adaptee) {
00138     this.adaptee = adaptee;
00139   }
00140   public void mouseClicked(MouseEvent e) {
00141     adaptee.invia_mouseClicked(e);
00142   }
00143 }

Generato il Wed Jun 22 16:42:58 2005 per JAEBI - Swing Client da  doxygen 1.4.3