File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Positing component

 
deepak carter
Ranch Hand
Posts: 165
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47253
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using Flow layout?
 
deepak carter
Ranch Hand
Posts: 165
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47253
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic