Hi to all ! i am a newbie and i don't know a lot of things..i am making a programm..i have make JMenuBar(i am working with netbeans) and i have add some JmenuItems...i want to know how can add a JChooserColor to an item so the user can choose the color he wants for the background!!
I make an example-----> File | Edit | Options
-------------------------
-----------------------------------> ColorChoose--->?????
(ColorChoose is an item of Options )
where the ??? i want to put the JfileChooser class so the user can see the colors..i mean when he puts the mouse over the ColorChoose then opens a window to the right side with the background colors!
or i have to make another class and when he goes to ColorChoose opens the new interfacce and connect them so he can select the color?
i am so sorry about my english!! i am from greece so i don't speak very well english!! i hope that i have made to understand what i want!
your Objective is to bring out a color Palette when u click on a menu item, right!!!
This can be done in two steps :
1. Add Actionlistenerto the required MenuItem.
2.In the actionPerformed method, write the following code
Code:
Color newColor = JColorChooser.showDialog(
this, //refers the parent frame
"Choose Background Color", //Title of ColorChooser Dialog
Color.blue //Initial color selected in Chooser
);
the above code pops up the color chooser dialog and the selected color is in the newColor variable.
well i i have try everything you said me and it is working..thank you so much!!
but now i have another problem...when i choose a color this doesn't set a color of background...what i have to do now? remains the default color !! of tha programm... i use (netbeans)
the code now is like this :
Color newColor = JColorChooser.showDialog(
this, //refers the parent frame
"Choose Background Color", //Title of ColorChooser Dialog
Color.blue //Initial color selected in Chooser
);
}
i was thinking to put something like this: setBackground but i have tried it and doesn't works..maybe i am not setting well the command !! can you help plz?
and now another thing !!! if i make the JmenuItem25 like a Jmenu25 under the Jmenu Options
Options
jmenu25>....
and i want to open a window parent(not another window but opens in the right of jmenu25 with a color panel(or opens always JcolorChooser) it is difficult to make this?i have try it but nothing...
thank you for eveything..so kind!!! and i am so sorry if i am tiring!!!
hi again!! well i have find one way to all this...i have created another class with the name Colori
and i have created into this the JcolorChooserDialog and 3 buttons!!!
then i went to the main class ( has the name HomeEstimo2) and i have
put this : Colori = new Estimo2.Colori();
and then under the JMenu3 ( has the name Colore Sfondo=in english means Color Backgorund) i have done this
i upload the image to see how works!! now my problem is how when i go to the button OK , i dont'know what command line i have to put for il background!! because the button "OK" is in the JPanel !!
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.