Re: Windows Decoration Listeners? - Problem Solved



Michael Dunn wrote:
there doesn't seem to be any way to see actions on the title bar on a JFrame.

seems to work OK like this, but the frame might not be what you want.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Testing
{
public void buildGUI()
{
JFrame.setDefaultLookAndFeelDecorated(true);
final JFrame f = new JFrame();
f.setSize(400,200);
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
f.addMouseListener(new MouseAdapter(){
public void mousePressed(MouseEvent me){
if(me.getY() < f.getRootPane().getInsets().top +
f.getContentPane().getY())
{
System.out.println("Title bar clicked");
}
}
});
}
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable(){
public void run(){
new Testing().buildGUI();
}
});
}
}


Michael:

That doesn't work in my WinXP SP2 box running Sun's 1.6 JDK.

--

Knute Johnson
email s/nospam/knute/
.



Relevant Pages

  • Re: Canvas
    ... I added a Canvas in a JFrame. ... public void actionPerformed{ ... public class MyCanvas2 extends Canvas{ ...
    (comp.lang.java.programmer)
  • Re: Drawing Image
    ... put on to a JFrame which has several internal frames. ... public class test extends JPanel { ... public void paintComponent{ ...
    (comp.lang.java.help)
  • Re: Drawing translucent masks
    ... I ommited the lines that create the JFrame instance. ... private static Image[] TileGfx; ... public void actionPerformed{ ... int h = getHeight; ...
    (comp.lang.java.help)
  • Help Menu - opens frame which does not go to front
    ... I'm using a JFrame to display help content in a JEditorPane. ... the help frame does not have focus nor is it at the ... public void menuSelected ...
    (comp.lang.java.gui)
  • JFrame bring to front and getting the focus
    ... windows application) the telephone lost the focus. ... JFrame in front. ... Timer timer; ... public void actionPerformed{ ...
    (comp.lang.java.gui)