Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > SystemColor in Linux - what's wrong?

Reply
Thread Tools

SystemColor in Linux - what's wrong?

 
 
Alexandr Molochnikov
Guest
Posts: n/a
 
      07-30-2003
SystemColor.textHighlight is supposed to be the color of the "background of
selected items, such as in menus, comboboxes, and text" - quoted from
SystemColor API docs. And under Windows, it does what the manual says.

However, in Linux SystemColor.textHighlight is black (r=0,g=0,b=0). The menu
background, for comparison, is blueish (r=153,g=153,b=204).

Does anyone know why this happens? I attached a small program that
demonstrates the problem; if someone could run it under Linux and tell me if
my observations are correct, this will remove my setup from the list of
suspects.

I use Java 1.4.1_03 under Linux Red Hat 9.

On a related note, how do the UIDefaults map onto the SystemColor? E.g.
which property the value for SystemColor.textHighlight comes from?

Thank you for any clues.

Alex Molochnikov
Gestalt Corporation


Here is the demo program:

import java.awt.*;
import java.util.*;
import javax.swing.*;

public class Controller
{
private JFrame frame;
private Container contentPane;
private Font textFont;

public static void main(String args[])
{
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAn dFeelClassName()); }
catch (Exception exc) { System.out.println("Error loading L&F: " + exc); }
new Controller();
}

public Controller()
{
frame = new JFrame("Test");
textFont = new Font("SansSerif",Font.PLAIN,12);
frame.addNotify();
frame.pack();
contentPane = frame.getContentPane();
contentPane.setLayout(null);
frame.setSize(400, 265);
frame.validate();
createMenu();
createViews();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

public void createViews()
{
JLabel label1 = new JLabel("textHighlight");
label1.setFont(textFont);
label1.setBorder(BorderFactory.createEtchedBorder( ));
label1.setSize(label1.getPreferredSize());
label1.setBackground(SystemColor.textHighlight);
label1.setLocation(10, 10);
label1.setOpaque(true);
label1.setToolTipText("Background: SystemColor.textHighlight");
contentPane.add(label1);
JLabel caption = new JLabel("Background: SystemColor.textHighlight");
caption.setFont(textFont);
caption.setSize(caption.getPreferredSize());
caption.setLocation(150, 10);
contentPane.add(caption);

JLabel label2 = new JLabel("textHighlightText");
label2.setFont(textFont);
label2.setBorder(BorderFactory.createEtchedBorder( ));
label2.setSize(label2.getPreferredSize());
label2.setBackground(SystemColor.textHighlightText );
label2.setLocation(10, 40);
label2.setOpaque(true);
label2.setToolTipText("Background: SystemColor.textHighlightText");
contentPane.add(label2);
caption = new JLabel("Background: SystemColor.textHighlightText");
caption.setFont(textFont);
caption.setSize(caption.getPreferredSize());
caption.setLocation(150, 40);
contentPane.add(caption);

JLabel label3 = new JLabel("textText");
label3.setFont(textFont);
label3.setBorder(BorderFactory.createEtchedBorder( ));
label3.setSize(label3.getPreferredSize());
label3.setBackground(SystemColor.textText);
label3.setLocation(10, 70);
label3.setOpaque(true);
label3.setToolTipText("Background: SystemColor.textText");
contentPane.add(label3);
caption = new JLabel("Background: SystemColor.textText");
caption.setFont(textFont);
caption.setSize(caption.getPreferredSize());
caption.setLocation(150, 70);
contentPane.add(caption);

JLabel label4 = new JLabel("control");
label4.setFont(textFont);
label4.setBorder(BorderFactory.createEtchedBorder( ));
label4.setSize(label4.getPreferredSize());
label4.setBackground(SystemColor.control);
label4.setLocation(10, 100);
label4.setOpaque(true);
label4.setToolTipText("Background: SystemColor.control");
contentPane.add(label4);
caption = new JLabel("Background: SystemColor.control");
caption.setFont(textFont);
caption.setSize(caption.getPreferredSize());
caption.setLocation(150, 100);
contentPane.add(caption);

JLabel label5 = new JLabel("controlText");
label5.setFont(textFont);
label5.setBorder(BorderFactory.createEtchedBorder( ));
label5.setSize(label5.getPreferredSize());
label5.setBackground(SystemColor.controlText);
label5.setLocation(10, 130);
label5.setOpaque(true);
label5.setToolTipText("Background: SystemColor.controlText");
contentPane.add(label5);
caption = new JLabel("Background: SystemColor.controlText");
caption.setFont(textFont);
caption.setSize(caption.getPreferredSize());
caption.setLocation(150, 130);
contentPane.add(caption);

JLabel label6 = new JLabel("textInactiveText");
label6.setFont(textFont);
label6.setBorder(BorderFactory.createEtchedBorder( ));
label6.setSize(label6.getPreferredSize());
label6.setBackground(SystemColor.textInactiveText) ;
label6.setLocation(10, 160);
label6.setOpaque(true);
label6.setToolTipText("Background: SystemColor.textInactiveText");
contentPane.add(label6);
caption = new JLabel("Background: SystemColor.textInactiveText");
caption.setFont(textFont);
caption.setSize(caption.getPreferredSize());
caption.setLocation(150, 160);
contentPane.add(caption);

JLabel label7 = new JLabel("inactiveCaption");
label7.setFont(textFont);
label7.setBorder(BorderFactory.createEtchedBorder( ));
label7.setSize(label7.getPreferredSize());
label7.setBackground(SystemColor.inactiveCaption);
label7.setLocation(10, 190);
label7.setOpaque(true);
label7.setToolTipText("Background: SystemColor.inactiveCaption");
contentPane.add(label7);
caption = new JLabel("Background: SystemColor.inactiveCaption");
caption.setFont(textFont);
caption.setSize(caption.getPreferredSize());
caption.setLocation(150, 190);
contentPane.add(caption);
}

protected void createMenu()
{
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
/*
** Create submenu
*/
JMenu menu = new JMenu("Test");
menuBar.add(menu);
JMenuItem item1 = new JMenuItem("Item 1");
menu.add(item1);
JMenuItem item2 = new JMenuItem("Item 2");
menu.add(item2);
JMenuItem item3 = new JMenuItem("Item 3");
menu.add(item3);
}
}


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Is Netscape Leaving Firefox Behind on GNU/Linux? THE LINUX PROPAGANDA MACHINE CONTINUES. FIREFOX IGNORING LINUX............. traci.manicotti@gmail.com Computer Support 2 10-20-2007 02:12 PM
Linux... yeah linux.. Linux Have a nice cup of pee NZ Computing 19 04-17-2006 10:16 AM
Importing TB mail from linux in linux Nick de Graeve Firefox 0 10-04-2004 10:49 AM
SystemColor 'Control' to 'buttonface' Ade ASP .Net 2 04-20-2004 07:59 PM
Linux-Cisco-ADSL-Cisco-Linux Connection hangs.... Adrian de los Santos Cisco 6 07-22-2003 04:44 AM



Advertisments