File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JDialog: accessing its Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JDialog: accessing its "title bar"" Watch "JDialog: accessing its "title bar"" New topic
Author

JDialog: accessing its "title bar"

Claude Moore
Ranch Hand

Joined: Jun 24, 2005
Posts: 430
    
    1

Hi there,

I need to add a custom handler for double-click on a JDialog's title bar. I need the component to be reactive only if user clicks twice on the title bar; the problem is I don't know how (and I did not find anything useful on the matter) access that part of the component. Can anyone suggest me how to achieve this ?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
this works, but the 'JDialog.setDefaultLookAndFeelDecorated(true)' is a bit ugly

Claude Moore
Ranch Hand

Joined: Jun 24, 2005
Posts: 430
    
    1

Michael,

thank you so much for your reply and providing me a sample. In a nutshell, the part of the code that gives you a reference to JDialog's title is


Your code works, anyway there's another problem: I cannot drag dialog's window anymore. It seems "frozen". It's like if adding a MouseListener to d.getLayeredPane().getComponent(1) inhibits default drag handler...

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
it would probably consume the mouseEvent that would normally pass to the default listener handling the dragging.

add your own mouseMotionListener for dragging

Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Or add the custom listener to the dialog (which is where the original drag handler is added).
Took a fair amount of sleuthing through the sources to find the handler.


luck, db
There are no new questions, but there may be new answers.
Claude Moore
Ranch Hand

Joined: Jun 24, 2005
Posts: 430
    
    1

Thak you so much, I've tested Michael's second post code and it works greatly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDialog: accessing its "title bar"
 
Similar Threads
how to add html text in JFrame title bar? (Urgent) anyone?
create modal JWindow
Creating frame withouth title bar
hot to change the icon at title bar?
popup