I'm using Design mode on NetBeans in order to create multiple JFrames. I'm currently trying to make a JDialog but I don't know what kind of variable I have to give it.
Because Design-mode made the code for me, I can't just edit it in order to let it work. It was already quite the hassle to get a doubleClick event in the generated code of the masterTable.
this is the code I'm trying to run. The public void DoubleClick is where an new instance for the Jdialog is made.
masterTable.addMouseListener( new ClickListener() {
public void singleClick (MouseEvent e) {
System.out.println("single");
JTable target = (JTable) e.getSource();
int row = target.getSelectedRow();
int col = 0;
Object data = (Object) target.getValueAt(row, col);
String id = data.toString();
System.out.println("Er is geklikt op de rij met ID nummer: " + data);
try {
GetSelectedData(id);
} catch (SQLException ex) {
Logger.getLogger(InzienDienstgegevensForm.class.getName()).log(Level.SEVERE, null, ex);
}
try {
DisplayPaymentInfo(id);
} catch (SQLException ex) {
Logger.getLogger(InzienDienstgegevensForm.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void doubleClick (MouseEvent e){
System.out.println("double");
JTable target = (JTable) e.getSource();
int row = target.getSelectedRow();
int col = 0;
Object data = (Object) target.getValueAt(row, col);
String id = data.toString();
System.out.println("Er is geklikt op de rij met ID nummer: " + data);
InzienSelectieDialoog dialoog = new InzienSelectieDialoog(this, true);
}
});
My JDIALOG has the following constructor and runnable in public void Run():
public InzienSelectieDialoog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
public static void main(String args[]) {
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
InzienSelectieDialoog dialog = new InzienSelectieDialoog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
There are two things I want to adjust in order for me to get this JDialog working like I want it to:
- I want to make it visible with the right attributes. So I need to put something at the (...,...) constructor... but I have no clue what I have to put there.
- I want to give a String id (which contains the ID what the Jdialog needs to print the right values)
Any suggestion are very welcome!
If I need to provide more code or information what I want to do, please ask me and I'll do so accordingly.
EDIT: the masterTable.addMouseListener is inside the public void initComponents(). The this in the new JDialoog (InzienGegevensSelectie) gives the following error:
- incompatible types < anonymous ClickListener > cannot be converted to Frame