import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.ToolTipManager; /* * TestTooltipFronting.java * * Created on 15. listopad 2003, 12:49 */ /** Tests a jdk bug in which showing a tooltip on a frame behind one * that is fronted and has focus causes the non-focused one to be fronted. * * @author Tim Boudreau */ public class TestTooltipFronting extends javax.swing.JFrame { /** Creates new form TestTooltipFronting */ public TestTooltipFronting() { initComponents(); final JFrame jf = new JFrame(); jf.getContentPane().add(new JButton("Hello world")); jf.setSize(200,200); jf.setLocation(getLocation().x + getWidth()-20, getLocation().y); jf.show(); SwingUtilities.invokeLater(new Runnable() { public void run() { jf.toFront(); jf.requestFocus(); } }); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents jButton1 = new javax.swing.JButton(); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } }); jButton1.setText("Show another window"); jButton1.setToolTipText("This is a very long tooltip that will probably need a heavyweight window to be displayed"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); getContentPane().add(jButton1, java.awt.BorderLayout.CENTER); pack(); }//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed }//GEN-LAST:event_jButton1ActionPerformed /** Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm System.exit(0); }//GEN-LAST:event_exitForm /** * @param args the command line arguments */ public static void main(String args[]) { new TestTooltipFronting().show(); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; // End of variables declaration//GEN-END:variables }