SWING / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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 […]
SWING / NOTES</>↗Swing31 Dec 2008
This example demonstrates the ItemListener to listen for changes to the selected item in the JComboBox component. package org.kodejava.swing; import javax.swing.*; import javax.swing.border.BevelBorder; import java.awt.event.ItemEvent; import java.awt.*; public class ComboBoxSelectionChange extends JFrame { public ComboBoxSelectionChange() { initialize(); } public static void main(String[] args) { SwingUtilities.invokeLater( () -> new ComboBoxSelectionChange().setVisible(true...
SWING / NOTES</>↗Swing28 Dec 2008
In this example you’ll see how we can change the default number of visible items in the combo box. By default, it only shows eight items at once and when the combo box has more items a scrollbar will be shown, so we can scroll up and down in the combo box list. If we […]