Buttons in GridBagLayout werden einfach nicht kleiner?

will2k

Mitglied
Hallo,

Komplettcode zum ausführen. Warum werden die add/del Buttons nicht kleiner, wenn ich die JComboBox via weightX größer mache? ab einer bestimmten Breite wird die JComboBox einfach nicht breiter, da kann ich für weightX setzen was ich will und kleiner machen kann ich die add/buttons ja net...

Code:
public class MainWindow extends JFrame
{    
   static final long serialVersionUID = 1L;   
   private JTabbedPane jtp = new JTabbedPane();   

   public MainWindow() throws IOException
   {
	  super("Test");  
	  SettingsPanel settingsPanel = new SettingsPanel();
	  jtp.addTab("Settings", settingsPanel);     
      add(jtp);       
      setResizable(false);      
      setSize(400,400);
      setLocationRelativeTo(null);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     
      setVisible(true);	      
   } 
       
   public static void main(String []args) throws Exception
   {     
	      EventQueue.invokeLater(new Runnable()
	      {
		      public void run()
		      {	      
				try 
				{ 				
					new MainWindow(); 
				}
				catch (IOException e)
				{				
					e.printStackTrace();
				}	                    
		      }
	      });  	      
   }
}

Code:
public class SettingsPanel extends JPanel
{	 	
	private static final long serialVersionUID = 1L;
  
    private JButton titelAddBT    = new JButton("+"); 
    private JButton titelDelBT    = new JButton("-"); 
    private JButton playLengthAddBT    = new JButton("+"); 
    private JButton playLengthDelBT    = new JButton("-"); 
    private JLabel titelLB = new JLabel("Movie Format List");
    private JLabel playLengthLB = new JLabel("Play Length");    
    private JComboBox titelCB = new JComboBox();
    private JComboBox playLengthCB = new JComboBox();      
    private JPanel panel3 = new JPanel();   
    
	public SettingsPanel()
    {  		
	   setLayout(new GridBagLayout());		   
	       	       
	   panel3.setLayout(new GridBagLayout()); 	       
       addJComponentToJPanel( panel3,titelLB       ,0 , 0 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
       addJComponentToJPanel( panel3,titelCB       ,1 , 0 , 1 , 1 , 33 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);	  
       addJComponentToJPanel( panel3,titelAddBT    ,2 , 0 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
       addJComponentToJPanel( panel3,titelDelBT    ,3 , 0 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
       addJComponentToJPanel( panel3,playLengthLB    ,0 , 1 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
       addJComponentToJPanel( panel3,playLengthCB    ,1 , 1 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);	  
       addJComponentToJPanel( panel3,playLengthAddBT ,2 , 1 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
       addJComponentToJPanel( panel3,playLengthDelBT ,3 , 1 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
       addJPanelToJFrame( panel3,0,2,4,1,1,5,GridBagConstraints.NORTH,GridBagConstraints.BOTH);	
       
    
    }
	
	public void addJPanelToJFrame(JComponent c, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int anchor, int fill)
	{
    	add(c, new GridBagConstraints(gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill, new Insets(0, 0, 0, 0), 0, 0));
	}
    
    void addJComponentToJPanel(JPanel panel, JComponent c, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int anchor, int fill ) 
    { 
    	panel.add(c, new GridBagConstraints(gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill, new Insets(0, 0, 0, 0), 0, 0));        
    }
	    
}
 
ok das ist der Witz habe jetzt herausgefunden es liegt an meinem LooknFeel Substance v4.3 da verändert sich die Breite der buttons nicht ohne den LnF gehts einwandfrei...
 
Zurück