-
Bug
-
Resolution: Won't Fix
-
P4
-
5.0
-
x86
-
linux_sun
###@###.### 2004-01-22
J2SE Version (please include all output from java -version flag):
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32, mixed mode)
Does this problem occur on J2SE 1.3 or 1.4.x? Yes / No (pick one)
No
Operating System Configuration Information (be specific):
(Linux) Sun Java Desktop System, 2003
Hardware Configuration Information (be specific):
Platform configuration:
CPU: Intel 32bit Single Processor
Processor Speed: 1893 MHz
Bug Description:
The combobox looks strange, borders are not drawn with the Sun Java
Destop' default look and feel
Steps to Reproduce (be specific):
- Compile and execute the source code attached.
==========================================================
/**
* JComboBoxJ150.java
*/
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
/**
* Class: JComboBoxLinuxJ150
*/
public class JComboBoxLinuxJ150 extends JFrame
{
/**
* Constructor: JComboBoxLinuxJ150
* @return instance of JComboBoxLinuxJ150
*/
public JComboBoxLinuxJ150()
{
super();
setBounds(100,100,400,400);
JComboBox comboBox = new JComboBox();
comboBox.setRenderer(new ComboBoxRenderer());
comboBox.addItem("Background");
comboBox.addItem("Foreground");
JPanel panel = new JPanel();
panel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER,5,5));
panel.add(comboBox);
getContentPane().add(panel,java.awt.BorderLayout.CENTER);
} /* End of Constructor: JComboBoxLinuxJ150 */
/**
* Method: generalHandleException <br>
* @param java.lang.Throwable exception
* @return void
*/
protected void generalHandleException(java.lang.Throwable exc)
{
/* Remove this comment and specialize processing here. */
exc.printStackTrace(System.err);
} /* End of Method: generalHandleException */
/**
* Method: main <br>
* Note: Called only if we're an application. <br>
* @param java.lang.String[] args the command line arguments
* @return void
*/
public static void main(java.lang.String[] args)
{
try
{
/* Set native look and feel */
javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
/* Creates new MainObject */
JComboBoxLinuxJ150 self = new JComboBoxLinuxJ150();
/* Remove this comment and specialize processing here. */
self.show();
} /* End try */
catch (java.lang.Throwable exc)
{
/* Remove this comment and specialize processing here. */
exc.printStackTrace(System.err);
} /* End catch */
} /* End of Method: main */
class ComboBoxRenderer extends DefaultListCellRenderer
{
ComboBoxRenderer()
{
}
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus)
{
super.getListCellRendererComponent(list, value, index, isSelected,
cellHasFocus);
setText("" + value);
setIcon(new ColorIcon());
return this;
}
class ColorIcon implements Icon
{
ColorIcon()
{
}
public void paintIcon(Component c, Graphics g, int x, int y)
{
String colorID = ((JLabel)c).getText();
Color color = Color.blue;
g.setColor(color);
int width = getIconWidth();
int height = getIconHeight();
g.fillRect(x, y, width, height);
g.setColor(Color.lightGray);
g.drawRect(x, y, width - 1, height - 1);
g.draw3DRect(x+1, y+1, width - 3, height - 3, true);
}
public int getIconWidth()
{
return 24;
}
public int getIconHeight()
{
return 12;
}
}
}
} /* End of Class: JComboBoxLinuxJ150 */