Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2009
    Messaggi
    142

    Popup non appare in windows

    Ciao,

    ho scritto un codice per mostrare un menu a popup su una JTable. Scritto e testato sotto Ubuntu funziona a dovere, provato su un altro pc con Windows il popup non appare.

    Copio il codice, noterete che è abbastanza simile a quello di questa pagina http://docs.oracle.com/javase/tutori...enu.html#popup
    Potete dirmi dove sbaglio?

    Grazie, ciao

    codice:
    table.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent e) {
                    boolean opened = false;
                    if (e.getClickCount() == 2) {
                        // apre un file con l'oggetto Desktop
                    }
                }
    
                public void mousePressed(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        JTable source = (JTable) e.getSource();
                        rowP = source.rowAtPoint(e.getPoint());
                        colP = source.columnAtPoint(e.getPoint());
                        //System.out.println(rowP + " " + colP);
    
                        if (!source.isRowSelected(rowP))
                            source.changeSelection(rowP, colP, false, false);
                        if (rowP >= 0 && rowP < table.getRowCount())
                            popup.show(e.getComponent(), e.getX(), e.getY());
                    }
                }
    
                public void mouseReleased(MouseEvent e) {
                    // TODO
                }
    
            });
    <esistono cose che non esistono>

  2. #2
    Come si evince dalla documentazione http://docs.oracle.com/javase/tutori...enu.html#popup
    codice:
    The exact gesture that should bring up a popup menu varies 
    by look and feel. In Microsoft Windows, the user by convention brings up 
    a popup menu by releasing the right mouse button while the cursor is over 
    a component that is popup-enabled. In the Java look and feel, the customary 
    trigger is either pressing the right mouse button (for a popup that goes away 
    when the button is released) or clicking it (for a popup that stays up).
    Quindi devi gestire meglio tutti gli eventi del mouse.

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.