Hi. I am making JMenuBars in my way but i start to understand, that my way ir crap! :D
So I want to know, if there is a way, how to know, which item from menu is set.
For example - i have menu with actors - i choose one, press OK and it opens new window with picture of chosen actor.
so i have to set action listener to JRadioButtonMenuItem, that gives an argument to JButtons actionlistener, so program knows, which one to show.
But how to give as an argument this exact JRadioButtonMenuItem (actually i don't pass this item, i'll pass its ID - number), that will be set!?
For now i made JTextArea in the window with my menu. And action listeners to JRadioButtonMenuItem sets text (writes it's ID) to JTextArea. and when i press OK, i watch to this JtextArea and check for its text - depending on the text, different picture will be shown).
I don't need exact code (because that will stop my learning process), i just want an idea. in this i really can't think of nothing better.
Thanks. :)

Edited by diafol: Moved to Java

5 Years
Discussion Span
Last Post by migelitto

That code won't show you anything. Simply - i want to know, how to "tell program", which RadioButton of JMenu is set.


and what do you mean: "which RadioButton of JMenu"? a JMenu uses JMenuItems, not RadioButtons

it also uses JRadioButtonMenuItems - i just used short name of it!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.