Configurar tamanho dos componentes

0 respostas
luis_rodriguez

Boa noite,

Estou configurando uma GUI e os "sets" dos componentes não estão funcionando...
public class Principal extends JFrame{

    private JMenuBar bar = new JMenuBar();
    private JMenu model, tools, about, help;
    private JPanel pnl1 = new JPanel();
    private JPanel pnl2 = new JPanel();
    private JPanel pnl3 = new JPanel();
    private JPanel pnl4 = new JPanel();
    private JPanel pnl5 = new JPanel();
    private JPanel pnl6 = new JPanel();
    private JPanel pnl7 = new JPanel();
    private JPanel pnl8 = new JPanel();
    private JPanel pnl9 = new JPanel();
    private JPanel pnl10 = new JPanel();
    private JPanel pnl11 = new JPanel();
    private GridLayout gridLayout1 = new GridLayout( 2, 3, 5, 5 );
    private GridLayout gridLayout2 = new GridLayout( 4, 1, 5, 5);
     private GridLayout gridLayout3 = new GridLayout( 1, 3, 5, 5);
    private JTabbedPane tabbedPane = new JTabbedPane();
    private JList list, clone;
    private JCheckBox externalClass = new JCheckBox();
    private JCheckBox internalClass = new JCheckBox();
    private JCheckBox subclassOf = new JCheckBox();
    private JCheckBox property = new JCheckBox();
    private JTextField externalClassText = new JTextField();
    private JTextField internalClassText = new JTextField();
    private JTextField subclassOfText = new JTextField();
    private JTextField propertyText = new JTextField();
    private JButton extClassBut = new JButton();
    private JButton intClassBut = new JButton();
    private JButton subClassBut = new JButton();
    private JButton propBut = new JButton();
    private JLabel extLabel = new JLabel("SuperClass");
    private JLabel intLabel = new JLabel("Class");
    private JLabel subClassLabel = new JLabel("SubClassOf");
    private JLabel propLabel = new JLabel("Property");
    private ImportWordObject object = new ImportWordObject();
    private List<String> stublist = new ArrayList<String>();
    private String[] listaArray;
    
   // set up GUI
   @SuppressWarnings("empty-statement")
   public Principal()
   {
      
      //setting the frame 
      super( "OWL Ontology Builder" );
      this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      Font displayFont = new Font("Courier", Font.PLAIN, 14);
      this.setJMenuBar(bar);
      this.add(tabbedPane);
      tabbedPane.add(pnl1);
      setSize( 800, 450 );
      setVisible( true );

      BorderLayout lay = new BorderLayout();

      //Create the two Lists
      list = new JList();
      clone = new JList();
     
      //setting the lists

      //For List list
      list.setVisibleRowCount(10);
      list.setFixedCellHeight( 15 );
      list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      pnl2.add( new JScrollPane( list ) );


      //For List Clone
      clone.setVisibleRowCount(10);
      clone.setFixedCellHeight( 15 );
      clone.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      pnl4.add( new JScrollPane( clone ) );

      //Setting Layout of Panels
      pnl1.setLayout( gridLayout1 );
      pnl3.setLayout(gridLayout2);
      pnl5.setLayout(gridLayout2);
      pnl6.setLayout( gridLayout2 );
      pnl7.setLayout(gridLayout2);
      pnl8.setLayout(gridLayout3);
      pnl9.setLayout(gridLayout3);
      pnl10.setLayout(gridLayout3);
      pnl11.setLayout(gridLayout3);
      

      //Adding all panels to pnl1
      pnl1.add(pnl2);
      pnl1.add(pnl3);
      pnl1.add(pnl4);
      pnl1.add(pnl5);
      pnl1.add(pnl6);
      pnl1.add(pnl7);

      //Adding panels to pnl3
      pnl3.add(pnl8);
      pnl3.add(pnl9);
      pnl3.add(pnl10);
      pnl3.add(pnl11);
      
      //Add the TabbedPanel
      tabbedPane.add("OWL LITE", pnl1);

      //Adding the Menus to MenuBar
      model = new JMenu("Model");
      about = new JMenu("About");
      help = new JMenu("Help");
      tools = new JMenu("Tools");

      //Add JMenuItem and his Listener
      JMenuItem imports = new JMenuItem("Import Word Object");
      imports.addActionListener(new ImportWordObjectListener(this, object, list, clone, listaArray));
      tools.add(imports);

      model.add(new JMenuItem("Create OntoModel"));
      model.add(new JMenuItem("Write OntoModel"));
      bar.add(model);
      bar.add(tools);
      bar.add(about);
      bar.add(help);

      //Setting components size
      externalClassText.setSize(5,60);
      extLabel.setSize(5,20);
      extClassBut.setSize(5, 5);

      //pnl3.add(externalClass);
      pnl8.add(extLabel, BorderLayout.WEST);
      pnl8.add(externalClassText, BorderLayout.CENTER);
      pnl8.add(extClassBut, BorderLayout.EAST);

      
      


      //pnl3.add(internalClass);
     // pnl3.add(subclassOf);
      //pnl3.add(property);

      //Add all JLabels
      
      //pnl3.add(intLabel);
      //pnl3.add(subClassLabel);
      //pnl3.add(propLabel);



   } // end constructor


   //To fill the left list
   public void setDataList()
   {

       //este método recebe os dados do ArrayList de palavras e os coloca dentro das duas JList (list e clone)
   }

   //Insert new created Classes into the ArrayList
   public List<String> insertNewClass (List<String> listaAtualizClass){

       /*Com este método eu pretendo capturar uma classe criada pelo usr
        oriunda de um campo texto em que ele digita uma string
        que será inserida no ArrayList de palavras que foi recebido
        Ainda, toda vez que for inserida uma nova String na lista
        o método chama o método que mostra a lista dentro da JList e atualiza
        a tela*/
       return listaAtualizClass;
   }

   //Insert new Property
   public List<String> insertNewProperty(List<String> listaAtualizProperty)
   {
       /*Com este método eu pretendo capturar uma Propriedade criada pelo usr
        oriunda de um campo texto em que ele digita uma string
        que será inserida no ArrayList de palavras que foi recebido
        Ainda, toda vez que for inserida uma nova String na lista
        o método chama o método que mostra a lista dentro da JList e atualiza
        a tela*/
       /******* Pensei em colocar este método dentro do Listener de um botão
        Assim, no momento em que eu mandar o sistema criar a propriedade
        chama o método direto de dentro do listener*********/
       return listaAtualizProperty;
   }




   public static void main( String args[] )
   {
      Principal teste = new Principal();
      
   }

}

Os componentes estão amontoados, está bem feio, alguém sabe por que?

Criado 30 de maio de 2010
Respostas 0
Participantes 1