Hello Members,

I have a JFrame, which creates a JDialog upon clicking. In the JDialog, I have a JCombobox. When I choose one of the options in the JCombobox, I should be able to change the background color of the JFrame randomly in an open ended loop. When I then choose some other option in the JComboBox, the background color in the JFrame should change to some other fixed (not open ended) combination.

Can this be done in a JFrame/JDialog without using a JPanel(which has paintComponent())?
If anyone can help me, I would be grateful. Any code fragments will be very helpful.

Thank you!!
sciprog1

JFrame has a paintComponent too. You can use this to paint whatever you want as the background for that JFrame. Check that everything inside the JFrame has setOpaque(false) if any controls are obscuring the background.

Hello again,

I will try that.

Thank you!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.