Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



JPanle update in java

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 26-11-2009
Member
 
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.

Reply With Quote
  #2  
Old 26-11-2009
Member
 
Join Date: Feb 2008
Posts: 1,843
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.
Reply With Quote
  #3  
Old 26-11-2009
Member
 
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.
Reply With Quote
  #4  
Old 26-11-2009
Member
 
Join Date: May 2008
Posts: 2,377
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.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "JPanle update in java"
Thread Thread Starter Forum Replies Last Post
Java Auto Updater wants me to update java everyday in Windows 7 minajoh Windows Software 4 04-09-2013 11:04 PM
Not able to uninstall Java TM 6 Update 29 Yayati Windows Software 12 11-04-2012 06:49 AM
Unable to install Java 6 Update 23 Xymaya Windows Software 4 26-12-2010 06:23 PM
Unable installing Java update Camillee Windows Software 5 13-01-2010 02:42 PM
Java update for Windows 64 Bit supremer Windows x64 Edition 3 06-09-2005 07:52 PM


All times are GMT +5.5. The time now is 12:39 PM.