hi..
so basically my program works like this.....first frame > buttons > another frame > more buttons > lead to another frame ... but a few problems are preventing me from doing this.

p.s. I don't want to use the cardlayout because I want my buttons like a column, and I'm only showing part of the code that Im having problem with.. but if you want to see my whole program in order to solve this problem I'll post it too. :) thanks

Problems:
In my second frame I'm adding ...
1. A button, but it's not in the position that I want, like I want it more in the center and not so high up.
2. I've tried adding another button under the first button(like a column of buttons) but the second button isn't displaying. Maybe it's because of the way the position is ....

Yeaa.. can some1 help me fix this problem?
picture of the window (GUI window):
http://i47.tinypic.com/29g1kjn.jpg

this is the part of the code:

/* Creates a homepage frame */ 
     private void homepageFrame() { 
      homepageFrame = new JFrame("Homepage"); 
      homepageFrame.setSize(350, 320); 
      homepageFrame.setDefaultCloseOperation  (JFrame.EXIT_ON_CLOSE); 
      homepageFrame.setVisible(true);
      
      /* creates a button called tacobell */ 
      tacobellButton = new JButton("Taco Bell");
      tacobellButton.setActionCommand("TacoBell");
      tacobellButton.addActionListener(this); 
      contentPane.add(Box.createRigidArea(new Dimension(0, 15)));
      JPanel contentPanel = new JPanel(); 
      contentPanel.add(tacobellButton);
      homepageFrame.add(contentPanel);
      
      /* creates a button called mcdonald under the tacobell button */ 
     /* but it's not displaying - and not it's not even making the tacobell button display */ 
      mcdonaldButton = new JButton("Mcdonald");
      mcdonaldButton.setActionCommand("Mcdonald");
      mcdonaldButton.addActionListener(this); 
      contentPane.add(Box.createRigidArea(new Dimension(0, 15)));
      JPanel contentPanel2 = new JPanel(); 
      contentPanel.add(mcdonaldButton);
      homepageFrame.add(contentPanel2);

}

Sooner or later you'll get to GridBagLayout - not the easiest to use, but it's the one that gives you the most control. Hang on in thru the learning curve and you'll never regret it.

If you're going to spend some time learning about layoutmanagers. Make sure you put all your efforts into GridBagLayout, its probably the most useful one. All the neat java UIs you see are based on GBL.

you may try this ...

the location you put like below code..
addComponent(panel, button(or)any field, x,y,width,height);

JPanel contentPane;

                addComponent(contentPane, jTextField1, 22,48,166,22);
		addComponent(contentPane, jTextField2, 23,92,100,20);
		addComponent(contentPane, jbutton, 246,51,163,22);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.