A Java Swing Question concerning File Menus

I created a file menu applet in Java, Swing 1.2 and for some reason it has the default purple background color on the Menu Item. How can I change this ugly default color? I tried everything, setting the background and opique function color to something else and It still showed up.
7of9121098Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sen_kumConnect With a Mentor Commented:
Try to set the background of JMenuItem

import javax.swing.* ;
import java.awt.* ;
public class Test
{
    public static void main( String args[] )
    {
        JFrame f = new JFrame( "Test" ) ;
        JMenu m = new JMenu( ) ;
        JMenuBar mb = new JMenuBar( ) ;
        JMenuItem mi = new JMenuItem( "File" ) ;
        mi.setBackground( Color.red ) ;
        mb.add( mi ) ;
        mb.add( new JMenuItem( "Edit" ) ) ;
        f.getContentPane().add( mb ) ;
        f.setSize( 100, 100 ) ;
        f.setVisible( true ) ;
    }
}
0
All Courses

From novice to tech pro — start learning today.