Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Evento su JTable

  1. #1

    Evento su JTable

    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?
    [ SimplyMepis 8 ]Copyleft
    www.mepisitalia.org IL SITO ITALIANO UFFICIALE DI MEPIS
    www.salentomovida.it LA MOVIDA DEL SALENTO HA UN NUOVO PUNTO D'INCONTRO SUL WEB
    [ SUD SOUND SYSTEM MINA FUECU INTRA ALLU SALENTU ]

  2. #2
    Utente di HTML.it L'avatar di andbin
    Registrato dal
    Jan 2006
    residenza
    Italy
    Messaggi
    18,284

    Re: Evento su JTable

    Originariamente inviato da alex86
    io l'unico dubbio che ho è sul frame..lo devo creare così vero?
    Non vedo perché tu debba creare un JInternalFrame solo per "darlo in pasto" alla JOptionPane come parent component.

    La tua applicazione ha di certo una finestra principale (JFrame, JDialog o altro ... non so), passa la istanza di tale finestra.
    Andrea, andbin.devSenior Java developerSCJP 5 (91%) • SCWCD 5 (94%)
    java.util.function Interfaces Cheat SheetJava Versions Cheat Sheet

  3. #3
    ok risolto...
    piccolo altro problema..se noti vi è una combobox con i valori di possibilità..
    la visualizzazione mi viene troncata all'altezza della JOptionPane .. mi mostra solo i primi tre parametri e i restanti me li nasconde
    [ SimplyMepis 8 ]Copyleft
    www.mepisitalia.org IL SITO ITALIANO UFFICIALE DI MEPIS
    www.salentomovida.it LA MOVIDA DEL SALENTO HA UN NUOVO PUNTO D'INCONTRO SUL WEB
    [ SUD SOUND SYSTEM MINA FUECU INTRA ALLU SALENTU ]

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.