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

Tags: , , , ,

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

Sponsored Links
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
MindSpace's Avatar
Member
 
Join Date: Feb 2008
Posts: 1,839
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
opaper's Avatar
Member
 
Join Date: May 2008
Posts: 2,371
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "JPanle update in java"
Thread Thread Starter Forum Replies Last Post
Not able to uninstall Java TM 6 Update 29 Yayati Windows Software 12 11-04-2012 06:49 AM
Unable installing Java update Camillee Windows Software 5 13-01-2010 02:42 PM
Can i delete the old java version update FeebaAnni Windows Software 4 24-07-2009 11:03 AM
Sun Java JRE 6 Update 14 updated with Win 7 compatibility Erubiel Windows x64 Edition 2 29-05-2009 07:52 AM
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 07:26 AM.