Skip to content
Java library for using the touchbar API on supported macbooks.
Branch: master
Clone or download
Latest commit 3c7155d Jan 22, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.settings
.travis Prepared 0.1.0 release. Apr 19, 2018
JTouchBar.xcodeproj Improved native exception handling. Jan 22, 2019
src Updated file headers. Jan 22, 2019
.classpath Improvements for JNI exception handling. Added separate pom for SWT. … Aug 27, 2018
.gitignore Initial commit. Oct 24, 2017
.project Initial commit. Oct 24, 2017
.travis-deploy.sh Removed calls for pom-swt.xml from deploy script. Jan 21, 2019
.travis-prepare.sh Trying to fix signing errors. Apr 19, 2018
.travis.settings.xml
.travis.yml
CODE_OF_CONDUCT.md
LICENSE Updated file headers. Jan 22, 2019
README.md Update README.md Jan 22, 2019
build.sh Improvements for JNI exception handling. Added separate pom for SWT. … Aug 27, 2018
pom.xml

README.md

Build Status

JTouchBar

Java library for using the touchbar API on supported macbooks.

Support the Developers!

Please take a look at the other stuff the developers are working on and support them in other ways.

Installation & Usage

Maven

<dependency>
	<groupId>com.thizzer.jtouchbar</groupId>
	<artifactId>jtouchbar</artifactId>
	<version>1.0.0</version>
</dependency>

Gradle

implementation group: 'com.thizzer.jtouchbar', name: 'jtouchbar', version: '1.0.0'

Using JTouchBar with Swing

JFrame frame = ...

JTouchBar jTouchBar = new JTouchBar();
jTouchBar.setCustomizationIdentifier("MySwingJavaTouchBar");

// Customize your touchbar

jTouchBar.show(frame);

Using JTouchBar with JavaFX

There is a separate library for adding JavaFX support.

Maven

<dependency>
	<groupId>com.thizzer.jtouchbar</groupId>
	<artifactId>jtouchbar-javafx</artifactId>
	<version>1.0.0</version>
</dependency>

Gradle

implementation group: 'com.thizzer.jtouchbar', name: 'jtouchbar-javafx', version: '1.0.0'

JavaFX Example

Stage stage = ...

JTouchBar jTouchBar = new JTouchBar();
jTouchBar.setCustomizationIdentifier("MyJavaFXJavaTouchBar");

// Customize your touchbar

JTouchBarJavaFX.show(jTouchBar, shell);

Using JTouchBar with LWJGL

long window = ... // LWJGL window

JTouchBar jTouchBar = new JTouchBar();
jTouchBar.setCustomizationIdentifier("MyLWJGLJavaTouchBar");

// Customize your touchbar

jTouchBar.show(
		GLFWNativeCocoa.glfwGetCocoaWindow(window)
	);

Using JTouchBar with SWT

There is a separate library for adding SWT support.

Maven

<dependency>
	<groupId>com.thizzer.jtouchbar</groupId>
	<artifactId>jtouchbar-swt</artifactId>
	<version>1.0.0</version>
</dependency>

Gradle

implementation group: 'com.thizzer.jtouchbar', name: 'jtouchbar-swt', version: '1.0.0'
<dependency>
	<groupId>com.thizzer.jtouchbar</groupId>
	<artifactId>jtouchbar-swt</artifactId>
	<version>1.0.0-SNAPSHOT</version>
</dependency>

SWT Example

Shell shell = ...

JTouchBar jTouchBar = new JTouchBar();
jTouchBar.setCustomizationIdentifier("MySWTJavaTouchBar");

// Customize your touchbar

JTouchBarSWT.show(jTouchBar, shell);

Adding views to your touchbar

// flexible space
jTouchBar.addItem(new TouchBarItem(TouchBarItem.NSTouchBarItemIdentifierFlexibleSpace));

// fixed space
jTouchBar.addItem(new TouchBarItem(TouchBarItem.NSTouchBarItemIdentifierFixedSpaceSmall));

// button
TouchBarButton touchBarButtonImg = new TouchBarButton();
touchBarButtonImg.setTitle("Button 1");
touchBarButtonImg.setAction(new TouchBarViewAction() {
	@Override
	public void onCall( TouchBarView view ) {
		System.out.println("Clicked Button_1.");
	}
});

Image image = new Image();
img.setName(ImageName.NSImageNameTouchBarColorPickerFill);
touchBarButtonImg.setImage(image);

jTouchBar.addItem(new TouchBarItem("Button_1", touchBarButtonImg, true));

// label
TouchBarTextField touchBarTextField = new TouchBarTextField();
touchBarTextField.setStringValue("TextField 1");

jTouchBar.addItem(new TouchBarItem("TextField_1", touchBarTextField, true));

// scrubber
TouchBarScrubber touchBarScrubber = new TouchBarScrubber();
touchBarScrubber.setActionListener(new ScrubberActionListener() {
	@Override
	public void didSelectItemAtIndex(TouchBarScrubber scrubber, long index) {
		System.out.println("Selected Scrubber Index: " + index);
	}
});
touchBarScrubber.setDataSource(new ScrubberDataSource() {
	@Override
	public ScrubberView getViewForIndex(TouchBarScrubber scrubber, long index) {
		if(index == 0) {
			ScrubberTextItemView textItemView = new ScrubberTextItemView();
			textItemView.setIdentifier("ScrubberItem_1");
			textItemView.setStringValue("Scrubber TextItem");
			
			return textItemView;
		}
		else {
			ScrubberImageItemView imageItemView = new ScrubberImageItemView();
			imageItemView.setIdentifier("ScrubberItem_2");
			imageItemView.setImage(new Image(ImageName.NSImageNameTouchBarAlarmTemplate, false));
			imageItemView.setAlignment(ImageAlignment.CENTER);
			
			return imageItemView;
		}
	}
	
	@Override
	public int getNumberOfItems(TouchBarScrubber scrubber) {
		return 2;
	}
});

jTouchBar.addItem(new TouchBarItem("Scrubber_1", touchBarScrubber, true));

License

This project is licensed under the MIT License - see the LICENSE file for details

You can’t perform that action at this time.