Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

color of JMenuBar

0 views
Skip to first unread message

Dong-Yueh Liu

unread,
Nov 27, 1997, 3:00:00 AM11/27/97
to

I am the first tme to use JMenuBar of swing 0.5.1 in Windows 95.
I create a JMenuBar and a JTextArea and attach them to a JFrame.
The color of JMenuBar is white. I want to change its color to
light gray. JMenuBar doest not have setColor() method, but I find
that if the frame's background is set to light gray, then the color
of JMenuBar will be light gray. But if another window is overlapped
with the menu bar, then the overlapped area of menu bar will
become white after the window is move out. The following is my
source code:

import java.awt.*;
import com.sun.java.swing.*;

public class Test
{
public static void main(String argv[])
{
JFrame frame = new JFrame();
frame.setSize(300, 300);
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");
menuBar.add(menu);
frame.setJMenuBar(menuBar);
frame.setBackground(Color.lightGray);
frame.getContentPane().add(new JTextArea());
frame.show();
}
}

If I does not add a JTextArea to frame, then the color of JMenuBar
will always be light gray. Is the above problem a bug of swing? Or,
Is there other correct method to set color of JMenuBar?

Dong-Yueh Liu
email: dy...@ms1.hinet.net

0 new messages