Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 14th, 2007, 9:20 AM   #1
Intimidat0r
Hobbyist Programmer
 
Intimidat0r's Avatar
 
Join Date: May 2005
Location: Don't know, but the padded walls are a nice touch.
Posts: 126
Rep Power: 0 Intimidat0r is an unknown quantity at this point
Send a message via ICQ to Intimidat0r Send a message via AIM to Intimidat0r Send a message via MSN to Intimidat0r Send a message via Yahoo to Intimidat0r
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
Intimidat0r is offline   Reply With Quote
Old Mar 14th, 2007, 4:20 PM   #2
titaniumdecoy
Programming Guru
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 1,007
Rep Power: 5 titaniumdecoy will become famous soon enough
Send a message via AIM to titaniumdecoy
Try this.setSize(999, 999);
titaniumdecoy is offline   Reply With Quote
Old Mar 14th, 2007, 9:46 PM   #3
Intimidat0r
Hobbyist Programmer
 
Intimidat0r's Avatar
 
Join Date: May 2005
Location: Don't know, but the padded walls are a nice touch.
Posts: 126
Rep Power: 0 Intimidat0r is an unknown quantity at this point
Send a message via ICQ to Intimidat0r Send a message via AIM to Intimidat0r Send a message via MSN to Intimidat0r Send a message via Yahoo to Intimidat0r
Tried it, no effect.
__________________
Children in the dark cause accidents, and accidents in the dark cause children.

http://www.ronincoders.org
Intimidat0r is offline   Reply With Quote
Old Mar 14th, 2007, 10:40 PM   #4
titaniumdecoy
Programming Guru
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 1,007
Rep Power: 5 titaniumdecoy will become famous soon enough
Send a message via AIM to titaniumdecoy
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."
titaniumdecoy is offline   Reply With Quote
Old Mar 15th, 2007, 4:05 PM   #5
Intimidat0r
Hobbyist Programmer
 
Intimidat0r's Avatar
 
Join Date: May 2005
Location: Don't know, but the padded walls are a nice touch.
Posts: 126
Rep Power: 0 Intimidat0r is an unknown quantity at this point
Send a message via ICQ to Intimidat0r Send a message via AIM to Intimidat0r Send a message via MSN to Intimidat0r Send a message via Yahoo to Intimidat0r
Thanks, that worked perfectly.
__________________
Children in the dark cause accidents, and accidents in the dark cause children.

http://www.ronincoders.org
Intimidat0r is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:37 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC