-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0
-
1.2rc2
-
generic
-
solaris_2.5.1
-
Not verified
The Exception:
java.lang.NullPointerException
at java.awt.Window.postProcessKeyEvent(Compiled Code)
at java.awt.Container.postProcessKeyEvent(Compiled Code)
at java.awt.Component.dispatchEventImpl(Compiled Code)
at java.awt.Component.dispatchEvent(Compiled Code)
at java.awt.EventQueue.dispatchEvent(Compiled Code)
at java.awt.EventDispatchThread.run(Compiled Code)
Classes to Reproduce:
(I'm sorry these aren't very minimal. The first class calls the second.)
import java.util.zip.*;
import java.util.Enumeration;
import views.Legal;
public class testApplication {
private Frame frame;
public static void main(String args[]) throws Exception {
testApplication testApp = new testApplication();
testApp.view();
System.out.println("hello world");
}
private void view() throws Exception {
Label label = new Label("Hello World");
frame = new Frame("Trivial Application");
frame.add(label);
frame.setSize(new Dimension(400,300));
frame.show();
testMethod();
}
private void testMethod() throws Exception {
Legal.splashScreen(frame);
}
}
import java.awt.*;
import java.awt.event.*;
public class Legal {
static private Dialog splashScreenDialog = null;
static private Dialog licenseDialog = null;
static public void splashScreen(Frame view) {
// Dialog Dimensions
//-----------------------------
int dialogHeight = 480;
int dialogWidth = 370;
int copytextHeight = 65;
int copytextWidth = 240;
// Throw everything on a panel - the extra panel is here for setting
// the background to white - Windows doesn't let us do this for a dialog.
Panel dp = new Panel();
dp.setName("SplashScreenPane");
GridBagLayout bl = new GridBagLayout();
dp.setLayout(bl);
dp.setBackground(Color.white);
// Component stuff
// ------------------------
String title = "test title";
splashScreenDialog = new Dialog(view, true);
splashScreenDialog.setName("SplashScreenDialog");
splashScreenDialog.setLayout(new BorderLayout());
splashScreenDialog.setBackground(Color.white);
splashScreenDialog.setTitle(title);
Button agButton = new Button("kill me");
agButton.setName("SplashScreenContinueButton");
// Wire the quit button
//-------------------------------------------------
agButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
splashScreenDialog.dispose();
}
});
// Wire the Keyboard (any key disposes the dialog);
//-------------------------------------------------
agButton.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
splashScreenDialog.dispose();
}
});
// Wire the Keyboard (any key disposes the dialog);
//-------------------------------------------------
splashScreenDialog.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
splashScreenDialog.dispose();
}
});
try {
addComponent(dp, agButton, 3, 4, 1, 1, 0, 0, new Insets(5, 1, 5, 5),
GridBagConstraints.NONE, GridBagConstraints.SOUTHEAST);
}
catch (Exception e) {
e.printStackTrace();
}
splashScreenDialog.add("Center", dp);
splashScreenDialog.pack();
splashScreenDialog.setSize(dialogWidth, dialogHeight);
Point loc = view.getLocation();
Dimension fDim = view.getSize();
Dimension dDim = splashScreenDialog.getSize();
// center the dialog frame
loc.translate((fDim.width - dDim.width)/2, (fDim.height - dDim.height) / 2);
splashScreenDialog.setLocation(loc.x, loc.y);
splashScreenDialog.show();
splashScreenDialog.repaint();
}
public static void addComponent (Container container, Component component, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, Insets insets, int fill, int anchor) throws AWTException {
LayoutManager lm = container.getLayout();
if (! (lm instanceof GridBagLayout)) {
throw new AWTException ("Invalid layout" + lm);
}
else {
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = gridx;
gbc.gridy = gridy;
gbc.gridwidth = gridwidth;
gbc.gridheight = gridheight;
gbc.weightx = weightx;
gbc.weighty = weighty;
gbc.insets = insets;
gbc.fill = fill;
gbc.anchor = anchor;
container.add(component, gbc);
}
}
}
java.lang.NullPointerException
at java.awt.Window.postProcessKeyEvent(Compiled Code)
at java.awt.Container.postProcessKeyEvent(Compiled Code)
at java.awt.Component.dispatchEventImpl(Compiled Code)
at java.awt.Component.dispatchEvent(Compiled Code)
at java.awt.EventQueue.dispatchEvent(Compiled Code)
at java.awt.EventDispatchThread.run(Compiled Code)
Classes to Reproduce:
(I'm sorry these aren't very minimal. The first class calls the second.)
import java.util.zip.*;
import java.util.Enumeration;
import views.Legal;
public class testApplication {
private Frame frame;
public static void main(String args[]) throws Exception {
testApplication testApp = new testApplication();
testApp.view();
System.out.println("hello world");
}
private void view() throws Exception {
Label label = new Label("Hello World");
frame = new Frame("Trivial Application");
frame.add(label);
frame.setSize(new Dimension(400,300));
frame.show();
testMethod();
}
private void testMethod() throws Exception {
Legal.splashScreen(frame);
}
}
import java.awt.*;
import java.awt.event.*;
public class Legal {
static private Dialog splashScreenDialog = null;
static private Dialog licenseDialog = null;
static public void splashScreen(Frame view) {
// Dialog Dimensions
//-----------------------------
int dialogHeight = 480;
int dialogWidth = 370;
int copytextHeight = 65;
int copytextWidth = 240;
// Throw everything on a panel - the extra panel is here for setting
// the background to white - Windows doesn't let us do this for a dialog.
Panel dp = new Panel();
dp.setName("SplashScreenPane");
GridBagLayout bl = new GridBagLayout();
dp.setLayout(bl);
dp.setBackground(Color.white);
// Component stuff
// ------------------------
String title = "test title";
splashScreenDialog = new Dialog(view, true);
splashScreenDialog.setName("SplashScreenDialog");
splashScreenDialog.setLayout(new BorderLayout());
splashScreenDialog.setBackground(Color.white);
splashScreenDialog.setTitle(title);
Button agButton = new Button("kill me");
agButton.setName("SplashScreenContinueButton");
// Wire the quit button
//-------------------------------------------------
agButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
splashScreenDialog.dispose();
}
});
// Wire the Keyboard (any key disposes the dialog);
//-------------------------------------------------
agButton.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
splashScreenDialog.dispose();
}
});
// Wire the Keyboard (any key disposes the dialog);
//-------------------------------------------------
splashScreenDialog.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
splashScreenDialog.dispose();
}
});
try {
addComponent(dp, agButton, 3, 4, 1, 1, 0, 0, new Insets(5, 1, 5, 5),
GridBagConstraints.NONE, GridBagConstraints.SOUTHEAST);
}
catch (Exception e) {
e.printStackTrace();
}
splashScreenDialog.add("Center", dp);
splashScreenDialog.pack();
splashScreenDialog.setSize(dialogWidth, dialogHeight);
Point loc = view.getLocation();
Dimension fDim = view.getSize();
Dimension dDim = splashScreenDialog.getSize();
// center the dialog frame
loc.translate((fDim.width - dDim.width)/2, (fDim.height - dDim.height) / 2);
splashScreenDialog.setLocation(loc.x, loc.y);
splashScreenDialog.show();
splashScreenDialog.repaint();
}
public static void addComponent (Container container, Component component, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, Insets insets, int fill, int anchor) throws AWTException {
LayoutManager lm = container.getLayout();
if (! (lm instanceof GridBagLayout)) {
throw new AWTException ("Invalid layout" + lm);
}
else {
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = gridx;
gbc.gridy = gridy;
gbc.gridwidth = gridwidth;
gbc.gridheight = gridheight;
gbc.weightx = weightx;
gbc.weighty = weighty;
gbc.insets = insets;
gbc.fill = fill;
gbc.anchor = anchor;
container.add(component, gbc);
}
}
}
- relates to
-
JDK-4182193 ICEMail 2.6 gets NullPointerException on JDK 1.2
- Closed