How to set the task switcher icon text? - swt

In my SWT application I want to set the OS task switcher (Alt-Tab) icon and its text caption. Setting the icon works OK, but its caption while Alt-Tab switching among apps is always "SWT", not the String I set it to.
I'm primarily interested in this working in Linux (Ubuntu), but it should work cross-platform as SWT, right?
Display display = new Display();
Shell shell = new Shell(display);
shell.setImage
(new Image (display, loadSvgImage().scaledTo(500, 500)));
shell.setText("SuperApp");

This is the application name. You set it with Display.setAppName which must be called before you create the display:
Display.setAppName("appname");
Display display = new Display();

Related

How to change the image of my java app icon

I have searched for an answer to this question in many places, but none of the answers satisfies what I really want. There are variations of the solution, but they all go along the lines of the code I have below:
MainFrame() {
ImageIcon logo = new ImageIcon(getClass().getResource("file_path"));
setIconImage(logo.getImage);
//the rest of my code
}
public static void main(String[] args){
MainFrame mf = new MainFrame();
mf.pack();
mf.setVisible(true);
}
Basically, load an image or an image icon from a file, and then call the setIconImage() method from the JFrame. This sets the icon image in the title bar of the window, and also the icon image in the task bar when the app is active. But it does not set the icon image of the app icon. In order to show you more clearly what I mean, please see the image I attached, where I circled the three icons. The one with the Java coffee cup is the one I haven't been able to change.
the taskbar, my app, and the window of my app
Can somebody help me set the image of the app icon itself (not just the task bar and title bar icons)?
I was not able change the image of the jar file itself as it sits inside a directory, as shown in the image attached to my question. However, I was able was to set the icon image of the .exe file when I packaged it with jpackage.
Basically, once I was ready to package my app I entered in Command Prompt, making sure to include the --icon option:
jpackage --input C:\app_files\MyApp --name MyApp --main-jar myapp.jar --main-class main.MainThread --icon C:\app_files\MyApp\logo.ico --win-shortcut --dest C:\Users\Desktop\Apps --runtime-image C:\app_files\my_jre
Note: Here, at least for Windows 10, the icon image must be an .ico file.

Custom Icon for Gnome Shell Extension in Top Panel not visible

I try to use a custom SVG for my GNOME shell extension as status icon in top panel. But the custom icon is never shown, just the widget's label text. And I find no error in log output.
When I try to set a build-in icon like "system-search-symbolic" it works, this icon is shown.
This is my code snippet (the SVG is in an "icons" directory of my extension: /home/myusername/.local/share/gnome-shell/extensions/my-widget#my-widgets/icons/timeclock-16x16.svg):
// ...
let widgetBoxLayout = new St.BoxLayout();
let iconPath = `${Me.path}/icons/timeclock-16x16.svg`;
// just for debug if path is correct
log(`${Me.metadata.name}: Icon path=${iconPath}`);
let gicon = Gio.icon_new_for_string(`${iconPath}`);
let icon = new St.Icon({ gicon: gicon, style_class: 'system-status-icon', icon_size: 16 });
// this works for build-in icon:
//let icon = new St.Icon({ icon_name: 'system-search-symbolic', style_class: 'system-status-icon'});
widgetBoxLayout.add(icon);
widgetBoxLayout.add(this.widgetText);
//...
Maybe it's a problem that there is an "#" char in icon path?
But why no error is logged?
What is the correct code to use a custom icon for status panel?
(I have GNOME Shell 3.30.2)
Oh no! This one of these "fight for weeks alone, finally ask the crowd, suddenly know the solution yourself" cases ...
The icon was actually visible but since I use a dark theme and the icon itself is also dark it was not "visible". I inverted the colors of this icon and now I can see the icon next to my text in top panel.
Now I have to find out which icon to use depending on user's theme, but the original issue is solved.
Maybe this answer helps other developer making same stupid error.
You need to use -symbolic icons to allow automatic theme aware re-colorization of the icons. Just change the file name of the icon to timeclock-symbolic.svg, at least this should be your first step if every other aspect is fine.

Set the window of an eclipse e4 application to have based screen size

I followed the below link to open window size as whole screen size, it's working fine for windows os but linux os small size window is opening.
How to open screen sized window in linux os just like windows os?
Window Size link
An alternative way to maximize the window is to do the following in the #ProcessAdditions method of your Life Cycle class (if you have one):
#ProcessAdditions
public void processAdditions(final MApplication app, final EModelService modelService)
{
MWindow window = (MWindow)modelService.find("id of top window", app);
Monitor monitor = Display.getCurrent().getPrimaryMonitor();
Rectangle monitorClientArea = monitor.getClientArea();
window.setX(monitorClientArea.x);
window.setY(monitorClientArea.y);
window.setWidth(monitorClientArea.width);
window.setHeight(monitorClientArea.height);
}

Template10 overwriting Windows Mobile System Header

Doing some testing with Template10 I noticed that with say Hamburger Template that the windows system header/menu/whatever its called at the very top of my Windows Mobile 10 screen goes white and none of the icons (time, battery level, wifi signal etc) are visible when the light theme is used but they appear if I use the black theme.
If I use the Minimal Template then the system menu isn't visible with either the dark or light themes, its just a white band at the top.
Any idea on how to fix this? I'm running a 950XL if that matters.
That is a function of the theming and you need to account for it with the application being "mobile". The so called "System Menu" is the StatusBar
I added this to the OnInitializeAsync in the App.xaml.cs file
if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0))
{
var statusBar = StatusBar.GetForCurrentView();
statusBar.BackgroundOpacity = 1;
}
and that seems to fix the problem. Not sure how portable this is as I'm just targeting Windows Phone for this app so I haven't tried testing other platforms.

SWT: How to “render” a Widget in the background / into an offscreenbuffer

I would very much appreciate your advice and help:
How can I render a SWT Widget/Component in the BACKGROUND (offscreenbuffer?) and get the “painted” pixels that were drawn by the Widget/Component to save them on the harddisk:
What I currently have is:
Display display = new Display();
Shell shell = new Shell(display);
// ...
MyWidgetComponent mwc = new MyWidgetComponent(shell, SWT.BORDER);
shell.open();
Image screenshot = new Image(shell.getDisplay(), shell.getBounds());
GC.copyArea(screenshot, 0, 0);
//...
Problem:
Taking the screenshot itself of the shell/widget works, but it will open a new Window in the Taskbar. That is something I do NOT want.
What I want to achieve is:
I want to run this application completely in the background as a “server application” (for example embed and call this into a servlet). So the MyWidgetComponent should be rendered pixel by pixel completely in the offscreenbuffer and I later I retrieve the pixels and save them to the harddisk or directly return the rendered widget as an image as the result of the servlet-request. (I do not want to popup any windows in a server environment, in case this might be a windows server...).
How can I achieve this. I searched a lot but havent found anything useful.
Thank you very much!!
Jan
I can't answer your question directly, but I have run into a similar problem that I struggled with: taking a screenshot of a Shell or Widget while it is obstructed from view.
Consider, for instance, window A that overlaps window B. A screenshot is made of B using your code:
Image screenshot = new Image(shellB.getDisplay(), shellB.getBounds());
GC.copyArea(screenshot, 0, 0);
My findings revealed that this could be done under Windows Vista, Windows 7 and Mac OS X (although I'm unsure about the latter). However, under Windows XP, Linux with GNOME and Linux with KDE, the screenshot contains a white area where the overlapping window obstructs the view.
I haven't found a solution for this, and I suspect that not only is this behavior platform dependent, but also fairly buggy in SWT.
I'd love to hear that I'm off the mark, though!