Name: vi73552 Date: 05/27/99
Searched the JDC for the bugs elicited by the example below and could not find them. Happens under jdk 1.2 using both Windows L&F and Metal L&F... Did not try under latest Swing beta.
Running the example below:
1) Press MakeFrame
2) Note that JIF is closable, resizable, minimizable
3) Click each of the closable, resizable, minimizable JButtons in the JIF (turning these attribs off). Note that the respective JIF titlebar action icons disappear as expected. (Note: the JIF also grows a pixel with each button press, I'm using setBounds with new values just to force the JIF to repaint after each button press).
4) MINOR BUG: Under Windows L&F, press the titlebar (coffee cup) icon... Minimize, Maximize , Close choices are NOT grayed out as they should be (but they do not function, which is correct). If you re-enable Iconifiable then iconify & de-iconify the JIF, these choices show up as properly grayed.
5) THE BUGS: Now with the restored JIF, re-enable Closable & Maximizable (using the JButtons, set these to true)... Note these bugs:
a) The biggie: The respective JIF titlebar action icons (the closable X and Maximizable box) DO NOT REAPPEAR as they should.
b) Under Windows L&F, press the titlebar (coffee cup)
icon... Maximize , Close choices are STILL grayed out (not usable), and they should now be available. Iconify & de-iconify the JIF & these are properly show.
Seems like some property changes are not be fired or implemented within the title bar UIs.
The real problem is the fact that the Minimize, Maximize & Close icons cannot be made to reappear in the titlebar once they are disabled.
Sample code:
// Demonstrates JInternalFrame problems with dynamic attributes & titlepane icons
import javax.swing.*;
import javax.swing.event.*;
import java.beans.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import com.sun.java.swing.plaf.windows.*; // Needed for Windows L&F
public class JFrame1 extends JFrame {
static int frameCount = 1;
public JFrame1() {
super("Internal Frames Demo");
try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }
catch (Exception exc) { System.out.println("Error loading L&F: " + exc); }
final JDesktopPane desktop = new JDesktopPane();
getContentPane().add(desktop,BorderLayout.CENTER);
JInternalFrame makeFrame = new JInternalFrame("Frame Maker",true,false,true,true);
JButton button = new JButton("Make Frame");
button.addActionListener(new ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent event) {
final JInternalFrame internal =
new JInternalFrame("Frame #" + frameCount,true,true,true,true);
internal.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
Container contentPane = internal.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane,BoxLayout.Y_AXIS));
// Add buttons to flip attributes
final JButton Closable = new JButton("Closable: true");
Closable.addActionListener(new ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent event) {
// Flip closable attribute
internal.setClosable(!internal.isClosable());
Closable.setText("Closable: "+internal.isClosable());
// Resize JIF just to get the Title Pane to repaint
Rectangle r = internal.getBounds();
r.grow(1, 1);
internal.setBounds(r);
}
});
contentPane.add(Closable);
final JButton Iconifiable = new JButton("Iconifiable: true");
Iconifiable.addActionListener(new ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent event) {
// Flip Iconifiable attribute
internal.setIconifiable(!internal.isIconifiable());
Iconifiable.setText("Iconifiable: "+internal.isIconifiable());
// Resize JIF just to get the Title Pane to repaint
Rectangle r = internal.getBounds();
r.grow(1, 1);
internal.setBounds(r);
}
});
contentPane.add(Iconifiable);
final JButton Maximizable = new JButton("Maximizable: true");
Maximizable.addActionListener(new ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent event) {
// Flip Maximizable attribute
internal.setMaximizable(!internal.isMaximizable());
Maximizable.setText("Maximizable: "+internal.isMaximizable());
// Resize JIF just to get the Title Pane to repaint
Rectangle r = internal.getBounds();
r.grow(1, 1);
internal.setBounds(r);
}
});
contentPane.add(Maximizable);
internal.setBounds(frameCount*25,frameCount*25,200,150);
desktop.add(internal);
frameCount++;
if (frameCount > 10) frameCount=0;
}
});
makeFrame.getContentPane().add(button,BorderLayout.CENTER);
makeFrame.setBounds(200,0,200,75);
desktop.add(makeFrame);
setSize(500,500);
this.addWindowListener( new WindowAdapter() {
public void windowClosing(WindowEvent event) {
setVisible(false);
dispose();
System.exit(0);
}
});
show();
}
public static void main(String args[]) {
new JFrame1();
}
}
(Review ID: 83516)
======================================================================