JSplitButton

Swing implementation of a split button and JavaBean information for using it in an IDE.

License

License

Categories

Categories

Jakarta Server Pages Jakarta EE The Web Tier
GroupId

GroupId

com.alexandriasoftware.swing
ArtifactId

ArtifactId

jsplitbutton
Last Version

Last Version

1.3.1
Release Date

Release Date

Type

Type

jar
Description

Description

JSplitButton
Swing implementation of a split button and JavaBean information for using it in an IDE.
Project URL

Project URL

https://rhwood.github.io/jsplitbutton
Source Code Management

Source Code Management

https://github.com/rhwood/jsplitbutton

Download jsplitbutton

How to add to project

<!-- https://jarcasting.com/artifacts/com.alexandriasoftware.swing/jsplitbutton/ -->
<dependency>
    <groupId>com.alexandriasoftware.swing</groupId>
    <artifactId>jsplitbutton</artifactId>
    <version>1.3.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.alexandriasoftware.swing/jsplitbutton/
implementation 'com.alexandriasoftware.swing:jsplitbutton:1.3.1'
// https://jarcasting.com/artifacts/com.alexandriasoftware.swing/jsplitbutton/
implementation ("com.alexandriasoftware.swing:jsplitbutton:1.3.1")
'com.alexandriasoftware.swing:jsplitbutton:jar:1.3.1'
<dependency org="com.alexandriasoftware.swing" name="jsplitbutton" rev="1.3.1">
  <artifact name="jsplitbutton" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.alexandriasoftware.swing', module='jsplitbutton', version='1.3.1')
)
libraryDependencies += "com.alexandriasoftware.swing" % "jsplitbutton" % "1.3.1"
[com.alexandriasoftware.swing/jsplitbutton "1.3.1"]

Dependencies

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.hamcrest : hamcrest-core jar 1.3

Project Modules

There are no modules declared in this project.

JSplitButton

A split button control for Java Swing.

Maven Central Javadocs Build Status Coverage Status Maintainability Test Coverage

A simple implementation of the split button control for Java Swing. This control raises two events:

  • buttonClicked(ActionEvent e)
  • splitButtonClicked(ActionEvent e)

The buttonClicked event is raised when the main, or left, part of the button is clicked, which will not trigger the popup menu. The splitButtonClicked event is raised when the split, or right, part of the button is clicked and displays a popup menu.

To handle these events you need a listener that implements:

  • SplitButtonActionListener to handle both events in a single listener
  • ButtonClickedActionListener to handle just buttonClicked
  • SplitButtonClickedActionListener to handle just splitButtonClicked

See also http://naveedmurtuza.blogspot.ch/2010/11/jsplitbutton.html

Screenshots

alt tag

alt tag

alt tag

Using the Control

//first instantiate the control
JSplitButton splitButton = new JSplitButton();
//register for listener
splitButton.addSplitButtonActionListener(new SplitButtonActionListener() {

    public void buttonClicked(ActionEvent e) {
        System.out.println("Button Clicked");
    }

    public void splitButtonClicked(ActionEvent e) {
        System.out.println("Split Part Clicked");
    }
});
//add popup menu
splitButton.add(popupMenu);
//add this control to panel
panel.add(splitButton);

or (using Java 8 lambda expressions):

//first instantiate the control
JSplitButton splitButton = new JSplitButton();
//register for button listener
splitButton.addButtonClickedActionListener((ActionEvent e) -> {
    System.out.println("Button Clicked");
});
//register for split button listener
splitButton.addSplitButtonClickedActionListener((ActionEvent e) -> {
    System.out.println("Split Part Clicked");
});
//add popup menu
splitButton.add(popupMenu);
//add this control to panel
panel.add(splitButton);

Prior History

Versions

Version
1.3.1
1.3.0