Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (776)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  JToolTip  (Read 2888 times)
0 Members and 1 Guest are viewing this topic.
Offline BrainPain

Senior Newbie




Java games rock!


« Posted 2005-05-03 05:53:09 »

Hello.

I'm using and AWT Canvas and a Swing JToolBar.
The ToolBar is over the Canvas.
The Problem is if you want to read the ToolTip of a Button in the ToolBar the ToolTip will be displayed behind the Canvas. How can i fix this?
menues have the option to set them heavyweight but ToolTips?
Any Ideas?
Offline Garage_Joe

Senior Newbie




Java games rock!


« Reply #1 - Posted 2005-05-03 06:40:21 »

why do you use canvas and not a JPanel?

Heavyweight is always more heavy than lightweight ;-)

lg Clemens
Offline BrainPain

Senior Newbie




Java games rock!


« Reply #2 - Posted 2005-05-03 07:13:29 »

because i want to paint some stuff dynamical.
how should i do this with a JPanel?

of course it will be easier if only
swing elements are working together, but sun says:
"which class has not a direct equivalent in Swing? -> Canvas!"
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline c_lilian

Senior Devvie


Projects: 1


Java games will probably rock someday...


« Reply #3 - Posted 2005-05-03 07:37:48 »

To paint dynamically on a JComponent (or any subclass) , you just have to override paintComponent(Graphics).

And that's all.

For your tooltip problem, you can use TooltipManager.sharedInstance().setLightWeightPopupEnabled(false).

Lilian

Offline Orangy Tang

JGO Kernel


Medals: 57
Projects: 11


Monkey for a head


« Reply #4 - Posted 2005-05-03 07:38:56 »

IIRC, you can set tooltips to be heavyweight in the same way that you set JPopupMenus to be heavyweight. (Search!)

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline BrainPain

Senior Newbie




Java games rock!


« Reply #5 - Posted 2005-05-03 08:03:36 »

Thanks Lilian,

i know that i can override the paintComponent() function to draw my own stuff, but i am using a bufferstrategy and i think swing elements have their own buffering which is maybe not efficient enough for my purpose. and i am using a separate thread for painting and swing is known for beeing not thread-safe.
do you have any experiences with that?
Also thanks for saying how to switch the tooltips to heavyweight.

@orangy Tang:
i have searched before i posted here, but thanks for your great help.  Wink
Offline c_lilian

Senior Devvie


Projects: 1


Java games will probably rock someday...


« Reply #6 - Posted 2005-05-03 08:26:21 »

It seems mixing components is your solutions for performance.

I have ran into the same kind of problems, and found a good solution was :

- don't use any overlapping in your application (JInternalFrame is your ennemy).

- enable all workarounds for tooltips, popups


[warning probable shameless plug ;-) ]
At work, I use a docking framework of my company (I'm the author) to overcome the internal frames problems (but it's not the main reason).
I've patched it recently to support that kind of AWT/Swing mixing (the version including this patch will be released later on this week).
[/plug]

Offline BrainPain

Senior Newbie




Java games rock!


« Reply #7 - Posted 2005-05-03 10:05:43 »

yes, the mixing of awt/swing is now my solution because there is no swing class which is capable to do the stuff i need but canvas does.

i have tried JInternalFrame but the repaint of the DesktopPane was to bad so i don't want to use it.

what do you mean with workarounds for tooltips and popups? this heavyweight things or is there more to do?

(in our company we are using a docking framework, too.
but i'm not the author) Wink
Offline Garage_Joe

Senior Newbie




Java games rock!


« Reply #8 - Posted 2005-05-03 10:16:54 »

everything which AWT can do SWING also does. Get rid of your AWT hack, its really old and in my mind "canvas" should be marked as deprecated.

lg Joe
Offline c_lilian

Senior Devvie


Projects: 1


Java games will probably rock someday...


« Reply #9 - Posted 2005-05-03 10:20:26 »

There's another workaround for JPopUpMenu (setLightWeightPopUpEnabled(false) as OrangyTang said earlier).

Also, if you want to overlay components (including swing and AWT) you can since java 1.5 with Container.setComponentZOrder(), but it requires some tweaks (the overlapping swing component must belong to different heavyweight containers (Panel) ). It's what I've done to enable auto-expand/maximize component in the docking framework.
But with that patch, the code is not as readable as before : I'm now waiting for mustang which is said to support AWT/swing mixing.

Lilian

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline BrainPain

Senior Newbie




Java games rock!


« Reply #10 - Posted 2005-05-03 10:42:06 »

@Garage_Joe:

maybe you are right but maybe not, because if canvas should be marked as deprecated why there are thousands of experienced programmers which think that it is the best solution?
and if swing everything can do what awt does, why is it not thread-safe?

if you already implemented a canvas-like JPanel with a BufferStrategy and a Painting-Thread, i would be happy if you can give me some tips.
Offline Garage_Joe

Senior Newbie




Java games rock!


« Reply #11 - Posted 2005-05-03 10:59:54 »

Quote

maybe you are right but maybe not, because if canvas should be marked as deprecated why there are thousands of experienced programmers which think that it is the best solution?

Because it takes a long time till experienced programmers come to the conclusion that the way they did it till they started isn't the best anymore.
Have a look at yourself ;-)

Quote

and if swing everything can do what awt does, why is it not thread-safe?

Well, AWT isn't thread-safe either. It was designed to be thread-safe but it soon turned out that this was a BAD desision and some hacks to allow AWT stuff to be used from many threads was even removed in 1.2+!
So in most situations it will work but it is really not recommended. In Swing the removed thread-safty from the beginning to avaoid the mistakes made with AWT.
Multi-Threaded Graphics is never a good idea, at least on all underlaying graphic subsystems AWT is supported on.
Rendering is always done only with a single thread down to the hardware!

Quote

if you already implemented a canvas-like JPanel with a BufferStrategy and a Painting-Thread, i would be happy if you can give me some tips.

No I haven't. But if you really need to draw from multiple threads maybe your design is broken anyway?

lg Joe
Pages: [1]
  ignore  |  Print  
 
 

 
hadezbladez (269 views)
2018-11-16 13:46:03

hadezbladez (146 views)
2018-11-16 13:41:33

hadezbladez (279 views)
2018-11-16 13:35:35

hadezbladez (62 views)
2018-11-16 13:32:03

EgonOlsen (2109 views)
2018-06-10 19:43:48

EgonOlsen (2141 views)
2018-06-10 19:43:44

EgonOlsen (1353 views)
2018-06-10 19:43:20

DesertCoockie (1941 views)
2018-05-13 18:23:11

nelsongames (1593 views)
2018-04-24 18:15:36

nelsongames (2241 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!