Results 1 to 6 of 6
  1. #1
    Vin
    Vin is offline Member
    Join Date
    Jan 2010
    Posts
    8
    Rep Power
    0

    Default I have a problem in setting layout for panel.

    Hi,
    I am new to JAVA, I have a problem in setting GroupLayout for Panel.
    I am trying to add components on the panel during run time.
    How can I place these components at desired place?
    If i set GroupLayout am getting Exception like
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at org.dyno.visual.swing.layouts.GroupLayout.checkPre ferredSize(GroupLayout.java:59)
    at org.dyno.visual.swing.layouts.GroupLayout.addLayou tComponent(GroupLayout.java:53)
    Please help me to resolve ths problem.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    1.) Do you know that there is already a GroupLayout class in the standard Java packages?
    2.) To get help with your current GroupLayout class you would have to read the documentation and help files from where you got it.
    3.) Did you consider using CardLayout?

  3. #3
    Vin
    Vin is offline Member
    Join Date
    Jan 2010
    Posts
    8
    Rep Power
    0

    Default

    Hi r035198x,
    I have gone through GroupLayout class package, even with the cardlayout am getting the same exception.

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    It's that time again when we need to see the code.
    Rip all the stuff and just post the smallest piece if code that compiles, runs and demonstrates the problem.

  5. #5
    Vin
    Vin is offline Member
    Join Date
    Jan 2010
    Posts
    8
    Rep Power
    0

    Default

    for panel1
    Java Code:
    private JPanel getJPanel1() {
    	if (jPanel1 == null) {
    			jPanel1 = new JPanel();
    			jPanel1.setBackground(new Color(224, 224, 224));
    			jPanel1.setBorder(BorderFactory.createTitledBorder(null, "Work Bench", TitledBorder.LEADING, TitledBorder.ABOVE_TOP, new Font("SansSerif", Font.BOLD,
    					12), new Color(59, 59, 59)));
    			jPanel1.setForeground(new Color(64, 0, 0));
    			//jPanel1.setLayout(new FlowLayout());
    			jPanel1.setLayout(new GroupLayout());
    		}
    		return jPanel1;
    	}
    here if i set the layout as Group Layout then i will get exception

    for Button in panel0
    Java Code:
    private void jButton0ActionActionPerformed(ActionEvent event) {
    	if(event.getActionCommand().equals("Click")){
    		jPanel1.add(new JButton("Click"));
    		pack();
    		
    	}
    here am trying to put a button on panel1 during run time
    Last edited by Fubarable; 01-19-2010 at 02:42 PM. Reason: code tags fixed

  6. #6
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You are still not yet using Java's GroupLayout so I can't be of help here.
    Ask the people who created that GroupLayout class or consult its help/javadocs.

Similar Threads

  1. Setting Charset problem
    By geekdad in forum Advanced Java
    Replies: 2
    Last Post: 11-17-2009, 01:27 AM
  2. Layout problem / add components from another class
    By ehochedez in forum AWT / Swing
    Replies: 9
    Last Post: 09-02-2009, 10:42 AM
  3. [SOLVED] Layout Problem
    By casid in forum New To Java
    Replies: 4
    Last Post: 06-02-2009, 11:17 PM
  4. Problem in setting Eclipse
    By Crisanto in forum New To Java
    Replies: 3
    Last Post: 10-29-2008, 06:48 PM
  5. Problem in getting table on panel
    By adeeb in forum AWT / Swing
    Replies: 0
    Last Post: 06-09-2008, 08:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •