-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.4.0
-
generic
-
generic
Name: jk109818 Date: 01/04/2002
java version "1.4.0-beta3"
Java (TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)
Compile the attached code with "javac BenRite.java". Run it with "java BenRite".
Please supply your own .gif image, preferrable 64x64 pixels. This web-based bug
report *discourages* attaching binaries :^). This .gif image should be named
"BRAbout.gif".
What will happen: Start the program. Your "BRAbout.gif" image will partially
obscure the "About" button. Now click the "About" button. The "About" page
displays, and the image moves to its proper position. Press the "Done" button.
The menu page redisplays. This time the image behaves itself and confines
itself to its "About" JPanel.
----- BEGINNING OF ATTACHED CODE -----
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class BenRite extends JFrame {
private Container thisContentPane;
private CardLayout cdlBenRite = new CardLayout();
JButton btnAbout;
JButton btnReturn;
JButton btnDone;
public static void main (String[] args) {
BenRite f = new BenRite();
f.pack();
f.setVisible(true);
}
public BenRite() {
super("BenRite 2000");
// Build the Utility Menu.
JPanel utilityMenu = new JPanel();
BorderLayout bdlUtilityMenu = new BorderLayout();
JLabel lblTitle = new JLabel();
btnAbout = new JButton();
btnReturn = new JButton();
lblTitle.setFont(new Font("Helvetica", Font.BOLD, 16));
lblTitle.setText("Utility Menu");
lblTitle.setHorizontalAlignment(JLabel.CENTER);
btnAbout.setText("About this Program");
btnAbout.setMnemonic('A');
btnAbout.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
btnAbout_actionPerformed(e);
}
});
btnReturn.setText("Quit Program");
btnReturn.setMnemonic('Q');
btnReturn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
btnReturn_actionPerformed(e);
}
});
utilityMenu.setLayout(bdlUtilityMenu);
utilityMenu.add(lblTitle, BorderLayout.NORTH);
utilityMenu.add(btnAbout, BorderLayout.CENTER);
utilityMenu.add(btnReturn, BorderLayout.SOUTH);
// Build the "About" page.
JPanel utilityAbout = new JPanel();
GridBagLayout gblMain = new GridBagLayout();
JPanel pnlImageHolder = new JPanel();
GridBagLayout gblImageHolder = new GridBagLayout();
JPanel pnlTitleHolder = new JPanel();
GridBagLayout gblTitleHolder = new GridBagLayout();
ImageDisplayer idAbout = new ImageDisplayer();
JLabel lblName = new JLabel();
btnDone = new JButton();
JPanel pnlFormatNavButton1 = new JPanel();
BorderLayout bdlNavButtons = new BorderLayout();
utilityAbout.setLayout(gblMain);
utilityAbout.add(pnlTitleHolder, GBC(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0));
pnlImageHolder.setLayout(gblImageHolder);
pnlTitleHolder.setLayout(gblTitleHolder);
idAbout.setImage(Toolkit.getDefaultToolkit().getImage("BRAbout.gif"));
idAbout.setSize(64, 64);
pnlImageHolder.add(idAbout, GBC(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
pnlTitleHolder.add(pnlImageHolder, GBC(0, 0, 1, 2, 0.0, 0.0,
GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
lblName.setFont(new Font("Helvetica", Font.BOLD, 32));
lblName.setText("BenRite 2000");
lblName.setHorizontalAlignment(JLabel.CENTER);
pnlTitleHolder.add(lblName, GBC(1, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
btnDone.setText("Done");
btnDone.setMnemonic('D');
btnDone.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
btnDone_actionPerformed(e);
}
});
utilityAbout.add(pnlFormatNavButton1, GBC(0, 3, 1, 1, 1.0, 1.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
pnlFormatNavButton1.setLayout(bdlNavButtons);
pnlFormatNavButton1.add(btnDone, null);
// Put the Utility Menu and "About" page into the main panel.
thisContentPane = this.getContentPane();
thisContentPane.setLayout(cdlBenRite);
thisContentPane.add(utilityMenu, "UtilityMenu");
thisContentPane.add(utilityAbout, "UtilityAbout");
}
void btnAbout_actionPerformed(ActionEvent e) {
cdlBenRite.show(thisContentPane, "UtilityAbout");
btnDone.requestFocus();
}
void btnReturn_actionPerformed(ActionEvent e) {
System.exit(0);
}
void btnDone_actionPerformed(ActionEvent e) {
cdlBenRite.show(thisContentPane, "UtilityMenu");
btnAbout.requestFocus();
}
public static GridBagConstraints GBC(int gridx, int gridy, int gridwidth,
int gridheight,
double weightx, double weighty, int anchor,
int fill,
Insets ins, int ipadx, int ipady) {
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = gridx;
gbc.gridy = gridy;
gbc.gridwidth = gridwidth;
gbc.gridheight = gridheight;
gbc.weightx = weightx;
gbc.weighty = weighty;
gbc.anchor = anchor;
gbc.fill = fill;
gbc.insets = ins;
gbc.ipadx = ipadx;
gbc.ipady = ipady;
return gbc;
}
}
class ImageDisplayer extends Canvas {
Image img;
public ImageDisplayer() {
this.img = null;
}
public void setImage(Image img) {
this.img = img;
if(img != null)
this.setSize(img.getWidth(this), img.getHeight(this));
}
public void paint(Graphics g) {
if(img != null)
g.drawImage(img, 0, 0, this);
}
}
----- END OF ATTACHED CODE -----
Release Regression From : 1.3.1_01
The above release value was the last known release where this
bug was knwon to work. Since then there has been a regression.
(Review ID: 136743)
======================================================================
java version "1.4.0-beta3"
Java (TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)
Compile the attached code with "javac BenRite.java". Run it with "java BenRite".
Please supply your own .gif image, preferrable 64x64 pixels. This web-based bug
report *discourages* attaching binaries :^). This .gif image should be named
"BRAbout.gif".
What will happen: Start the program. Your "BRAbout.gif" image will partially
obscure the "About" button. Now click the "About" button. The "About" page
displays, and the image moves to its proper position. Press the "Done" button.
The menu page redisplays. This time the image behaves itself and confines
itself to its "About" JPanel.
----- BEGINNING OF ATTACHED CODE -----
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class BenRite extends JFrame {
private Container thisContentPane;
private CardLayout cdlBenRite = new CardLayout();
JButton btnAbout;
JButton btnReturn;
JButton btnDone;
public static void main (String[] args) {
BenRite f = new BenRite();
f.pack();
f.setVisible(true);
}
public BenRite() {
super("BenRite 2000");
// Build the Utility Menu.
JPanel utilityMenu = new JPanel();
BorderLayout bdlUtilityMenu = new BorderLayout();
JLabel lblTitle = new JLabel();
btnAbout = new JButton();
btnReturn = new JButton();
lblTitle.setFont(new Font("Helvetica", Font.BOLD, 16));
lblTitle.setText("Utility Menu");
lblTitle.setHorizontalAlignment(JLabel.CENTER);
btnAbout.setText("About this Program");
btnAbout.setMnemonic('A');
btnAbout.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
btnAbout_actionPerformed(e);
}
});
btnReturn.setText("Quit Program");
btnReturn.setMnemonic('Q');
btnReturn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
btnReturn_actionPerformed(e);
}
});
utilityMenu.setLayout(bdlUtilityMenu);
utilityMenu.add(lblTitle, BorderLayout.NORTH);
utilityMenu.add(btnAbout, BorderLayout.CENTER);
utilityMenu.add(btnReturn, BorderLayout.SOUTH);
// Build the "About" page.
JPanel utilityAbout = new JPanel();
GridBagLayout gblMain = new GridBagLayout();
JPanel pnlImageHolder = new JPanel();
GridBagLayout gblImageHolder = new GridBagLayout();
JPanel pnlTitleHolder = new JPanel();
GridBagLayout gblTitleHolder = new GridBagLayout();
ImageDisplayer idAbout = new ImageDisplayer();
JLabel lblName = new JLabel();
btnDone = new JButton();
JPanel pnlFormatNavButton1 = new JPanel();
BorderLayout bdlNavButtons = new BorderLayout();
utilityAbout.setLayout(gblMain);
utilityAbout.add(pnlTitleHolder, GBC(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0));
pnlImageHolder.setLayout(gblImageHolder);
pnlTitleHolder.setLayout(gblTitleHolder);
idAbout.setImage(Toolkit.getDefaultToolkit().getImage("BRAbout.gif"));
idAbout.setSize(64, 64);
pnlImageHolder.add(idAbout, GBC(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
pnlTitleHolder.add(pnlImageHolder, GBC(0, 0, 1, 2, 0.0, 0.0,
GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
lblName.setFont(new Font("Helvetica", Font.BOLD, 32));
lblName.setText("BenRite 2000");
lblName.setHorizontalAlignment(JLabel.CENTER);
pnlTitleHolder.add(lblName, GBC(1, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
btnDone.setText("Done");
btnDone.setMnemonic('D');
btnDone.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
btnDone_actionPerformed(e);
}
});
utilityAbout.add(pnlFormatNavButton1, GBC(0, 3, 1, 1, 1.0, 1.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
pnlFormatNavButton1.setLayout(bdlNavButtons);
pnlFormatNavButton1.add(btnDone, null);
// Put the Utility Menu and "About" page into the main panel.
thisContentPane = this.getContentPane();
thisContentPane.setLayout(cdlBenRite);
thisContentPane.add(utilityMenu, "UtilityMenu");
thisContentPane.add(utilityAbout, "UtilityAbout");
}
void btnAbout_actionPerformed(ActionEvent e) {
cdlBenRite.show(thisContentPane, "UtilityAbout");
btnDone.requestFocus();
}
void btnReturn_actionPerformed(ActionEvent e) {
System.exit(0);
}
void btnDone_actionPerformed(ActionEvent e) {
cdlBenRite.show(thisContentPane, "UtilityMenu");
btnAbout.requestFocus();
}
public static GridBagConstraints GBC(int gridx, int gridy, int gridwidth,
int gridheight,
double weightx, double weighty, int anchor,
int fill,
Insets ins, int ipadx, int ipady) {
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = gridx;
gbc.gridy = gridy;
gbc.gridwidth = gridwidth;
gbc.gridheight = gridheight;
gbc.weightx = weightx;
gbc.weighty = weighty;
gbc.anchor = anchor;
gbc.fill = fill;
gbc.insets = ins;
gbc.ipadx = ipadx;
gbc.ipady = ipady;
return gbc;
}
}
class ImageDisplayer extends Canvas {
Image img;
public ImageDisplayer() {
this.img = null;
}
public void setImage(Image img) {
this.img = img;
if(img != null)
this.setSize(img.getWidth(this), img.getHeight(this));
}
public void paint(Graphics g) {
if(img != null)
g.drawImage(img, 0, 0, this);
}
}
----- END OF ATTACHED CODE -----
Release Regression From : 1.3.1_01
The above release value was the last known release where this
bug was knwon to work. Since then there has been a regression.
(Review ID: 136743)
======================================================================