Salve ragazzi..avrei la necessità di aprire una JOptionPane al doppio clic sulle righe di una JTable...
codice:
tabellaparametri = new JTable(righe,colonne){
public boolean isCellEditable(int riga, int colonna) {
return false;
}
};
tabellaparametri.setName("tabellaparametri");
tabellaparametri.setVisible(true);
tabellaparametri.setAlignmentY(CENTER_ALIGNMENT);
tabellaparametri.setAlignmentX(CENTER_ALIGNMENT);
tabellaparametri.getColumn("PADRE").setPreferredWidth(5);
tabellaparametri.getColumn("FIGLIO").setPreferredWidth(70);
tabellaparametri.getColumn("VALORE").setPreferredWidth(100);
tabellaparametri.getColumn("IMPOSTA").setPreferredWidth(10);
tabellaparametri.setPreferredScrollableViewportSize(new Dimension((screenSize.width /2)-150, 50));
tabellaparametri.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2){
System.out.println("adasdas");
JInternalFrame frame= new JInternalFrame();
ImageIcon icon = new ImageIcon("M.gif");
Object[] possibilities = {"ham", "spam", "yam"};
String s = (String)JOptionPane.showInputDialog(
frame,
"Complete the sentence:\n"
+ "\"Green eggs and...\"",
"Customized Dialog",
JOptionPane.PLAIN_MESSAGE,
icon,
possibilities,
"ham");
//If a string was returned, say so.
if ((s != null) && (s.length() > 0)) {
System.out.println("Green eggs and... " + s + "!");
return;
}
//If you're here, the return value was null/empty.
System.out.println("Come on, finish the sentence!");
} else {
System.out.println("Come on, finish the sentence!");
}
}
});
tabellaparametri.setVisible(true);
Il problema è che sembra non entrare proprio nel metodo visto che non mi stampa neanche la riga col systemout...
io l'unico dubbio che ho è sul frame..lo devo creare così vero?