GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Positing component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Positing component" Watch "Positing component" New topic
Author

Positing component

deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
Hi
This the code i have written


package Swing;
import javax.swing.*;
import java.awt.*;


public class JCheckBoxTest
{

JCheckBox ch;
JButton b1;
JPanel p,p1;
JFrame f;
JCheckBoxTest()
{

f=new JFrame();
f.setLayout(new FlowLayout());
p=new JPanel();
p1=new JPanel();
b1=new JButton("Press");
ch=new JCheckBox("Red");
p.add(ch);
p1.add(b1, 0);
f.getContentPane().add(p);
f.getContentPane().add(p1);
f.setSize(400,500);
f.setVisible(true);


}
public static void main(String[] args)
{
new JCheckBoxTest();
}
}

now when i am running it it is showing both checkbox and button in the same line .Like one after another.I dont want that.

How to make button to come to next line or at the bottom?

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39095
    
  23
Why are you using Flow layout?
deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
oh,

It is commented ...i dont know why it didnt got pasted here.still...after commenting the F.FLOWLAYOUT(NEW FLOWLAYOUT()).still its coming one after another.Can there be showhow button comes below checkbox
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39095
    
  23
deepak carter wrote:oh,

It is commented ...i dont know why it didnt got pasted here.still...after commenting the F.FLOWLAYOUT(NEW FLOWLAYOUT()).still its coming one after another.Can there be showhow button comes below checkbox
Pardon?

What do you know about layouts?
 
GeeCON Prague 2014
 
subject: Positing component