Skip to content

JButton AbstractButton

Change the shape of the JButton

RoundButton

Create a JButton with any shape applied, such as a circle or a rounded rectangle.

Create a JButton in the form of an ImageIcon

Section titled “Create a JButton in the form of an ImageIcon”
Create a JButton in the form of an ImageIcon

RoundImageButton

Create a JButton using an arbitrary shape and an image with a transparent color set for that shape.

Right-align icon buttons in JToolBar

ToolBarLayout

Display icon buttons in JToolBar aligned to the right or bottom.

Add a JButton to a JTable cell and delete the row

Section titled “Add a JButton to a JTable cell and delete the row”
Add a JButton to a JTable cell and delete the row

DeleteButtonInCell

Add a JButton to a JTable cell, and when clicked, delete that row.

Section titled “Displaying hyperlinks using JLabel, JButton, and JEditorPane”
Displaying hyperlinks using JLabel, JButton, and JEditorPane

HyperlinkLabel

This code displays a hyperlink using a JLabel, JButton, and JEditorPane, and captures the event that occurs when each is clicked.

Change the text shift amount of the JButton

Section titled “Change the text shift amount of the JButton”
Change the text shift amount of the JButton

TextShiftOffset

This modifies the amount of text shift when a JButton is clicked.

Using OverlayLayout

OverlayLayout

Use OverlayLayout to layer the JButtons.

Place a JButton in the margin of the JTabbedPane

Section titled “Place a JButton in the margin of the JTabbedPane”
Place a JButton in the margin of the JTabbedPane

TabbedPaneWithButton

Create some padding in the tab area of ​​the JTabbedPane, and then place a JButton there using OverlayLayout.

DefaultButton settings

DefaultButton

It obtains its parent JRootPane and sets the default JButton that is launched when the Enter key is pressed to it.

Display JPopupMenu by long-pressing the button

Section titled “Display JPopupMenu by long-pressing the button”
Display JPopupMenu by long-pressing the button

PressAndHoldButton

Add a button to JToolBar that displays JPopupMenu when long-pressed and the selected menu when clicked.

Place a JButton in the EditorComponent of the JComboBox

Section titled “Place a JButton in the EditorComponent of the JComboBox”
Place a JButton in the EditorComponent of the JComboBox

ButtonInComboEditor

Place JButtons, JLabels, etc., into the EditorComponent of the JComboBox.

Drawing a JButton

ButtonPainted

Change the JButton's settings and test how the content area, border, focus, and rollover states are rendered.

Place multiple JButtons in a JTable cell

MultipleButtonsInTableCell

Place multiple clickable JButtons within the cells of a JTable.

Place a JButton inside a JList cell

ButtonsInListCell

Place multiple JButtons within a JList cell.

Add a JButton to the JTableHeader

ButtonInTableHeader

Add a JButton to the JTableHeader that displays a popup menu when clicked.

Make the JButton semi-transparent

TranslucentButton

Create a JButton where everything except the button text is semi-transparent by setting a semi-transparent icon to a JButton with a transparent background.

Create a composite button by layering multiple JButtons using OverlayLayout

Section titled “Create a composite button by layering multiple JButtons using OverlayLayout”
Create a composite button by layering multiple JButtons using OverlayLayout

CompoundButton

We create a composite button by placing four fan-shaped buttons and a circular button into a JPanel with an OverlayLayout applied.

Use a 9-part image for the JButton

NineSliceScalingButton

To ensure that the size of the corners and other parts of the JButton does not change when it is resized, we use an image divided into nine sections.

Place a JButton inside a JMenuItem

ButtonsInMenuItem

Place a JButton inside the JMenuItem to perform cut, copy, and paste operations.

Apply a blur effect to a component using ConvolveOp

Section titled “Apply a blur effect to a component using ConvolveOp”
Apply a blur effect to a component using ConvolveOp

BlurButton

We'll use ConvolveOp to blur out JButtons that are in an unusable state.

Set a timer to repeat the action while the JButton is pressed with the mouse

Section titled “Set a timer to repeat the action while the JButton is pressed with the mouse”
Set a timer to repeat the action while the JButton is pressed with the mouse

AutoRepeatTimer

This sets up a timer that repeatedly executes a specified action while the JButton is pressed with the mouse.

Always display the underline for Mnemonics such as JMenuItem

Section titled “Always display the underline for Mnemonics such as JMenuItem”
Always display the underline for Mnemonics such as JMenuItem

ShowMnemonics

This setting ensures that the underline of the Mnemonic you've set for JMenuItem, JButton, etc., is always displayed when using WindowsLookAndFeel.

Resizing a component using LayoutManager

SizeLayoutManager

Use LayoutManager to change the size and position of components based on their state.

Configure the JButton so that the Action name is not used as its text

Section titled “Configure the JButton so that the Action name is not used as its text”
Configure the JButton so that the Action name is not used as its text

HideActionText

When you set an Action for a JButton, configure it so that the Action name is not used as the JButton's text.

Set a threshold to prevent consecutive clicks on a JButton

Section titled “Set a threshold to prevent consecutive clicks on a JButton”
Set a threshold to prevent consecutive clicks on a JButton

MultiClickThreshhold

To prevent consecutive clicks on a JButton, set the click interval in milliseconds before a subsequent event can occur.

Test whether a key such as Shift is pressed when a JButton is clicked

Section titled “Test whether a key such as Shift is pressed when a JButton is clicked”
Test whether a key such as Shift is pressed when a JButton is clicked

ActionEventModifiers

This tests whether a key such as Shift is pressed simultaneously when a JButton or JMenuItem is clicked.

Let’s compare the differences in behavior between ItemListener and ActionListener

Section titled “Let’s compare the differences in behavior between ItemListener and ActionListener”
Let's compare the differences in behavior between ItemListener and ActionListener

ItemListenerActionListener

This test compares the behavior of ItemListener and ActionListener set in JComboBox, JCheckBox, etc.

The JButton’s hover effect is represented by a circular radial gradient

Section titled “The JButton’s hover effect is represented by a circular radial gradient”
The JButton's hover effect is represented by a circular radial gradient

RadialGradientButton

This will execute a circular radial gradient animation as a hover effect for the JButton.

Arrange JButtons in a keyboard-like layout using GridBagLayout

Section titled “Arrange JButtons in a keyboard-like layout using GridBagLayout”
Arrange JButtons in a keyboard-like layout using GridBagLayout

KeyboardLayout

Use GridBagLayout to arrange the JButtons in a keyboard-like layout.

Set the border color of the button placed in the JToolBar

Section titled “Set the border color of the button placed in the JToolBar”
Set the border color of the button placed in the JToolBar

ButtonToolBarBorder

This sets the border color of JToggleButtons and JButtons placed in the JToolBar.

Change the inner margin of focus drawing using dotted lines for JButtons and similar elements

Section titled “Change the inner margin of focus drawing using dotted lines for JButtons and similar elements”
Change the inner margin of focus drawing using dotted lines for JButtons and similar elements

FocusDashedRectGap

This modifies the inner margin of the focus rectangle drawn by a dotted line in a JButton that uses WindowsLookAndFeel or similar effects.

Set DefaultButton to the JButton that has focus

Section titled “Set DefaultButton to the JButton that has focus”
Set DefaultButton to the JButton that has focus

DefaultButtonFollowsFocus

This setting configures a JButton that is not the DefaultButton to behave as the DefaultButton when it has focus.

Change the background color of the JButton

Section titled “Change the background color of the JButton”
Change the background color of the JButton

ButtonBackgroundColor

This tests how to change the background color of a JButton in a WindowsLookAndFeel environment.

Add a JButton to the JScrollPane that performs a scrollback to the top area

Section titled “Add a JButton to the JScrollPane that performs a scrollback to the top area”
Add a JButton to the JScrollPane that performs a scrollback to the top area

ScrollBackToTopButton

A JLayer is set on the JScrollPane to draw a JButton, and when a click event is captured here, a scrollback to the top area is performed.

Changing the HTML text color when a JButton is disabled

Section titled “Changing the HTML text color when a JButton is disabled”
Changing the HTML text color when a JButton is disabled

ButtonDisabledHtmlText

This overrides the default gray color of the HTML text when the JButton is disabled, using the original HTML text color with a semi-transparent finish.

Get the component that implements ItemSelectable from ItemListener

Section titled “Get the component that implements ItemSelectable from ItemListener”
Get the component that implements ItemSelectable from ItemListener

ItemSelectableSelectedObjects

This test retrieves the source component that implements the ItemSelectable configured with the ItemListener, as well as the selected item, etc.

Use JButton as the cell renderer for JTableHeader

Section titled “Use JButton as the cell renderer for JTableHeader”
Use JButton as the cell renderer for JTableHeader

ButtonTableHeaderRenderer

A JButton is applied as the cell renderer to draw the column cells of the JTableHeader.

Create a tag input component that can be added with a JTextField, displayed with a JLabel, and deleted with a JButton

Section titled “Create a tag input component that can be added with a JTextField, displayed with a JLabel, and deleted with a JButton”
Create a tag input component that can be added with a JTextField, displayed with a JLabel, and deleted with a JButton

TagInputPanel

Create a tag input component that uses a JTextField to add tags, displays them with JLabels, and allows them to be deleted using JButtons.

Create an avatar group with a layout where the left and right JButtons overlap

Section titled “Create an avatar group with a layout where the left and right JButtons overlap”
Create an avatar group with a layout where the left and right JButtons overlap

Avatars

Set circular clipped icons on the JButtons, and create an avatar group where these overlap horizontally by default and expand horizontally on mouseover.

Laying out JButton in a honeycomb pattern

HoneycombHexagonLayout

Create a LayoutManager that sets the JButton shape to a regular hexagon and arranges them in a honeycomb pattern.

Create a split button that can be expanded and collapsed by setting a JLayer on a JButton

Section titled “Create a split button that can be expanded and collapsed by setting a JLayer on a JButton”
Create a split button that can be expanded and collapsed by setting a JLayer on a JButton

ExpandableSplitButton

Create a split button by setting a JLayer on a JButton that controls the start and end of the expand/collapse animation and assigns actions to each clicked area.