Results 1 to 2 of 2
  1. #1
    atrodeyo is offline Member
    Join Date
    Apr 2012
    Posts
    41
    Rep Power
    0

    Default having issue with validate ().. please help

    I am trying to solve this for so long but got stuck for months now. Started with groupLayout but had no Help at this fourm. Now I tried with AbsoluteLayout and still I am having the same issue. Reasons for using those layout is because I need to be able to position components wherever I want to. Here is my Code. Please someone help me.

    When I Press the button the textfield suppose to appear but it does not appear. What am I doing wrong here? Please help. I am stuck with this for a while now.

    Java Code:
    import java.awt.Dimension;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTabbedPane;
    
    
    public class tabs extends JFrame {
    
    	/**
    	 * Create the panel.
    	 */
    	JFrame myFrame = null;
    	public static void main (String [] args) {
    		new tabs ();
    	}
    	public tabs() {
    
    		JTabbedPane tp = new JTabbedPane ();
    		getContentPane().add (tp);
    		
    		tp.addTab("tab1", new TestAbsoluteLayer1());
    		tp.addTab("tab2", new TestAbsoluteLayer1());
    
    		
    		setPreferredSize(new Dimension(526, 483));
    		pack();
    		setVisible(true);
    		
    	}
    
    }
    Java Code:
    import javax.swing.JPanel;
    import java.awt.BorderLayout;
    import javax.swing.JTextField;
    
    
    
    public class TestAbsoluteLayer2 extends JPanel {
    	private JTextField textField;
    
    	/**
    	 * Create the panel.
    	 */
    	public TestAbsoluteLayer2() {
    		setLayout(null);
    		
    		JPanel panel = new JPanel();
    		panel.setBounds(149, 31, 165, 21);
    		add(panel);
    		panel.setLayout(new BorderLayout(0, 0));
    		
    		textField = new JTextField();
    		panel.add(textField, BorderLayout.NORTH);
    		textField.setColumns(10);
    
    	}
    
    }
    Java Code:
    import javax.swing.JPanel;
    import java.awt.BorderLayout;
    import javax.swing.JButton;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    
    
    public class TestAbsoluteLayer1 extends JPanel {
    
    	/**
    	 * Create the panel.
    	 */
    	public TestAbsoluteLayer1() {
    		setLayout(null);
    		
    		JPanel panel = new JPanel();
    		panel.setBounds(117, 176, 98, 29);
    		add(panel);
    		panel.setLayout(new BorderLayout(0, 0));
    		
    		JButton btnNewButton = new JButton("New button");
    		btnNewButton.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent arg0) {
    				btnActionPerformed (arg0);
    			}
    		});
    		panel.add(btnNewButton, BorderLayout.CENTER);
    
    	}
    	
    	private void btnActionPerformed (ActionEvent e) {
    		removeAll ();
    		TestAbsoluteLayer2 abs2 = new TestAbsoluteLayer2 ();
    		add (abs2, null);
    		validate ();
    	}
    
    }

  2. #2
    atrodeyo is offline Member
    Join Date
    Apr 2012
    Posts
    41
    Rep Power
    0

    Default Re: having issue with validate ().. please help

    can anyone help me with this or atleast let me know where I can find some help about make this work?

Similar Threads

  1. Replies: 4
    Last Post: 04-02-2012, 08:57 PM
  2. Validate an array????
    By carlasofb in forum New To Java
    Replies: 5
    Last Post: 02-13-2012, 04:34 PM
  3. can someone validate my code?
    By alacn in forum New To Java
    Replies: 6
    Last Post: 08-08-2010, 04:18 AM
  4. Validate XML against XSD during generation
    By mandarkatdare in forum XML
    Replies: 0
    Last Post: 05-29-2010, 11:57 AM
  5. validate hex character
    By paul in forum New To Java
    Replies: 1
    Last Post: 07-25-2007, 10:08 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
  •