wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JTabbedPane pblm. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTabbedPane pblm." Watch "JTabbedPane pblm." New topic
Author

JTabbedPane pblm.

Arun Martin
Ranch Hand

Joined: Dec 01, 2000
Posts: 64
Hi,
I am designing a swing application. I am to use JTabbedPanes. In one JFrame screen, I want two JTabbed Panes
(1).Add New User
(2).Change New User.
(1) contains a Label "ADD".
(2) contains a Label "MODIFY"
What I require:
1. When I click "Add New User" tab, "ADD". should be displayed hiding "MODIFY"
2. When I click " Change New User" tab, "MODIFY". should be displayed hiding "ADD".
Problems faced:
----------------
1. When first time I run the pgm,I click the ADD User Tab, nothing is displayed.
Then I click the MODIFY Tab, "MODIFY" is displayed and after that when I click ADD Tab,the same label "modify" is being displayed and then "modify" is always displaced irrespective of the tabbed panes clicked.
What could be the cause of this?.
2. I changed the setLayout(null) so that I could position components according to my desired locations. The pgm is running but only the blank JFrame is displayed. Will JTabbedPannes not work in setLayout(null)?.
3. There are only 2 JTabbedpanes. They occupy only a portion of the top left hand side of the screen. Is there any method through which I can place the 2 panes equidistant from each other?
The Program:
------------

with warm regards,
Arun.

please use code tags when posting source code.
thxs.
- satya



[This message has been edited by Madhav Lakkapragada (edited July 15, 2001).]
Mo Ibrahim
Greenhorn

Joined: Jul 10, 2001
Posts: 28
I modified your code and here it is working:

[This message has been edited by Mo Ibrahim (edited July 14, 2001).]
[This message has been edited by Mo Ibrahim (edited July 14, 2001).]
Arun Martin
Ranch Hand

Joined: Dec 01, 2000
Posts: 64
Hi Ibrahim,
Thanks a lot for the refined pgm.In the refined pgm, I have got 2 doubts.
1. public static void main(String[] a)
{
TabbedPane ob = new TabbedPane();
return;
}
Why the return stmt has been included in the first place?. When I remove return stmt, and when I run the pgm,the Add User Tab doesn't show any result?. Could u please explain the reason behind this?
2. public static JLabel getChangeLabel()
{ return label;
}
In the above mentioned code,if I change the code to
public JLabel getChangeLabel()
{
return label;
}
class TPListener implements ChangeListener
{
//
public void stateChanged(ChangeEvent ce)
{
//
//
//
//
JLabel label = getChangeLabel();
}
}

The pgm works perfectly fine. Why this inclusion of static
keyword?.
with warm regards,
Arun.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTabbedPane pblm.
 
Similar Threads
JTextField : setText() is not working. getText() is working
In JTabbedPane, updation of database values not working
JTabbedPane pblm.
In JTabbedPane, updation of database values not working
JTabbedPane pblm.