-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
swing0.7
-
generic
-
generic
-
Verified
The following application demonstrates that in Swing 0.6, the background
color of JInternalFrame cannot be set. This feature does work with
Swing 0.5.1.
Start the application and press the "Show Internal Frame" button. Each
internal frame that is shown is expected to have a colored background.
With Swing 0.5.1, this does happen; with Swing 0.6 it does not.
/*=========================================================================*/
/*
* JInternalFrameColorBug.java
* Cannot set the background color of a JInternalFrame.
*
*/
import java.awt.Color;
import java.awt.BorderLayout;
import java.awt.event.*;
import java.awt.swing.*;
public class JInternalFrameColorBug extends JPanel {
JInternalFrame internalFrame;
int layer = 0;
int frameCount = 0;
JDesktopPane dpane = new JDesktopPane();
Color[] colors = {Color.blue, Color.green, Color.red, Color.yellow,
Color.magenta};
public static void main( String[] argv ) {
new JInternalFrameColorBug();
}
public JInternalFrameColorBug() {
JFrame frame = new JFrame("JInternalFrame Test");
JPanel controlPanel = new JPanel();
JButton showButton = new JButton("Show Internal Frame");
frame.setLayout(new BorderLayout());
frame.setBackground(Color.white);
dpane.setOpaque(true);
dpane.setBackground(Color.pink);
controlPanel.add(showButton);
frame.add(BorderLayout.NORTH, controlPanel);
frame.add(BorderLayout.CENTER, dpane);
showButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
String command = evt.getActionCommand();
if (command == "Show Internal Frame")
showInternalFrame();
}
});
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
public void windowClosed(WindowEvent e) {System.exit(0);}
});
frame.pack();
frame.setSize(500, 400);
frame.setVisible(true);
}
public void showInternalFrame() {
internalFrame = new JInternalFrame("JInternalFrame");
internalFrame.setBackground(colors[frameCount]);
frameCount++;
internalFrame.setBounds(20*frameCount, 20*frameCount, 150, 200);
if (frameCount > 4)
frameCount = 0;
dpane.add(internalFrame, new Integer(layer));
try {internalFrame.setSelected(true);} catch
(java.beans.PropertyVetoException e) {}
layer++;
}
}
/*=========================================================================*/
- relates to
-
JDK-4268949 JInternalFrame cannot do setBackground()
-
- Closed
-