ingrid.yao@Eng 2000-11-21
J2SE Version (please include all output from java -version flag):
------------------------------------------------------------------
java version "1.4.0beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b40)
Java HotSpot(TM) Client VM (build 1.4beta-B40, mixed mode)
Does this problem occur on J2SE 1.3? Yes / No (pick one)
----------------------------------------------------------
No
Operating System Configuration Information (be specific):
-------------------------------------------------------
Linux gumnut 2.2.14-5.0 #1 Tue Mar 7 21:07:39 EST 2000 i686 unknown
Hardware Configuration Information (be specific):
------------------------------------------------
IBM Thinkpad 600X standard config. 320Mb ram.
Bug Description:
---------------
open just about any Swing application, nothing appears in the window.
Steps to Reproduce (be specific):
--------------------------------
use the attached code, Frame1.java. COmpile and run it. It should show
a canvas with a red "X" and a menu. Instead nothing is shown.
Curiously, you can click where the menu should be, and, so long as you
click correctly, the menu works.
Test program:
================
//package fd;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
//import com.esri.aims.sdk.sys.tp.ThreadDialog;
//import com.esri.aims.sdk.sys.tp.ThreadPool;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2000
* Company:
* @author
* @version 1.0
*/
public class Frame1 extends JFrame {
static int count = 0;
static int id = 0;
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenu1 = new JMenu();
JMenuItem jMenuItem2 = new JMenuItem();
JMenuItem jMenuItem3 = new JMenuItem();
JMenuItem jMenuItem4 = new JMenuItem();
public static void main(String[] args) {
openFrame();
}
private static final void openFrame() {
Frame1 frame1 = new Frame1();
frame1.setSize(300,200);
frame1.getContentPane().setLayout(new BorderLayout());
frame1.getContentPane().add(new MyCanvas());
frame1.setTitle(getFrameTitle());
frame1.setVisible(true);
count++;
}
private static final String getFrameTitle() {
id++;
return "Frame "+id;
}
private static final void closeFrame(Window window) {
count--;
window.dispose();
if (count <= 0) System.exit(0);
}
protected void finalize() throws Throwable {
System.err.println("Frame1.finalize: "+getTitle());
}
public Frame1() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
jMenu1.setText("File");
jMenuItem2.setText("New");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jMenuItem2_actionPerformed(e);
}
});
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(WindowEvent e) {
this_windowClosing(e);
}
});
this.setJMenuBar(jMenuBar1);
jMenuItem3.setText("GC");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jMenuItem3_actionPerformed(e);
}
});
jMenuItem4.setText("Close");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jMenuItem4_actionPerformed(e);
}
});
jMenuBar1.add(jMenu1);
jMenu1.add(jMenuItem2);
jMenu1.addSeparator();
jMenu1.add(jMenuItem3);
jMenu1.addSeparator();
jMenu1.add(jMenuItem4);
}
void jMenuItem1_actionPerformed(ActionEvent e) {
System.exit(0);
}
void jMenuItem2_actionPerformed(ActionEvent e) {
openFrame();
}
void this_windowClosing(WindowEvent e) {
closeFrame(e.getWindow());
}
void jMenuItem3_actionPerformed(ActionEvent e) {
System.gc();
}
void jMenuItem4_actionPerformed(ActionEvent e) {
closeFrame(Frame1.this);
}
}
class MyCanvas extends JComponent {
public void paintComponent(Graphics g) {
int w = getWidth();
int h = getHeight();
g.setColor(Color.red);
g.drawLine(0,0,w,h);
g.drawLine(0,h,w,0);
}
protected void finalize() throws Throwable {
System.err.println("MyCanvas.finalize");
}
}
- duplicates
-
JDK-4395862 JCK-interactive: Swing does not work if color depth is 16 bpp
- Closed
-
JDK-4392224 Swing application does not come up properly on Linux
- Closed
-
JDK-4394271 JFC demos are not showing up on Linux 7.0
- Closed