When our application is installed by install4j on a Gnome 3 desktop in Linux, and the application runs: the Application menu, located beside the Activities button which shows the name of the active application is showing "com-install4j-runtime-launcher-UnixLauncher".
Is there a setting in install4j so that our application name shows up properly instead?
As of install4j 7, there is only a hack to achieve this:
Define the compiler variable
sys.ext.windowClass.<nn>=MyAppName
where <nn> is the ID of the launcher and MyAppName must not contain spaces.
This will add a "StartupWMClass" entry to the .desktop file.
For the AWT, the actual window class has to be set to the same value programmatically. This is not possible with an API, but just by using reflection:
String wmClass = ...;
Toolkit toolkit = Toolkit.getDefaultToolkit();
Class<?> toolkitClass = toolkit.getClass();
if (Objects.equals("sun.awt.X11.XToolkit", toolkitClass.getName())) {
//noinspection JavaReflectionMemberAccess
Field awtAppClassName = toolkitClass.getDeclaredField("awtAppClassName");
awtAppClassName.setAccessible(true);
awtAppClassName.set(null, wmClass);
}
Related
I have a JavaFX application that i have ported to Mac. When the application in foreground Command+H suppose to hide the application but for my ported application it is showing version details in a new popup windows.
I wanted to check if my program is suppose to handle Command+H and then hide the application or should it be handled by OS.
On macOS, it was solved by the following.
//
// Disable default popup window.
//
Desktop.getDesktop().setAboutHandler(null);
//
// Hides the stage when Command + H is pressed.
//
scene.getAccelerators().put(
new KeyCodeCombination(KeyCode.H, KeyCombination.META_DOWN), () -> {
primaryStage.setIconified(true);
}
);
I tried to add an overlay plugin. https://vaadin.com/directory/component/overlays
I have a problem with image overlay. Im getting that error:
The type com.vaadin.terminal.Resource cannot be resolved.
It is indirectly referenced from required .class file
problem is with this line:
io.setImage(res);
how can I fix it? I put icon-new.png to the class package folder and added into maven overlays plugin
My code:
final ImageOverlay io = new ImageOverlay(button);
Resource res = new ClassResource(this.getClass(), "../icon-new.png");
io.setImage(res);
io.setComponentAnchor(Alignment.TOP_LEFT); // Top left of the button
io.setOverlayAnchor(Alignment.MIDDLE_CENTER); // Center of the image
io.setClickListener(new OverlayClickListener() {
public void overlayClicked(CustomClickableOverlay overlay) {
Notification.show("ImageOverlay Clicked!");
}
});
layout.addComponent(io);
io.setEnabled(true);
I need to achive that on the button will show up an overlay. If the user clicked on this button and added a new content something like taht show up on the button
That's because it's compatible with Vaadin 6 only as it's indicated in the add-on page:
If you scroll to the comments section, someone is suggesting a fork of the add-on compatible with Vaadin 7, but I could not see anything related to 8:
HI ALL! You can find version 1.1.3 for Vaadin 7.6 here: https://github.com/Haulmont/vaadin-overlays/releases
YURIY ARTAMONOV
Add-ons that are compatible with multiple Vaadin versions, indicate this explicitly, and usually (but not necessarily... dev's choice) have different version numbering, eg: 1.x for Vaadin 6, 2.x For Vaadin 7, 3.x for Vaadin 8, etc:
Either way, clicking on the link for a specific Vaadin version, will select the latest add-on release compatible with it. Or, if you select an add-on release from the drop-down, the Vaadin version compatible with it will be updated accordingly.
Edit after update
You can use a regular button + the predefined BUTTON_ICON_ALIGN_RIGHT Valo style. From the javadoc:
/**
* Align the icon to the right side of the button caption. Can be combined
* with any other Button style.
*/
public static final String BUTTON_ICON_ALIGN_RIGHT = "icon-align-right";
Please note that for the best UI result, I've used 24x24 icons, but depending on your requirements you can tweak your theme for the size you need. Also if you don't have icons and don't want to spend money or time buying or creating your own icons, you can use the existing Vaadin Font Icons (list of icons and matching java enum)
public class ButtonWithIconOnTheRightComponent extends VerticalLayout {
public ButtonWithIconOnTheRightComponent() {
// text filed to specify icon URL
TextField urlField = new TextField("Icon URL", "http://files.softicons.com/download/toolbar-icons/status-icons-set-by-iconleak/png/16x16/30.png");
// button which updates its icon using the URL specified in the text field above
Button button = new Button("Update icon", event -> event.getButton().setIcon(new ExternalResource(urlField.getValue())));
// use valo style to align icon to the right
button.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_RIGHT);
// add components to the UI
addComponents(urlField, button);
setSpacing(true);
}
}
i am trying to make my mac tray icon as suggested in How to make my app icon bounce in the Mac dock
this works fine with pure java applications and swings
but this doesn't works with e4 swt applications , how to make it bounce in this type applications
ref:
pfa of the sample code in the following link
https://bugs.eclipse.org/bugs/show_bug.cgi?id=321949
Application.requestUserAttention works for me in an e4 application (Eclipse 4.3.2 on Mac 10.9.3 with Java 1.8 update 5).
Note: It only does something if the application is not the focused app. With the false parameter there is only one bounce, specify true to make it bounce until the app has focus.
Update:
You can also do this using the SWT Mac specific classes, like this:
private static final long sel_requestUserAttention_ = OS.sel_registerName("requestUserAttention:");
private static final int NSCriticalRequest = 0;
private static final int NSInformationalRequest = 10;
...
NSApplication app = NSApplication.sharedApplication();
OS.objc_msgSend(app.id, sel_requestUserAttention_, NSInformationalRequest);
Use NSInformationalRequest for a single bounce, NSCriticalRequest to bounce until the app receive focus.
Since this is Mac only SWT code you will have to put it in a plugin or fragment with a platform filter in the MANIFEST.MF such as:
Eclipse-PlatformFilter: (& (osgi.ws=cocoa) (osgi.os=macosx) (osgi.arch=x86_64) )
Update:
The above code is for 64 bit SWT on Mac OSX, for 32 bit SWT use
private static final int sel_requestUserAttention_ = OS.sel_registerName("requestUserAttention:");
I inherited a Java app built (I believe) in Eclipse, which I'm modifying using NetBeans 7.4. I want to set the main menu title which shows up on a Mac next to the Apple menu. Right now that name is MainForm, but I want it to change dynamically to the contents of a specific text file (name.txt). I've looked up tons of info on project.properties, ANT scripts, and the like, but I can't find a definitive (and hopefully cross-platform) way to set this main menu title. I have a function in my code that returns this name, so I can use that if there's a place to do it. Thanks in advance!
I have found that in order to set the App Name in Mac OS X Application Menu, and avoid having it show up as the name of your Java project, you have to set it VERY early in the application cycle, using System.setProperty("apple.awt.application.name", "Your App Name");
Here's how I have mine set in my "main" java method that launches the application:
public static void main(String[] args) {
// the application menu for Mac OS X must be set very early in the cycle
String opSysName = System.getProperty("os.name").toLowerCase();
if (opSysName.contains("mac")) {
// to set the name of the app in the Mac App menu:
System.setProperty("apple.awt.application.name", "Your App Name");
//to show the menu bar at the top of the screen:
System.setProperty("apple.laf.useScreenMenuBar", "true");
// to show a more mac-like file dialog box
System.setProperty("apple.awt.fileDialogForDirectories", "true");
//underlying laf:
javax.swing.UIManager.getInstalledLookAndFeels();
// other set-up code goes here
}
else { // not on Mac OS X
// set-up code for non-Mac systems
}
java.awt.EventQueue.invokeLater(() -> {
// run the program
});
}
All Swing/NetBeans-based Java GUI applications seem to have the same WM_CLASS value:
WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "java-lang-Thread"
This parameter can be viewed by issuing xprop command and pointing to the window. The practical purpose of customizing it is to let Mac-like docks (AWN, for example (and, perhaps, Ubuntu's Unity)) distinguish the application windows and group them under the application's pinned launcher icon. For this to work StartupWMClass parameter is to be set accordingly in the .application file in ~/.local/share/applications or /usr/share/applications. Needless to say, AWN (and analogues) get confused in case more than one application uses the same string for WM_CLASS.
This blog post found the field in Toolkit that controls it, named awtAppClassName. It suggests using reflection to modify it:
Toolkit xToolkit = Toolkit.getDefaultToolkit();
java.lang.reflect.Field awtAppClassNameField = xToolkit.getClass().getDeclaredField("awtAppClassName");
awtAppClassNameField.setAccessible(true);
awtAppClassNameField.set(xToolkit, applicationName);