Home arrow static arrow Java Programming [Archive] - JToolBar on awt Frame
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - JToolBar on awt Frame
This topic has 8 replies on 1 page.

Posts:177
Registered: 9/13/01
JToolBar on awt Frame  
Jul 14, 2004 6:30 AM



 
Hi all,
Adding JToolBar on awt Frame looks fine when using jdk1.3 but when using jdk1.4.1 it looks like ****.
Anyone know why?
Is that a problem of mixing awt & swing components?

Thanks,
Lior.
 

Posts:177
Registered: 9/13/01
Re: JToolBar on awt Frame  
Jul 17, 2004 10:50 PM (reply 1 of 8)



 
Hi all,
Isn't there anyone who can tell me why JToolBar looks different on AWT Frame in JDK1.4.1.

Need help on this one,
Lior.
 

Posts:177
Registered: 9/13/01
Re: JToolBar on awt Frame  
Jul 18, 2004 12:06 AM (reply 2 of 8)



 
Any help??

It drives me crazy!!

Thanks,
Lior.
 

Posts:177
Registered: 9/13/01
Re: JToolBar on awt Frame  
Jul 18, 2004 4:35 AM (reply 3 of 8)



 
I tried just adding JToolBar on a JFrame and also got incorrect view using JDK1.4.2
 

Posts:177
Registered: 9/13/01
Re: JToolBar on awt Frame  
Jul 18, 2004 8:05 AM (reply 4 of 8)



 
Hi all,
Where are you?
What happend to JToolBar GUI in JDK1.4.2?
Is there any reported bug about it ?

I tried the following:

import javax.swing.*;

public class Frame1 extends JFrame
{
public Frame1()
{
this.getContentPane().setLayout(null);
setSize(405,305);
setVisible(false);
JToolBar tb = new JToolBar();
tb.setBounds(0, 0, 150, 40);
tb.setEnabled(false);
this.getContentPane().add(tb);
}

public Frame1(String title)
{
this();
setTitle(title);
}

static public void main(String args[])
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
(new Frame1()).setVisible(true);
}
catch (Throwable t)
{
}
}

}

Please help.

Lior.

 

Posts:21,719
Registered: 98-02-20
Re: JToolBar on awt Frame  
Jul 18, 2004 8:17 AM (reply 5 of 8)



 
You shouldn't be mixing Swing and AWT. Don't do it. Make it a 100% Swing UI and it'll work.

%
 

Posts:21,719
Registered: 98-02-20
Re: JToolBar on awt Frame  
Jul 18, 2004 8:20 AM (reply 6 of 8)



 
You have no idea of what you're doing.

You've got an empty catch block that catches Throwable and doesn't even print a message or stack trace. That's one of the worst things you can do, because now your code could silently fail and never tell you.

Start with the Swing UI tutorial. Adding tool bars to frames isn't that hard.

%
 

Posts:709
Registered: 5/12/04
Re: JToolBar on awt Frame  
Jul 18, 2004 8:32 AM (reply 7 of 8)



 
You haven't added anything (buttons, etc..) to your JToolBar.
You have also set it non-enabled.

I second duffymo's suggestion(s).
Check up on the Swing Tutorial. It explains things clearly.

regards,

lutha
 

Posts:177
Registered: 9/13/01
Re: JToolBar on awt Frame  
Jul 18, 2004 10:49 PM (reply 8 of 8)



 
I catch nothing becouse this is just an example and I wanted it to be short.
In the above EXAMPLE I used only SWING components and it looks bad when using JDK1.4.2 (It looks fine when I checked it using JDK1.3.1.

Lior.
 
This topic has 8 replies on 1 page.