Domanda

Sto cercando di costruire un particolare JMenu. Voglio un JMenuItem con funzionalità JMenu, vale a dire quando si clicca la voce si dovrebbe fare qualcosa (come aprire una finestra di dialogo). Ma la JMenuItem dovrebbe contenere anche un pulsante (o altro componente) che, quando si fa clic, dovrebbe aprire un popup con un paio di opzioni.

Quindi, fino ad ora ho qualcosa di simile a questo:

desiderata UI

Questo è quello che ho davanti fare clic sulla freccia.

Il mio problema è che, quando si preme il pulsante (freccia), il sotto-menu viene effettivamente aperto, ma la voce di menu che contiene pulsanti che si chiude perché non è più attiva.

rotto UI

Questo è il risultato dopo aver fatto clic sul pulsante freccia.

C'è un modo per gestire questo? O un modo migliore per avere questo comportamento?

È stato utile?

Soluzione 4

Couldn't actually find a solution for this particular problem. As a workaround, I used just a simple button that toggle between the option 1 and option 2, instead of having the button (arrow) that open a new popup. Thanks a lot for your help.

Altri suggerimenti

We can guide you if we know exactly what you are trying to implement. If you just want to select an option, you can implement that in better way with the JRadioButtonMenuItem,so you dont really need to implement a button and then select an option.But it depends on what you really want.

That's not what a menu is intended for. Use a ribbon instead, and these things will be easy and natural.

Why not just use simple nested JMenuItem instead? Something like this (First screen from the top).

On the other hand you can benefit from a similar solution described here.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top