Thursday, 15 July 2010

java - GridLayout wrong number of columns -


I'm trying to make a panel with a grid-layout (7,2)

  membersPanel = new zpinal (new grid layout (7,2));   

However, when I add components (label, Cambodia, textfield, etc.) the components are displayed in column 3, such as:

 Image

I have tried to change the number of columns to 1 or 0, but the panel remains the same. What can i do

Edit:

Here's more code:

  p1 = new JPNL (); Memberspennel = new zpnell (new gridlate (7,0)); ResourcesLabel = new JLab ("resource"); MembersPanel.add (resourcesLabel); Empty label 5 = new jlab (""); MembersPanel.add (emptyLabel5); Empty label 6 = new jlabel (""); MembersPanel.add (emptyLabel6); ComboBoxResource = New JComboBox (configs.XMLreaderDOM4J.readResourceID ()); MembersPanel.add (comboBoxResource); Slider 1 = New SliderWith TextField (1,10); TextSli1 = New TextFieldFromSlider (this, Slider 1); Slider1.setTextField (textSli1); Slider1.setValue (1); MembersPanel.add (Slider1); MembersPanel.add (textSli1); Empty label 2 = new jlab (); MembersPanel.add (emptyLabel2); AddButton1 = New Pocket ("Add"); AddButton1.addActionListener (New TrataEvento ()); MembersPanel.add (addButton1); Agregator1Label = New JLABEL ("Aggetagor 1"); MembersPanel.add (agregator1Label); ComboBoxAgregator1 = New JComboBox (configs.XMLreaderDOM4J.readAgregator1ID ()); MembersPanel.add (comboBoxAgregator1); Slider 2 = new slider width textfield (1,10); TextSli2 = New TextFieldFromSlider (this, Slider 2); Slider2.setTextField (textSli2); Slider2.setValue (1); MembersPanel.add (slider2); MembersPanel.add (textSli2); AddButton2 = New Pocket ("Add"); AddButton2.addActionListener (New TrataEvento ()); MembersPanel.add (addButton2); Empty label 3 = new jlab (); MembersPanel.add (emptyLabel3); Agregator0Label = New JLABEL ("Accelerator"); MembersPanel.add (agregator0Label); ComboBoxAgregator0 = new JComboBox (configs.XMLreaderDOM4J.readAgregator0ID ()); MembersPanel.add (comboBoxAgregator0); Slider 3 = new slider width textfield (1,10); TextSli3 = New TextFieldFromSlider (this, Slider 3); Slider3.setTextField (textSli3); Slider3.setValue (1); MembersPanel.add (slider3); MembersPanel.add (textSli3); AddButton3 = New Pocket ("Add"); AddButton3.addActionListener (New TrataEvento ()); MembersPanel.add (addButton3); EmptyLabel4 = New JLab (); MembersPanel.add (emptyLabel4); P1.add (membersPanel); Number of columns used for    

swing Grid layout if the number of components added is greater than the original number specified. Use 0 to specify an adjustable number of rows:

  memberspanel = new zpinal (new gridlate (0, 2));   

This will make factoring easier in the future.

No comments:

Post a Comment