473,394 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

JFrame hides the JToolBar

Hi,
I want to create a toolbar that is floating by default and is not
dockable. I understand that for this I have to override the default
BasicToolBarUI. For this I wrote the following code.
JToolBar toolBar
BasicToolBarUI myui = new BasicToolBarUI() {
public boolean canDock(Component c, Point p) { return false; }
public boolean isFloating() { return true; }
};
toolBar.setUI(myui);
Point p = this.getLocation();
myui.setFloatingLocation(p.x, p.y);
myui.setFloating(true, p);

The toolbar is being added to a JFrame. When the application
instantiates, the toolbar is by default floating but the Frame hides
this ToolBar. If I comment outthe myui.setFloating line then toolbar
is not floating by default. When I grab the toolbar and make it
floating, the Frame does not cover this toolbar and behaves as
expected.
I am using Java 1.4.2-b28.
Thanks in advance,
Ranjan
Jul 17 '05 #1
3 3388
nos

"Ranjan Sinha" <rn********@indiatimes.com> wrote in message
news:b2**************************@posting.google.c om...
Hi,
I want to create a toolbar that is floating by default and is not
dockable. I understand that for this I have to override the default
BasicToolBarUI. For this I wrote the following code.
A while back I had a JFrame with a toolbar and I did not
override BasicToolBarUI and it worked fine.
JToolBar toolBar
BasicToolBarUI myui = new BasicToolBarUI() {
public boolean canDock(Component c, Point p) { return false; }
public boolean isFloating() { return true; }
};
toolBar.setUI(myui);
Point p = this.getLocation();
myui.setFloatingLocation(p.x, p.y);
myui.setFloating(true, p);

The toolbar is being added to a JFrame. When the application
instantiates, the toolbar is by default floating but the Frame hides
this ToolBar. If I comment outthe myui.setFloating line then toolbar
is not floating by default. When I grab the toolbar and make it
floating, the Frame does not cover this toolbar and behaves as
expected.
I am using Java 1.4.2-b28.
Thanks in advance,
Ranjan

Jul 17 '05 #2
For a normal JToolBar that is not floating by default, everything
works fine and I don't need to extend BasicToolBarUI. This case is
special. I require JToolBar to be floating by default. So that when
the application launches, JToolBar should be floating somewhere inside
the application's frame.
Thanks in advance
Jul 17 '05 #3
Have you tried drawing the frame with docked toolbar, then undocking the
toolbar? (I presume you are setting it undocked before the frame and toolbar
are drawn).

If this works, you can always draw it off screen the move it on screen when
undocked..

"Ranjan Sinha" wrote"
For a normal JToolBar that is not floating by default, everything
works fine and I don't need to extend BasicToolBarUI. This case is
special. I require JToolBar to be floating by default. So that when
the application launches, JToolBar should be floating somewhere inside
the application's frame.
Thanks in advance

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Lem | last post by:
How do I close a JFrame Window, other than calling system.exit(0) or dispatchEvent()? Thanks in advance, Lem
0
by: Jeff T. | last post by:
Hi, I have a JMenuBar object that contains a JToolBar object which contains some JButton objects. After I let my applet sit for > 20 minutes, the graphics on those buttons would disappear. ...
1
by: Tuno | last post by:
I'm relatively new to Java Swing programming. I have a console application that processes text files and while doing so I want to suspend the execution when an error is encountered that requires...
5
Shinzon
by: Shinzon | last post by:
ok so far I have got: JFrame frame = new JFrame( "Matt's DVD's" ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.setSize( 420, 170 ); // set frame size ...
5
Shinzon
by: Shinzon | last post by:
Ok so I have been working on this for a moment now and wondering how to add multiple jlabels to a jframe. the code looks like this: JLabel jl = new JLabel("DVD ID #= " + dvd); //Displays DVD...
3
by: coffeetime | last post by:
Hi, I just decided to learn java, so I'm quite a noob. I use the book learning java third edition. have JDK 1.6 program in notepad. I have made the simple HelloJava example, and now i wanted to...
3
by: coffeetime | last post by:
Hi, I just decided to learn java, so I'm quite a noob. I use the book learning java third edition. have JDK 1.6 program in notepad. I have made the simple HelloJava example, and now i wanted to...
2
by: zahit | last post by:
hi guys, my line doesn't appear on the frame. what's the problem? import java.util.*; import java.io.*; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.*; public class...
6
by: gaya3 | last post by:
Hi, I need to make the frame invisible on action event in swings. I have the following code: public class sample_pgm extends JFrame{ public void sample() { JFrame jf =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.