Still, I want to document the issue, so we don't lose the problem.
First, the paramString() method on line 494 of libraries/javalib/java/awt/Container.java calls getLayout().getClass().getName(), without checking to see if layoutm is null.
I've attached a test case to demonstrate the problem (click the button on the screen, and watch the console for errors). It probably isn't needed, but it never hurts. It also shows a problem with the layout, but I've already sent in a test case for that.
Second, the paramString() method of libraries/javalib/java/awt/Component.java uses String "+" operator instead of a StringBuffer and append() calls. This isn't a failure, per se, just a sub-optimal performance choice.
James Damour
/* * TestAWT - Simple program to test AWT code. * Copyright (c) 2004 James Damour. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */
/*
Author: James Damour (Suvarov454) <[EMAIL PROTECTED]>
Test AWT use.
*/
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class TestAWT {
public static void main (String[] args) {
final Frame frame = new Frame("Test AWT");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.setBackground(SystemColor.menu);
frame.setForeground(SystemColor.menuText);
Button hostB, connectB, botB, editB, scenB, loadB, quitB;
Panel panTitle = new Panel();
ActionListener closer = new ActionListener() {
public void actionPerformed (ActionEvent evt) {
HostDialog hd = new HostDialog (frame);
hd.show();
System.exit(0);
}
};
hostB = new Button("Host a New Game...");
hostB.addActionListener (closer);
// layout
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
frame.setLayout(gridbag);
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.WEST;
c.weightx = 0.0;
c.weighty = 0.0;
c.insets = new Insets(4, 4, 1, 1);
c.gridwidth = GridBagConstraints.REMAINDER;
c.ipadx = 10;
c.ipady = 5;
c.gridx = 0;
c.gridwidth = 1;
c.gridheight = 7;
addBag(frame, panTitle, gridbag, c);
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridx = 1;
c.gridheight = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridy = 0;
addBag(frame, hostB, gridbag, c);
frame.validate();
// set visible on middle of screen
Dimension screenSize = frame.getToolkit().getScreenSize();
frame.pack();
frame.setLocation(
screenSize.width / 2 - frame.getSize().width / 2,
screenSize.height / 2 - frame.getSize().height / 2);
// Show the window.
frame.setVisible(true);
}
private static void addBag(Frame frame, Component comp,
GridBagLayout gridbag, GridBagConstraints c) {
gridbag.setConstraints(comp, c);
frame.add(comp);
}
}
/**
* here's a quick class for the host new game diaglogue box
*/
class HostDialog extends Dialog implements ActionListener {
protected Label yourNameL, serverPassL, portL;
protected TextField yourNameF, serverPassF, portF;
protected Button okayB, cancelB;
public HostDialog(Frame frame) {
super(frame, "Host New Game...", true);
yourNameL = new Label("Your Name:", Label.RIGHT);
portF = new TextField("2536", 4);
portF.addActionListener(this);
okayB = new Button("Okay");
okayB.setActionCommand("done");
okayB.addActionListener(this);
okayB.setSize(80, 24);
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
setLayout(gridbag);
c.fill = GridBagConstraints.NONE;
c.weightx = 0.0;
c.weighty = 0.0;
c.insets = new Insets(5, 5, 5, 5);
c.gridwidth = 1;
c.anchor = GridBagConstraints.EAST;
gridbag.setConstraints(yourNameL, c);
add(yourNameL);
c.gridwidth = GridBagConstraints.REMAINDER;
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(portF, c);
add(portF);
c.ipadx = 20;
c.ipady = 5;
c.gridwidth = 1;
c.anchor = GridBagConstraints.CENTER;
gridbag.setConstraints(okayB, c);
add(okayB);
pack();
setResizable(false);
setLocation(
frame.getLocation().x + frame.getSize().width / 2 - getSize().width / 2,
frame.getLocation().y + frame.getSize().height / 2 - getSize().height / 2);
}
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
}
_______________________________________________ kaffe mailing list [EMAIL PROTECTED] http://kaffe.org/cgi-bin/mailman/listinfo/kaffe
