SWING / CATATAN</>↗Swing18 Jan 2009
In this example you can see how we do an absolute positioning to a swing component in the content panel. In this example we use a JPanel as the container, and we didn’t set a layout manager into it. To position the component on the container we use the setBounds() method of the component. This […]
SWING / CATATAN</>↗Swing17 Jan 2009
This example use the GridLayout to create a four by four grid layout. One each of the grid we place a JTextField component to read user inputs. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class GridLayoutDemo extends JFrame { public GridLayoutDemo() { initializeUI(); } public static void main(String[] args) { SwingUtilities.invokeLater(() -> new GridLayoutDemo().setVisible(true)); } […]
SWING / CATATAN</>↗Swing13 Jan 2009
In this example you can see how to arrange the swing components using the FlowLayout manager. This manager arranges the component in a directional flow based on the container component orientation such as ComponentOrientation.LEFT_TO_RIGHT and ComponentOrientation.RIGHT_TO_LEFT. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class FlowLayoutExample extends JFrame { public FlowLayoutExample() { initialize(); } public static […]
SWING / CATATAN</>↗Swing10 Jan 2009
This example demonstrate how we can arrange component in row or column order using the BoxLayout layout manager. Instead of use the BoxLayout manager we can also use the Box component as our content pane to get the same effect as using the BoxLayout manager. package org.kodejava.swing; import javax.swing.*; public class BoxLayoutDemo extends JFrame { […]
SWING / CATATAN</>↗Swing08 Jan 2009
This example show how to create an implementation of PopupMenuListener for listening to when the JComboBox menu is visible, invisible or cancelled. package org.kodejava.swing; import javax.swing.*; import javax.swing.event.PopupMenuListener; import javax.swing.event.PopupMenuEvent; import java.awt.*; public class ComboBoxPopupMenuListener extends JFrame { public ComboBoxPopupMenuListener() { initialize(); } public static void main(String[] args) { SwingUtilities.invokeLater(...
SWING / CATATAN</>↗Swing03 Jan 2009
The code below shows you how to add an ActionListener to a JComboBox component. In the snippet we add a listener by calling the addActionListener() method and give an instance of ActionListener listener as an anonymous class (a class without a specified name) as the parameter. The ActionListener interface contract said that we must implement […]