![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
Can't resize my JFrame.
I'm having difficulty resizing my form. My program is inheriting JFrame, so I thought I could use super, apparently not? Anybody?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TicTacToe extends JFrame implements ActionListener {
private static JButton[] bbox = new JButton[9];
private static JLabel lblwin = new JLabel("");
public TicTacToe() {
super("Tic Tac Toe!");
super.setSize(999, 999);
super.setResizable(false);
getContentPane().setLayout(new GridLayout(4, 3));
// makes the form's X button work
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
for (int i = 0; i < bbox.length; i++) {
bbox[i] = new JButton(" ");
bbox[i].setFont(new Font("Verdana", Font.BOLD, 16));
bbox[i].addActionListener(this);
getContentPane().add(bbox[i]);
}
getContentPane().add(lblwin);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent evt) {
// do stuff
}
public static void main(String args[]) {
new TicTacToe();
}
}Thanks. This has been driving me crazy. ![]()
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
Try this.setSize(999, 999);
|
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
Tried it, no effect.
![]()
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
#4 |
|
Programming Guru
![]() |
Sorry, I didn't look closely earlier. Remove the call to pack(). It "resizes the window to the minimum size to satisfy the preferred size of each of the components in the layout."
|
|
|
|
|
|
#5 |
|
Hobbyist Programmer
|
Thanks, that worked perfectly.
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Window resize event? | titaniumdecoy | Java | 1 | May 1st, 2006 2:09 AM |
| 1st Java Project...Still | Kilo | Java | 20 | Feb 23rd, 2006 5:20 PM |