Tutorial by Examples

Creating the JFrame Creating a window is easy. You just have to create a JFrame. JFrame frame = new JFrame(); Titling the Window You may wish to give your window a title. You can so do by passing a string when creating the JFrame, or by calling frame.setTitle(String title). JFrame frame = new...
A component is some sort of user interface element, such as a button or a text field. Creating a Component Creating components is near identical to creating a window. Instead of creating a JFrame however, you create that component. For example, to create a JButton, you do the following. JButton b...
Components have various parameters that can be set for them. They vary from component to component, so a good way to see what parameters can be set for components is to start typing componentName.set, and let your IDE's autocomplete (If you use an IDE) suggest methods. The default shortcut in many I...
DescriptionClassButtonJButtonCheckboxJCheckBoxDrop down menu / Combo boxJComboBoxLabelJLabelListJListMenu barJMenuBarMenu in a menu barJMenuItem in a menuJMenuItemPanelJPanelProgress barJProgressBarRadio buttonJRadioButtonScroll barJScrollBarSliderJSliderSpinner / Number pickerJSpinnerTableJTableTre...
Having a button there is all well and good, but what's the point if clicking it does nothing? ActionListeners are used to tell your button, or other component to do something when it is activated. Adding ActionListeners is done as such. buttonA.addActionListener(new ActionListener() { @Overri...
Adding components one after another results in a UI that's hard to use, because the components all are somewhere. The components are ordered from top to bottom, each component in a separate "row". To remedy this and provide you as developer with a possibility to layout components easily S...

Page 1 of 1