By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,373 Members | 1,792 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,373 IT Pros & Developers. It's quick & easy.

JFrame hides the JToolBar

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.