If you change frame.setSize( 150, 100 )
to
frame.setSize( 300, 100 )
how will the frame appear?
The frame will be 300 pixels wide by 100 high, twice as wide as previous.
The setSize()
method of JFrame
changes
the size of the frame on the computer monitor.
The size can be changed as the program runs.
For example, the following program works
(although it is mostly useless):
import java.awt.*; import javax.swing.*; public class TestFrame1 { public static void main ( String[] args ) { int height=100, width=200; JFrame frame = new JFrame("Test Frame 1"); frame.setSize( width, height ); frame.setVisible( true ); frame.setSize( width+50, height+75 ); } }
The frame starts out with size 200 by 100, and then changes size to 250 by 175.