-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
beta2
-
x86
-
windows_95, windows_nt
Name: ssT124754 Date: 02/06/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
When setting a TitledBorder as Border for a JComboBox in Windows Look and Feel
in an GridBagLayout the JComboBox disappears completely.
In Metal Look and Feel and GridBagLayout the JComboBox grows to double size.
Sample showing Windows Look And Feel as default:
(run with javax.swing.plaf.metal.MetalLookAndFeel as parameter to see Metal).
Components are arranged in getJFrameContentPane and Borders are set in
initBorder().
package com.retail_sc.javasoft.windowscomboboxui;
import javax.swing.*;
import com.sun.java.swing.plaf.windows.*;
/**
* Sample showing the small JComboBox in Jdk 1.3
* Switch to another Look And Feel using the class Name of it as first parameter
*
* Creation date: (04.01.01 09:57:35)
* @author: Stefan Cordes
*/
public class WindowsComboBoxUITest extends JFrame {
private JComboBox ivjJComboBox1 = null;
private JPanel ivjJFrameContentPane = null;
private JTextField ivjJTextField1 = null;
/**
* WindowsComboBoxUITest constructor comment.
*/
public WindowsComboBoxUITest() {
super();
initialize();
}
/**
* WindowsComboBoxUITest constructor comment.
* @param title java.lang.String
*/
public WindowsComboBoxUITest(String title) {
super(title);
}
/**
* Return the JComboBox1 property value.
* @return javax.swing.JComboBox
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JComboBox getJComboBox1() {
if (ivjJComboBox1 == null) {
try {
ivjJComboBox1 = new javax.swing.JComboBox();
ivjJComboBox1.setName("JComboBox1");
ivjJComboBox1.setEditable(true);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjJComboBox1;
}
/**
* Return the JFrameContentPane property value.
* @return javax.swing.JPanel
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JPanel getJFrameContentPane() {
if (ivjJFrameContentPane == null) {
try {
ivjJFrameContentPane = new javax.swing.JPanel();
ivjJFrameContentPane.setName("JFrameContentPane");
ivjJFrameContentPane.setLayout(new java.awt.GridBagLayout());
ivjJFrameContentPane.setBackground(java.awt.SystemColor.controlHighlight);
java.awt.GridBagConstraints constraintsJTextField1 = new java.awt.GridBagConstraints();
constraintsJTextField1.gridx = 1;
constraintsJTextField1.gridy = 0;
constraintsJTextField1.fill = java.awt.GridBagConstraints.HORIZONTAL;
constraintsJTextField1.weightx = 1.0;
constraintsJTextField1.insets = new java.awt.Insets(4,4, 4, 4);
getJFrameContentPane().add(getJTextField1(),
constraintsJTextField1);
java.awt.GridBagConstraints constraintsJComboBox1 = new java.awt.GridBagConstraints();
constraintsJComboBox1.gridx = 0;
constraintsJComboBox1.gridy = 0;
constraintsJComboBox1.fill = java.awt.GridBagConstraints.HORIZONTAL;
constraintsJComboBox1.weightx = 1.0;
constraintsJComboBox1.insets = new java.awt.Insets(4,4, 4, 4);
getJFrameContentPane().add(getJComboBox1(), constraintsJComboBox1);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjJFrameContentPane;
}
/**
* Return the JTextField1 property value.
* @return javax.swing.JTextField
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JTextField getJTextField1() {
if (ivjJTextField1 == null) {
try {
ivjJTextField1 = new javax.swing.JTextField();
ivjJTextField1.setName("JTextField1");
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjJTextField1;
}
/**
* Called whenever the part throws an exception.
* @param exception java.lang.Throwable
*/
private void handleException(java.lang.Throwable exception) {
/* Uncomment the following lines to print uncaught exceptions to stdout
*/
System.out.println("--------- UNCAUGHT EXCEPTION ---------");
exception.printStackTrace(System.out);
}
/**
* Set the Border around the components.
*
* Creation date: (04.01.01 10:00:37)
*/
protected void initBorders() {
getJComboBox1().setBorder(new javax.swing.border.TitledBorder("ComboBoxTitle"));
getJTextField1().setBorder(new javax.swing.border.TitledBorder("TextField Title"));
}
/**
* Initialize the class.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initialize() {
try {
// user code begin {1}
// user code end
setName("WindowsComboBoxUITest");
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setSize(426, 240);
setContentPane(getJFrameContentPane());
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
// user code begin {2}
initBorders();
initModel();
// user code end
}
/**
* Insert the method's description here.
* Creation date: (04.01.01 10:00:37)
*/
protected void initModel() {
DefaultComboBoxModel tempModel;
tempModel = new DefaultComboBoxModel();
tempModel.addElement("TEST");
getJComboBox1().setModel(tempModel);
}
/**
* main entrypoint - starts the part when it is run as an application
* @param args java.lang.String[]
*/
public static void main(java.lang.String[] args) {
try {
// Set the Look and Feel to Windows
if ((args != null) && (args.length == 1)) {
UIManager.setLookAndFeel(args[0]);
} else {
UIManager.setLookAndFeel(new WindowsLookAndFeel());
}
//
WindowsComboBoxUITest aWindowsComboBoxUITest;
aWindowsComboBoxUITest = new WindowsComboBoxUITest();
aWindowsComboBoxUITest.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e)
{
System.exit(0);
};
});
aWindowsComboBoxUITest.setVisible(true);
} catch (Throwable exception) {
System.err.println("Exception occurred in main() of javax.swing.JFrame");
exception.printStackTrace(System.out);
}
}
}
(Review ID: 115284)
======================================================================