ragazzi ho fatto un codice del genere per captare il mouseDown sulla mia finestra:
codice:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* NumberAdditionUI.java
*
* Created on 29-gen-2009, 16.39.39
*/
package my.numeraddition;
import javax.swing.*;
import java.awt.event.MouseEvent;
/**
*
* @author corradocacciapuoti
*/
public class NumberAdditionUI extends javax.swing.JFrame {
/** Creates new form NumberAdditionUI */
public NumberAdditionUI() {
initComponents();
}
/** 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jTabbedPane1 = new javax.swing.JTabbedPane();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("Add");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(141, 141, 141)
.add(jButton1)
.addContainerGap(151, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(102, 102, 102)
.add(jButton1)
.addContainerGap(130, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
public void mouseDown(MouseEvent e) {
JOptionPane.showMessageDialog(null, "Mouse Down");
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NumberAdditionUI().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JTabbedPane jTabbedPane1;
// End of variables declaration
}
ma quando faccio il click sulla finestra non accade nulla