Home » Tag Archives: swing

Tag Archives: swing

Java Swing Key Binding Example

Places where KeyListener is used in order to map key input to some action, it is more convenient and preferred from usimg Keymap or InputMap and ActionMap combination instead. Using Keymap or InputMap and ActionMap combination, it is easier to map the action to a specific key stroke and thus key binding is achieved. 1. Introduction Most of the manipulations performed on text ...

Read More »

Java Swing JTextField Example

Swing offers us components through which users can type in text input. JTextField is one such component which is used to allow applications to accept single line input. Even user can go for standard operations like copy, paste, cut, delete. 1. Introduction Swing offers several components to ease user experience while typing in text or edit text. Different such are ...

Read More »

IntelliJ GUI Designer Example

This example demonstrates how you can utilize IntelliJ GUI Designer to create a graphical user interface that is based on the Swing library components. It must be noted that IntelliJ does not support modeling of non-swing components. When working with the GUI Designer you operate in design view where you are able to drag and drop swing components within the ...

Read More »

JScrollPane Swing example

1. Introduction In this post, I’ll be giving an example of using JScrollPane Swing component. This component is usually used to create a scroller on panels that has more content that it can display. It will let the user scroll up, down, left or right, depending on what and where is the content of the panel is being viewed. 2. ...

Read More »

Java JTable Example

In this example we are going to demonstrate how to use Java Swing JTable, JTable is a Swing component with which we can display tables of data, optionally allowing the user to edit the data, JTable relies on a separate TableModel object to hold and represent the data it displays. This article shows how to work with JTable using a simple example where ...

Read More »

Java Swing Radio Button Example

Introduction The radio button is a one of the core components that has been introduced ever since the early foundations of graphical user interface development. The very aspects of it is that it allows the user to select one value from a group of values. In this post, I’ll be walking you through how it’s easy to create a radio ...

Read More »

JFileChooser Swing Example

The JFileChooser Component is used to create a cross platform directory explorer that can be used for a Java Desktop Application. For this blog post, I’ll showcase the how to use the component and call it from a Java class.       1. Import the necessary objects   We need to import the following objects on your java class. ...

Read More »

Java JDialog example

This is a tutorial of how to create dialog windows, using the JDialog class of the javax.swing package. The Swing API provides libraries to create a Graphical User Interface in platform independent way. It follows the MVC architecture. It consists of UI elements, which are the visual elements that a user interacts with, layouts, which define the use of the ...

Read More »

Set tool tip for tab in JTabbedPane

With this example we shall see how to set the tool tip for a tab in JTabbedPane. In order to do that, one should follow these steps: Create a new JFrame. Call frame.getContentPane().setLayout(new GridLayout(1, 1) to set up grid layout for the frame. Use JTabbedPane(JTabbedPane.TOP) to get a JTabbedPane. Use tabbedPane.addTab to add a tool tip. Let’s see the code: ...

Read More »

Set tab color in JTabbedPane

With this example we shall see how to set tab color in JTabbedPane. In order to do that, one should follows these steps: Create a new JFrame. Call frame.getContentPane().setLayout(new GridLayout(1, 1) to set up grid layout for the frame. Use JTabbedPane(JTabbedPane.TOP) to get a JTabbedPane. Use tabbedPane.setForeground(Color.green) to set foreground color. Use tabbedPane.setBackground(Color.red) to set the background color. Use tabbedPane.addTab to add a tool tip. Let’s see the code: package ...

Read More »