Results 1 to 7 of 7
  1. #1
    yuen is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Question how can create border

    how can i create the border with lebel "Actions"
    any one can help
    and add radiabutton inside the border:confused:

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    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);

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by yuen View Post
    and add radiabutton inside the border:confused:
    Or is he expecting something like group box, with the label Actions. I'm not clear the question.

  4. #4
    yuen is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default

    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);

  5. #5
    yuen is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default

    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"

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  7. #7
    yuen is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    Sorry!! It's createTitledBorder("Actions")
    thank you..
    i get it!!!:):)

Similar Threads

  1. Border with LestCellRenderer
    By Gajesh Tripathi in forum AWT / Swing
    Replies: 5
    Last Post: 06-02-2009, 07:59 AM
  2. How to remove border in JComboBox
    By tiro in forum AWT / Swing
    Replies: 2
    Last Post: 03-08-2009, 06:45 PM
  3. Textfield border problem
    By jurka in forum AWT / Swing
    Replies: 2
    Last Post: 08-31-2008, 10:15 AM
  4. Displaying a Button with a Border
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-26-2008, 08:40 PM
  5. Border Layout
    By mark-mlt in forum Java Applets
    Replies: 5
    Last Post: 05-12-2008, 10:48 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •