Java Swing Applications Tips and Tricks

Java is very good in creating desktop applications but creating UI using java java program is bit complicated.Few things we need to consider always while writing code for we will see some useful tips for java swing gui applications.

1.How to display a JDialog in Center of JFrame

Use following method to display JDialog in center of JFrame(parent frame).It will most useful while writing swing applications.

2.       How to add or remove Look and feel for Swing Applications.

public void setUndecorated (boolean undecorated)

Disables or enables decorations for this frame. This method can only be called while the frame is not displayable.


How to connect JDialog to Parent or Owner Window

public JDialog(Dialog owner,

String title)

Creates a modeless dialog with the specified title and with the specified owner dialog.

This constructor sets the component’s locale property to the value returned by JComponent.getDefaultLocale.


Owner – the owner Dialog from which the dialog is displayed or null if this dialog has no owner

Title – the String to display in the dialog’s title bar.
4.How to create Non – Editable Cells in JTable?

JTable Non €“Editable cells.

5.How to add JButton in JTable ColumnHeader


How to display JButton as Icon?

Use following methods.

7.How to Exit Swing Application Properly?
Close the swing application properly and no need to press CTRL + C after that.

8.load GIF, JPEG, and (in SDK 1.3) PNG images

instead of

9.getResourceAsStream() For Portability instead of

Use Java Swing Development Tools

About mohan

This is Mohan Jayapalan author of TechPages Blog.I am a part time blogger and Currently working for private Software Concern.

© Copyright 2010-2016 · All Rights Reserved · Powered by WordPress ·