FULL PRODUCT VERSION :
ADDITIONAL OS VERSION INFORMATION :
Ubuntu 12.04
A DESCRIPTION OF THE PROBLEM :
Frame size does not follow font size change with XToolkit.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the test case,
1), input 30 in 'font size' field and press ENTER
2), input 20 in 'font size' field and press ENTER
3), Press ENTER
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After each ENTER key press, the font and window size change accordingly.
ACTUAL -
Only font size got changed, not windows size.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Portions Copyright (c) 2012 IBM Corporation
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.SwingUtilities;
public class LbCharViewer {
Font currentFont;
final String str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
final int ROWS = 5;
final int COLS = 20;
Label[] labels;
public LbCharViewer() {
final Frame frame = new Frame("Char viewer");
currentFont = new Font("Dialog", Font.PLAIN, 12);
frame.setLayout(new BorderLayout());
frame.setBackground(Color.lightGray);
Panel charPanel = new Panel();
labels = new Label[ROWS * COLS];
charPanel.setLayout(new GridLayout(0, COLS, 3, 3));
for (int i = 0; i < ROWS * COLS; ++i) {
Label label = new Label("");
label.setBackground(Color.white);
label.setForeground(Color.black);
charPanel.add(label);
labels[i] = label;
}
for (int i = 0; i < str.length(); i++) {
labels[i].setText(str.substring(i, i + 1));
}
Panel fontPanel = new Panel();
TextField txtFontsize = new TextField(3);
txtFontsize.setText("" + currentFont.getSize());
txtFontsize.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
int size = Integer.parseInt(command);
Font font = currentFont.deriveFont((float) size);
for (int i = 0; i < ROWS * COLS; ++i) {
labels[i].setFont(font);
}
currentFont = font;
frame.validate();
frame.pack();
}
});
fontPanel.add(new Label("Font Size:"));
fontPanel.add(txtFontsize);
frame.add(charPanel, "Center");
frame.add(fontPanel, "South");
frame.pack();
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
LbCharViewer table = new LbCharViewer();
}
});
}
}
---------- END SOURCE ----------