Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Java
Expertise: Beginner
Nov 13, 1998



Application Security Testing: An Integral Part of DevOps

Beginning Swing-Based Applications

When you begin all Swing-based applications, you must set the look and feel and add a WindowListener so that when a user clicks on the exit box, the program exits. Consider putting these items in as base class JxFrame derived from JFrame so that you don't have to rewrite this code each time:
public class JxFrame extends JFrame {
	public JxFrame(String title)    {
	private void setCloseClick()    {
		//create window listener to respond to window close click
		addWindowListener(new WindowAdapter()
			public void windowClosing(WindowEvent e) {System.exit(0);}
	private void setLF()    {
	// Force SwingApp to come up in the System L&F
		String laf = UIManager.getSystemLookAndFeelClassName();
		try {
		catch (UnsupportedLookAndFeelException exc)
			{System.err.println("Warning: UnsupportedLookAndFeel: " + laf);}
		catch (Exception exc) {System.err.println("Error loading " + laf +
": " + exc);
James W.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date