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)    {		super(title);		setCloseClick();		setLF();	}	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 {		 UIManager.setLookAndFeel(laf);		}		catch (UnsupportedLookAndFeelException exc)			{System.err.println("Warning: UnsupportedLookAndFeel: " + laf);}		catch (Exception exc) {System.err.println("Error loading " + laf +": " + exc);			}	}}

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a