Results 1 to 4 of 4
Thread: creating an invisible JButton
- 01-27-2011, 03:40 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 2
- Rep Power
- 0
creating an invisible JButton
hey all had a quick question,
I wanted to add a jbutton to a panel but just for its physical space on the panel and not so users can see it.
iv got the code:
p7.add(new JButton("Im invisible"));
i was thinking something like this:
p7.add(new JButton("Im invisible"){Visible=false});
but that doesnt work.
Iv got alot of invisible buttons to add hence i am not taking the route that invloves creating and naming jbutton variables and then using method setVisible to make them invisible.
Any ideas? Thanks
- 01-27-2011, 04:54 PM #2
That doesn't work because that's not valid syntax at all.
How is that an easier approach than simply calling setVisible()?
And why are you adding invisible JButtons again? I'm pretty sure there's a better way to accomplish whatever it is you're trying to do.How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 01-27-2011, 05:17 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 01-28-2011, 04:47 PM #4
Member
- Join Date
- Jan 2011
- Posts
- 2
- Rep Power
- 0
The reason why i want to add invisible buttons is because i am using a mixture of GridLayouts and BorderLayouts and with gridlayout you have to specifiy the number of rows and columns e.g. gridlayout(4,1) (means 4 rows and 1 column).
However i want to add my button to the 4th row because of its position and so i add other invisible buttons before it, so that they will occupy the above space.
The reason why i do not want to instantise new JButton variables is because i will not be needed the invisible buttons ever again, and so dont require them to have a local name or take up memory.
Perhaps I should be using another layout manager?
Im going to have a look at this. Thanks.
Similar Threads
-
Thread updates invisible GUI
By matthew712 in forum Threads and SynchronizationReplies: 4Last Post: 10-16-2010, 09:26 PM -
Creating shortcutkey for jbutton
By vsmilejay in forum AWT / SwingReplies: 2Last Post: 09-01-2010, 01:20 PM -
Invisible component
By lupo in forum AWT / SwingReplies: 3Last Post: 04-07-2010, 05:43 PM -
how to give JButton a name when creating GridLayout
By yasmin k in forum AWT / SwingReplies: 5Last Post: 11-03-2009, 11:16 PM -
Creating a JButton that does not show focus
By Java Tip in forum javax.swingReplies: 0Last Post: 06-26-2008, 07:38 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks