SWING / CATATAN</>↗Swing03 Agt 2007
The UIManager.getSystemLookAndFeelClassName() method returns the current system LAF (Look and Feel) for Swing application. Do not forget to call the SwingUtilities.updateComponentTreeUI() method after setting the LAF to update the current application look and feel. package org.kodejava.swing; import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.WindowConstants; public class SystemLAFDemo { public static void main(Strin...
SWING / CATATAN</>↗Swing02 Agt 2007
package org.kodejava.swing; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.WindowConstants; import java.awt.FlowLayout; public class LookAndFeelDemo extends JFrame { public LookAndFeelDemo() { initComponents(); } public static void main(String[] args) { SwingUtilities.invokeLater(() -> new LookAndFeelD...
SWING / CATATAN</>↗Swing01 Agt 2007
The code snippet below describe how we can obtain the available look and feel in the current Swing platform. This information can then be made available to the user, so they can change to look and feel of the application in their preferences. package org.kodejava.swing; import javax.swing.UIManager; public class AvailableLookAndFeel { public static void main(String[] […]
SWING / CATATAN</>↗Swing31 Jul 2007
To change JTextField text to upper case can be easily done by adding a DocumentFilter to the JTextField component using the setDocumentFilter() method. The DocumentFilter allow us to filter action for changes in the document such as insert, replace and remove. The code snippet below show us how to do it. package org.kodejava.swing; import javax.swing.JFrame; […]
SWING / CATATAN</>↗Swing29 Jul 2007
In this small Swing code snippet we demonstrate how to use java.awt.event.KeyAdapter abstract class to handle keyboard event for the JTextField component. The snippet will change the characters typed in the JTextField component to uppercase. A better approach for this use case is to use the DocumentFilter class. See the following code snippet How do […]
SWING / CATATAN</>↗Swing26 Jul 2007
This code snippet demonstrates how to change a JFrame image icon using the setIconImage() method. package org.kodejava.swing; import javax.imageio.ImageIO; import javax.swing.JFrame; import javax.swing.WindowConstants; import java.awt.Dimension; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; public class FrameIconExample extends JFrame { public static void main(String[] args) { FrameIconExample frame = new FrameIconExample(); frame.setDe...