File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT / JFace and the fly likes Positing component Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "Positing component" Watch "Positing component" New topic
Author

Positing component

deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 136
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: 26716
Why are you using Flow layout?
deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 136
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: 26716
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?
 
 
subject: Positing component
 
Threads others viewed
BorderLayout Problem
adding one Jpanel to another
help with .isSelected
swing doesn't work
Test for button obscured
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com