SWING / CATATAN</>↗Swing08 Feb 2009
In this example we create a compound border, a border around border. Here, instead of creating a new instance of Border class directly we create the border using the BorderFactory factory class. package org.kodejava.swing; import javax.swing.*; import javax.swing.border.BevelBorder; import javax.swing.border.Border; import java.awt.*; public class CompoundBorderExample extends JFrame { public CompoundBorderExample() { initializeUI(); } public static […]
SWING / CATATAN</>↗Swing05 Feb 2009
This example shows you how to create a border that have a title in it. There is a special border class the TitledBorder that does this. We can define the justification of the title, left, centered or right justify. To do this we call the setTitleJustification() method. We can also set other attributes such as […]
SWING / CATATAN</>↗Swing31 Jan 2009
This example shows how we can create border for swing components. In the example below we set border of a JPanel component. Some border implementation that we use below including LineBorder, BevelBorder, EtchedBorder and MatteBorder. package org.kodejava.swing; import javax.swing.*; import javax.swing.border.LineBorder; import javax.swing.border.BevelBorder; import javax.swing.border.EtchedBorder; import javax.swing.border.MatteBorder; import java.awt.*; public class BorderDe...
SWING / CATATAN</>↗Swing27 Jan 2009
This example shows you how to create a ButtonGroup for grouping our radio buttons components into a single group. In this example you can also see that we add an action listener to the radio buttons. package org.kodejava.swing; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class ButtonGroupDemo extends JFrame { public ButtonGroupDemo() { […]
SWING / CATATAN</>↗Swing23 Jan 2009
Below we create a JRadioButton and pass an action handle to the component so that we know when the component is clicked. package org.kodejava.swing; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; public class RadioButtonCreateAction extends JFrame { public RadioButtonCreateAction() { initializeUI(); } public static void main(String[] args) { SwingUtilities.invokeLater( () -> new RadioButtonCreateAction().setVisible(true)); } private void […]
SWING / CATATAN</>↗Swing19 Jan 2009
This simple example shows you how to create a JRadioButton component. To create an instance of JRadioButton we can simply call its constructor and pass a string as the radio button text. We can also call the constructor with a boolean value after the text to indicate whether the radio button is selected or not. […]