Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2005

Tip: Looking for answers? Try searching our database.

Strange behaviour of JTabbedPane

Thread view: 
Roland Zitzke - 28 Nov 2005 15:53 GMT
Hi,
I have a tabbed pane with three tabs (only two are shown below).
All content is different except that two tabs share a status message box.
Sharing means that I want to display the same content in both tabs at that
position.
The strange effect is that the status box is only visible in the last tab I
added to the tabbed pane.
Do I need to "refresh" something here?
Is there a general problem with sharing the same Gui object accross
different panes? any hints?
Thanks and regards
Roland

code fragments:
private JTabbedPane tabPane;
private JPanel traceButtonPane = null;
private JPanel masterButtonPane = null;
private JScrollPane statusPane = null;
private JTextArea statusText = null;
JScrollPane getStatusPane() {
 if (statusPane == null) {
  statusPane = new JScrollPane();
  statusPane.setViewportView(getStatusText());
 }
 return statusPane;
}
JTextArea getStatusText() {
 if (statusText == null) {
  statusText = new JTextArea("Message console\n");
  statusText.setEditable(false);
 }
 return statusText;
}
private JPanel getMasterButtonPane() {
 if (masterButtonPane == null) {
//    here seems to be a problem
// removing the comments below will switch the tab with the visible status
pane
masterButtonPane.add(getStatusPane());
 }
 return masterButtonPane;
}
private JPanel getTraceButtonPane() {
 if (traceButtonPane == null) {
  traceButtonPane = new JPanel();
// here we add the status pane to the second tab and this fails
// in the sense that only one tab actually shows it
  traceButtonPane.add(getStatusPane());
}
 return traceButtonPane; }
private JTabbedPane getTabPane() {
 if (tabPane == null) {
  tabPane = new JTabbedPane();
tabPane.add(getMasterButtonPane());
tabPane.add(getTracerButtonPane());
}
return tabPane;
}
Oliver Wong - 28 Nov 2005 20:18 GMT
> Hi,
> I have a tabbed pane with three tabs (only two are shown below).
[quoted text clipped - 8 lines]
> Thanks and regards
> Roland

[code snipped]

   Instead of addind ghte same status box to both panes, did you try adding
two different status boxes, but having them share the same document model?

   - Oliver
Roland Zitzke - 29 Nov 2005 09:19 GMT
Oliver Wong schrieb:
>> Is there a general problem with sharing the same Gui object accross
>> different panes? any hints?
>
>    Instead of addind ghte same status box to both panes, did you try
> adding two different status boxes, but having them share the same document
> model?

This works great, thank you!

/Roland


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.