Results 1 to 9 of 9
- 09-22-2009, 10:19 AM #1
Member
- Join Date
- Sep 2009
- Location
- Italy, Turin
- Posts
- 39
- Rep Power
- 0
Switch JPanels in a single JFrame
Hi, i'm having some problem in realizing a Frame.. my customer asked me to create a single window (it's a quite big insertion form) in this section of this program and he also asked me to split all the textFields and the ckeckBoxes of this form in 2 or more different panel of the same window, that the user can "slide" with the button "next"...
The reason is there are too many information to fill in a single big window, so it's better to split the information in more "slidable" panel. The buttons next and back instead, shoud be settled in the bottom of the window and obviously at the 1st "page" the back button is disabled and the same thing for the next button at the last "page".
So my question is: how can i use the netBeans visual design IDE to make this? Yes i can work on all the single panels i want to split.. but how can i put all of them in the same jFrame at the same coordinates?? is it possible?? and when the next button is clicked do something like this?:
buttonNextActionPerformed(ActionEvent evt){
jPanel_N.setVisible(false);
jPanel_N+1.setVisible(true);
}
or maybe you can suggest me other solutions?
thanx.
PS: I'm italian, so sorry for my english grammar mistakes..
- 09-22-2009, 10:25 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Read about CardLayout.
- 09-22-2009, 09:08 PM #3
Senior Member
- Join Date
- Aug 2009
- Location
- Pittsburgh, PA
- Posts
- 282
- Rep Power
- 4
Here's another approach to think about:
Use the designer to lay out a single JPanel, perhaps calling it allTheFields.
Lay out everything on that one JPanel.
Then make the panel the contents of a JScrollPane.
Something vaguely like:
This way the user can scroll to see a variable subset of the fields.Java Code:ScrollPane appScroll = new JScrollPane(allTheFields, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); JFrame app = new JFrame(); app.add(allScroll);
And the user is spared the disorientation
of completely refilling the window with Next or Back.
Incidentally, I usually use NetBeans to layout a window initially.
And then find that it is much too rigid, so I write a purpose-build
LayoutManager that puts things where I want them.
It usually winds up to be much less work than fighting the NetBeans designer.
- 09-22-2009, 09:52 PM #4
Member
- Join Date
- Aug 2009
- Posts
- 8
- Rep Power
- 0
I think CardLayout has been deprecated for a while... You may also want to consider a TabbedPane approach.
- 09-22-2009, 09:53 PM #5
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
You might want to check out the "Card Layout Actions" entry which makes it easier to use a CardLayout:
tips4java.wordpress.com/2008/11/01/card-layout-actions
-
To mcashe: Please back this statement up with facts.
To the original poster: while mcashe has a point regarding possible use if JTabbedPane as a way to swap views, please ignore his other "advice" regarding CardLayout. Personally I think that CardLayout is the way to go here.You may also want to consider a TabbedPane approach.
- 09-23-2009, 01:11 AM #7
Member
- Join Date
- Aug 2009
- Posts
- 8
- Rep Power
- 0
My apologies if I offended anyone here. I was speaking from personal experience. I was asked to do a prototype using CardLayout like 6 years ago and if my memory serves me correctly, the only reason I was able to do it was because we were still using like swing 1.1.8 or something like that. I thought it had gone away with that version. I'll look into it.
- 09-23-2009, 01:20 AM #8
Member
- Join Date
- Aug 2009
- Posts
- 8
- Rep Power
- 0
- 09-23-2009, 09:30 AM #9
Member
- Join Date
- Sep 2009
- Location
- Italy, Turin
- Posts
- 39
- Rep Power
- 0
I already thought about a JTabbedPane approach, but my boss discard this option.
However i'm reading documentation about CardLayout... and i think it's really what i need to realize.. i'll test some methods of this class, and i'll let you know if it works or if i have other problems using CardLayout.
thanks:)
Similar Threads
-
HELP with jPanels
By maverik_vz in forum AWT / SwingReplies: 1Last Post: 03-12-2009, 11:46 AM -
Help with overlapping JPanels
By xcallmejudasx in forum New To JavaReplies: 2Last Post: 03-09-2009, 10:19 PM -
Adding Multiple Panels and Single Scroll bar on the JFrame
By SANDY_INDIA in forum AWT / SwingReplies: 6Last Post: 07-28-2008, 06:04 PM -
Can't synchronize multiple JPanels in a JFrame
By vassil_zorev in forum AWT / SwingReplies: 0Last Post: 12-30-2007, 04:22 PM -
How to add Images to JPanels?
By Soda in forum New To JavaReplies: 3Last Post: 12-08-2007, 05:54 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks