Skip to content

Instantly share code, notes, and snippets.

@Tanner
Created October 14, 2011 20:12
Show Gist options
  • Select an option

  • Save Tanner/1288184 to your computer and use it in GitHub Desktop.

Select an option

Save Tanner/1288184 to your computer and use it in GitHub Desktop.
JPanel with preferred size
import java.awt.*;
import javax.swing.*;
public class Test extends JPanel {
public Test() {
setPreferredSize(new Dimension(400, 400));
}
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.add(new Test());
frame.pack();
frame.setVisible(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment