-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.6, 1.2.0
-
generic, x86
-
generic, windows_95
Name: krT82822 Date: 11/08/98
This JComboBox bug occurs with both JDK v1.2b4.1 *and* JDK v1.1.6
w/Swing v1.1b2.
I'm using WinNT v4.0, SP3.
I've included a minimal sample program to illustrate the buggy behavior.
The problem has to do with setting the cursor for a JComboBox's "edit
field" when setEditable(true) has been called on the JComboBox. The
problem is that when the LaF changes, the cursor reverts back to the
standard arrow.
Not that if I replace the JComboBox with a JTextField, this problem does
not occur.
Follow these steps:
1. Run the attached program.
2. Move the cursor over the edit field of the JComboBox. Note the
shape of the cursor.
3. Change the LaF to any of the three available LaFs.
4. Move the cursor over the edit field of the JComboBox. Note the
shape of the cursor -- it is an arrow!
import com.sun.java.swing.*;
import java.awt.*;
import java.awt.event.*;
class Tester9
{
private static final JComboBox comboBox = new JComboBox();
public static void main(String[] args)
{
final JFrame f = new JFrame();
// WindowListener for closing progam.
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent evt)
{
evt.getWindow().dispose();
System.exit(0);
}
});
f.getContentPane().add(comboBox, BorderLayout.NORTH);
comboBox.setEditable(true);
Component editorComponent = comboBox.getEditor().getEditorComponent();
editorComponent.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
//--------------------
// The remaining code simply allows for a change in the LaF....
//--------------------
JPanel LaFPanel = new JPanel();
final JButton windowsLaF = new JButton("Windows"),
motifLaF = new JButton("Motif"),
metalLaF = new JButton("Metal");
LaFPanel.add(windowsLaF);
LaFPanel.add(motifLaF);
LaFPanel.add(metalLaF);
ActionListener LaFListener = new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
Object src = evt.getSource();
try
{
if(src == windowsLaF)
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
else if(src == motifLaF)
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
else
UIManager.setLookAndFeel("com.sun.java.swing.plaf.metal.MetalLookAndFeel");
SwingUtilities.updateComponentTreeUI(f);
}
catch(Exception e)
{
System.err.println("*** ERROR IN CHANGING LAF: " + e);
}
}
};
windowsLaF.addActionListener(LaFListener);
motifLaF.addActionListener(LaFListener);
metalLaF.addActionListener(LaFListener);
f.getContentPane().add(LaFPanel, BorderLayout.SOUTH);
f.setBounds(50, 50, 300, 300);
f.setVisible(true);
}
}
(Review ID: 38139)
======================================================================
- duplicates
-
JDK-4144505 Compound components don't behave properly
-
- Closed
-