Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window resizing trouble!

Status
Not open for further replies.

jeremytaffy

Technical User
Sep 6, 2001
75
0
0
US
I have an application that loads in a small window. When a selection is made, I clear the small window, and want to make it full screen sized, with a big button filling most of the screen. I have been able to resize the window, but the button only fills the size of the area that was originally there. I cant figure it out. code included

thanks in advance
j

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.border.*;
import java.io.*;
import javax.swing.filechooser.*;
import java.lang.*;

public class go extends JPanel {
JLabel label;
JFrame frame1;
String simpleDialogDesc = "The choices:";
JLabel space = new JLabel("");
final JButton yesbutton = new JButton("Go");
final JButton yesbutton2 = new JButton("Go");

final JButton voteButton = new JButton("Choose Wisely");
ButtonGroup selection = new ButtonGroup();
JRadioButton rbutton1 = new JRadioButton("A", true);
JRadioButton rbutton2 = new JRadioButton("B", false);
public go(final JFrame frame) {


yesbutton.setBackground(Color.green);
yesbutton.setFont(new Font("sansserif", Font.PLAIN, 600));
yesbutton2.setBackground(Color.green);
yesbutton2.setFont(new Font("sansserif", Font.PLAIN, 600));
final JLabel title = new JLabel(" Click the \"Choose\" button"
+ " once you have selected a choice. ",
JLabel.CENTER);
selection.add(rbutton1);
selection.add(rbutton2);
JLabel label2 = new JLabel(" ");
final JPanel buttons = new JPanel();
GridLayout flow1 = new GridLayout(9,1);
buttons.setLayout(flow1);
buttons.add(rbutton1);
buttons.add(rbutton2);
buttons.add(voteButton);

label = new JLabel("", JLabel.CENTER);


// Set the layout.
setLayout(new BorderLayout());
add(title, BorderLayout.NORTH);

add(buttons, BorderLayout.CENTER);
add(label2, BorderLayout.SOUTH);
add(label2, BorderLayout.WEST);

////////////////////////////////
voteButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (rbutton1.isSelected()){
removeAll();
setVisible(false);
setVisible(true);
//System.exit(0);
//frame1.setVisible(true);

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int wdFrame = screenSize.width;
int hgFrame = screenSize.height;
System.out.println(wdFrame);
System.out.println(hgFrame);
int space = 5;
//frame.setSize(wdFrame,hgFrame);
frame.setSize(wdFrame,hgFrame);
frame.setBounds(5,5,wdFrame,hgFrame);
setLayout(null);
yesbutton.setBounds(5,5,900, 900);
add(yesbutton);
setVisible(false);
setVisible(true);
}
}
});
}
public static void main(String[] args) {
final JFrame frame = new JFrame("Go");

Container contentPane = frame.getContentPane();
contentPane.setLayout(new GridLayout(1,1));
contentPane.add(new go(frame));

// Exit when the window is closed.
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.pack();
frame.setVisible(true);
}
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top