Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Dock a frame?  RSS feed

 
Nathan Paris
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anyone succesfully gotten a JFrame to dock? I will need for other applications to know that I am docked there, or vice versa that I can tell if another app is docked.
Thanks,
Nathan
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only docking mechanism that Swing supports "out of the box" is JToolBar... depending on how slick you want your docking mechanism to be you could use a modified JToolBar, or you could attach ComponentListeners to each of your frames and move them all relative to one that moved.

Why don't you describe exactly what you are trying to do... it would be easier to come up with a solution...
 
Nathan Paris
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to be able to dock an application, just like the Microsoft Shortcut bar or the Start Menu. It will need to be able to dock on any edge as well as other apps will need to know that the app is docked there.
I found in a thread that someone said JNI would need to be used, but didnt give any more details.
Anyone?
Thanks
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as the JAVA app goes, all you need to do is find out the dimensions of the screen, do some calculations based on that and the size of your Application Window, and then listen for Drag events on your window to determine when you are close enough to the edge to "dock" the app.
As far as detecting other running applications, yeah, JNI, and I would venture to guess that there will be a lot of work involved because I think you will have to search your memory and identify those running applications. WHOA!! More than what I would want to tackle. Good luck though.
 
Nathan Paris
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is what I am planning for the Java part, but have very little idea on the JNI part, and was hoping someone had tackled this problem already.
Thanks for the info, and if anyone has more details on the JNI side please let me know!
Thanks
 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nathan, I'm about to tackle dockable JInternalFrames and searching on JavaRanch turned up this post. Were you able to do it? Have any tips and/or code you can share?
--Mark
 
Nathan Paris
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Withe the JInternalFrames you shouldnt have to use JNI, but should just be able to use the java solutions that we have already discussed. Mine was NOT a JInternalFrame but a JWindow and JFrame and needed to be be able to dock as well as always remain on top much like the Microsoft app bar. This required JNI.
Nathan
 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, I think I found a much simplier solution in my case (keeping mind docking would've required relaying out the components as the frame shape changed signifcantly)...
The item being docked is pretty simple, a few radio buttons, text fields, and buttons. It also turns out undocking is much more important then docking. So I'll keep the undocked window as is. The base window will have a button allowing for the display of the 'docked" window--basically, I'll just expand the frame and add another panel at the bottom. That panel will have an "undock" button which will basically hide the panel and create this external window.
The reality is, nothing will be docked, but it will look pretty close to it.

--Mark
 
Nathan Paris
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it doesnt have to trully be docked then no need for JNI. I.e. our app needed to be completely docked as in the icons on the desktop needed to be aware of it, needed to always by on top...basically everything just like the windows task bar.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!