Results 1 to 7 of 7
Thread: how can create border
- 11-07-2009, 04:59 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 4
- Rep Power
- 0
-
If I understand what you are trying to do, then setting the border of a JPanel using setBorder(...) would help. You could then use the BorderFactory's static createTitleBorder("..") method to create the actual border.
Create a JPanel, say called radioButtonPanel and set its border using
Java Code:JPanel radioButtonPanel = new JPanel(); radioButtonPanel.setLayout(new GridLayout(0, 1)); // if you want several radiobuttons in a column radioButtonPanel.setBorder(BorderFactory.createTitleBorder("Actions")); // set the border radioButtonPanel.add(myRadioBtn1); radioButtonPanel.add(myRadioBtn2); radioButtonPanel.add(myRadioBtn3);
- 11-08-2009, 01:23 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 11-08-2009, 03:24 AM #4
Member
- Join Date
- Nov 2009
- Posts
- 4
- Rep Power
- 0
thank Fubarable,
i add radioButtonPanel.setBorder(BorderFactory.createTit leBorder("Actions"));
in my code but got error
method createTitleBorder(java.lang.String)
location: class javax.swing.BorderFactory
p2.setBorder(BorderFactory.createTitleBorder("Acti ons"));
how can i fix it?
this is my code
' JPanel p1=new JPanel();
p1.add( lb1);
p1.add( lb2);
JPanel p2=new JPanel();
p2.setBorder(BorderFactory.createTitleBorder("Acti ons"));
p2.add(rb1);
p2.add(rb2);
p2.add(rb3);
p2.add(rb4);
p2.add(rb5);
add("Center", p2);
JPanel p3=new JPanel();
p3.add(btn1);
p3.add(btn2);
p3.add(btn3);
p1.setLayout(new GridLayout(2,1));
p2.setLayout(new GridLayout(5,1));
setLayout(new BorderLayout());
add(p1,BorderLayout.NORTH);
add(p2,BorderLayout.CENTER);
add(p3,BorderLayout.SOUTH);
- 11-08-2009, 03:27 AM #5
Member
- Join Date
- Nov 2009
- Posts
- 4
- Rep Power
- 0
thank Eranga ,
actually i want post the picture together,but i just a new member so cant post..
actually, i want create a border then inside got radioButton and the border have Title"Action"
-
Sorry!! It's createTitledBorder("Actions")
- 11-08-2009, 11:42 AM #7
Member
- Join Date
- Nov 2009
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Border with LestCellRenderer
By Gajesh Tripathi in forum AWT / SwingReplies: 5Last Post: 06-02-2009, 06:59 AM -
How to remove border in JComboBox
By tiro in forum AWT / SwingReplies: 2Last Post: 03-08-2009, 05:45 PM -
Textfield border problem
By jurka in forum AWT / SwingReplies: 2Last Post: 08-31-2008, 09:15 AM -
Displaying a Button with a Border
By Java Tip in forum javax.swingReplies: 0Last Post: 06-26-2008, 07:40 PM -
Border Layout
By mark-mlt in forum Java AppletsReplies: 5Last Post: 05-12-2008, 09:48 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks