Problema con codigo en java
por favor ayúdenme xD
el problema es que yo utilizaba un código en las versiones de java netbeans anteriores y en la nueva versión el 6.8 no se puede no aparecen los eventos del mouse que yo antes utilizaba
if(evt.getButton()==MouseEvent.BUTTON3)
{
menu.show(this,evt.getX(),evt.getY());
}
quisiera saber que eventos puedo utilizar para cubrir el evt.getButton y el show
les agradezco su respuesta
- Inicie sesión o regístrese para enviar comentarios
hola deberias postear el
hola deberias postear el codigo completo y el error que te sale para darnos una idea mas clara de lo que sucede? con que version de java funciona y con cual estas trabajando ahorita?
problema con codigo en netbeans 6.8
el problema es con netbeans 6.8 pq en las verciones anteriores este codigo sirve
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* Ventana.java
*
* Created on 2/02/2010, 11:20:10 AM
*/
package eventmouse;
import java.awt.event.MouseEvent;
/**
*
* @author Crash
*/
public class Ventana extends javax.swing.JFrame {
/** Creates new form Ventana */
public Ventana() {
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")
//
private void initComponents() {
menu = new javax.swing.JPopupMenu();
hola = new javax.swing.JMenuItem();
caja = new javax.swing.JTextField();
hola.setText("jMenuItem1");
hola.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
holaActionPerformed(evt);
}
});
menu.add(hola);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
caja.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cajaActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(caja, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(caja, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
);
pack();
}//
private void cajaActionPerformed(java.awt.event.ActionEvent evt) {
if(evt.getButton()==MouseEvent.BUTTON3)
{
menu.show(this,evt.getX(),evt.getY());
}
}
private void holaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Ventana().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField caja;
private javax.swing.JMenuItem hola;
private javax.swing.JPopupMenu menu;
// End of variables declaration
}
/* * To change this
me refiero a las versiones de java no de netbeas y pon el error que te sale al compilar tu proyecto..