• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Positing component

 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you using Flow layout?
 
deepak carter
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic