//: Show.java // Tool for displaying Swing demos package c13.swing; import java.awt.*; import java.awt.event.*; import com.sun.java.swing.*; public class Show { public static void inFrame(JPanel jp, int width, int height) { String title = jp.getClass().toString(); // Remove the word "class": if(title.indexOf("class") != -1) title = title.substring(6); JFrame frame = new JFrame(title); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ System.exit(0); } }); frame.getContentPane().add( jp, BorderLayout.CENTER); frame.setSize(width, height); frame.setVisible(true); } } ///:~
Java Alley | Java's Swing Library, Part One (Web Techniques, Mar 1998)
Related Reading
More Insights
INFO-LINK
To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy. | |