Results 1 to 4 of 4

Thread: JPanle update in java

  1. #1
    Join Date
    Nov 2008
    Posts
    240

    JPanle update in java

    Hi
    I am writing a code for java. In the program I have JPanel full of buttons inside a JFrame. Now I want to change the position of the buttons. I tried it by removing them and adding the buttons back, but this is not working any ideas. here is my program.
    Code:
    bpanel.removeAll();
     for (int i=0; i<9; i++)
       {
       but[ i ] = new JButton( Names[ i ] );
       bpanel.add(but[i]);
       }
    getContentPane().add(bpanel);
    any ideas on how I can achieve this task.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,856

    Re: JPanle update in java

    Hi
    I think the code you have posted in incomplete. We will require more code so that we can understand what you have really done. Even a small program which can demonstrate your problem will do. Your question is correct, but before going through your code we can not give you the answer. So, it would be better if you post your code so that we can give you reviews for it.

  3. #3
    Join Date
    Nov 2008
    Posts
    240

    Re: JPanle update in java

    Hi
    I am sorry for that. I have posted my code below. This is my updated code so just go through it and see if you can get some ideas for what I am asking.
    Code:
    bpanel.removeAll();
    
    bpanel.getRootPane().revalidate();  
    
    for (int i=0; i<9; i++)
       {
       but[ i ] = new JButton( Names[ i ] );
       bpanel.add(but[i]);
       }
    
    getContentPane().add(bpanel);
    Any help or advice will be appreciated. Thanks in advance.

  4. #4
    Join Date
    May 2008
    Posts
    2,393

    Re: JPanle update in java

    Hi
    Your code is just mixed you too much, that is why I thick you are confused. You can change the order by adding them in this way
    Code:
    bpanel.add(but[0]);
    bpanel.add(but[5]);
    bpanel.add(but[1]);
    bpanel.add(but[4]);
    bpanel.add(but[8]);
    bpanel.add(but[6]);
    bpanel.add(but[2]);
    bpanel.add(but[3]);
    bpanel.add(but[1]);
    I think this might solve your problem.

Similar Threads

  1. Replies: 4
    Last Post: 04-09-2013, 11:04 PM
  2. Not able to uninstall Java TM 6 Update 29
    By Yayati in forum Windows Software
    Replies: 12
    Last Post: 11-04-2012, 06:49 AM
  3. Unable to install Java 6 Update 23
    By Xymaya in forum Windows Software
    Replies: 4
    Last Post: 26-12-2010, 06:23 PM
  4. Unable installing Java update
    By Camillee in forum Windows Software
    Replies: 5
    Last Post: 13-01-2010, 02:42 PM
  5. Java update for Windows 64 Bit
    By supremer in forum Windows x64 Edition
    Replies: 3
    Last Post: 06-09-2005, 07:52 PM

Posting Permissions

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