Home » Desktop Java » swing

swing

Set foreground color in JLabel

With this example we shall show you how to set foreground color in a JLabel component in Java Desktop Applications. This will enrich and customize your GUI components. It’s very easy to set the foreground color in a JLebel, as all you have to do is: Create a class that extends JFrame. Create a new JLabel. Use JLabel.setForeground(Color.[COLOR_CODE]) to set ...

Read More »

Set background color in JLabel

With this example we shall show you how to set background color in a JLabel component in Java Desktop Applications. This will enrich and customize your GUI components. It’s very easy to set the background color in a JLebel, as all you have to do is: Create a class that extends JFrame. Create a new JLabel. Use JLabel.setBackground(Color.[COLOR_CODE]) to set the foreground color. Use add method to ...

Read More »

Create JLabel with border

In this example we are going to see how to create a JLabel with border. This is one basic graphics enhancement for your application. In general, this is one of the main customizations you can perform to your JLabels. In short, all you have to do to create a JLabel with border is: Create a class that extends JFrame. Create ...

Read More »

Align Icon in JLabel

With this tutorial we shall show you how to align Icons in JLabel. This is a very easy optimization you can perform to your JLabel. Basically in order to align Icon in JLabel, one should follow these steps: Create a class that extends JFrame. Create a new ImageIcon. Create a new JLabel and use new JLabel(icon, JLabel.CENTER) to set the ...

Read More »

Create JLabel with ImageIcon and text

In this tutorial we are going to learn how to create a JLabel with ImageIcon and text in it. Using ImageIcons and text in Labels, usually makes them self explanatory to the end user. In short, to create a JLabel with ImageIcon and text, one should follow these steps: Create a class that extends JFrame. Create a new JLabel. Create ...

Read More »

Create JTextField with border

In this tutorial we are going to see how to create a JTextField with border. This is a very simple way to make your component a little bit more interesting. In short, in order to create a new JTextField with border, one should follow these steps: Create a class that extends JFrame. Create a new JTextField. Use BorderFactory.createLineBorder(Color.BLUE, 5) to ...

Read More »

Create JTextField with tooltip

With this example we are going to learn how to create a JTextField with a tootip. Tooltip texts are very useful because they explain to the users how to use a specific component. It’s very easy to set a tooltip text in a JTextField as all you have to do is: Create a class that extends JFrame. Create a new ...

Read More »

Create read-only (non-editable) JTextField

In this example we are going to see how to create read-only JTextFields in Java Desktop Applications. This is very useful in many occasions. In order to create a non editable JTextField, all you have to do is: Create a class that extends JFrame. Create a new JTextField. Use setEditable(false) that sets the specified boolean to indicate whether or not ...

Read More »

Create new JTextField

In this example we are going to see how to create a new JTextField component in a Java Desktop Application. Text fields in general are one of the most common ways for you application to get user input. Using text fields you give the user the ability to provide text input to your app. It’s very easy to create a ...

Read More »