ComboBox issue on Mac applet UI - java

I am new to java swing and applet UI, i have developed a applet to run on mac and windows, The functionality works fine , But the UI in Mac specially when i try to select the items in combo box disfigures the shape (Scrambles) and doesn't show values as in image below. But the same UI works fine in Windows.
i Have tried to add these lines in my code at start of applet still it does not work.
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
and also set the combo boxes opaque using
group.setOpaque(true);
exception occurred is
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at com.apple.laf.AquaMenuPainter.paintSelectedMenuItemBackground(AquaMenuPainter.java:153)
at com.apple.laf.AquaComboBoxRendererInternal.paintComponent(AquaComboBoxRenderer.java:151)
at javax.swing.JComponent.paint(JComponent.java:1054)
at javax.swing.CellRendererPane.paintComponent(CellRendererPane.java:151)
at javax.swing.plaf.basic.BasicListUI.paintCell(BasicListUI.java:227)
at javax.swing.plaf.basic.BasicListUI.paintImpl(BasicListUI.java:317)
at javax.swing.plaf.basic.BasicListUI.paint(BasicListUI.java:240)
Below i have attached the images

Use this code at start of your design it will work fine , I was facing the same issue too.
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
and
UIManager.setLookAndFeel("javax.swing.plaf.metal");
Here is the link for java doc for the issue faced in UI
Java Doc for UI look and feel

Related

Java Swing background one pixel off on MAC

I've created a Java Swing application using the Metal L&F. On Windows, everything looks just fine; but when running the application on a Mac, the background of all the GUI elements seems to be off by one pixel, bleeding out ouf their border to the bootom right.
A checkbox would look like this
I'd love to provide a code example, but i have no clue where the error could lie, as this behaviour occurs all over the application.
I'd appreciate any hint to the cause of this.

Running SWT from a RCP app

Can I run my swt code in a rcp application, when I am running in swt it works fine when trying to do so from rcp app getting:
Exception in thread "main" java.lang.IllegalArgumentException: Argument cannot be null
at org.eclipse.swt.SWT.error(SWT.java:4263)
Eclipse is based on SWT so you can re-use your code. But you cannot reuse your GUI. You have to create a View instead. Try to google for an example, there are many.
You have to define a view in plugin.xml first then you can re-use your SWT code with very little modification.

Java command line application and Systray

I am writing Java application, which is totally GUI-less. It runs in terminal through command line and everything is fine. But now I need to add system tray's icon to it in order to provide some notifications to the user. I tried to use java.awt.SystemTray and java.awt.TrayIcon for that. Although icon almost works (leaving look and feel problem aside), my Mac OS puts new application window to the Dock, as if whole Swing application was run.
So, the question: can my GUI-less java application remain totally invisible but for the tray icon? In Mac OS, Windows and Linux.
Edit: I have tried
System.setProperty("apple.awt.UIElement", "true");
This helped me getting rid of Dock icon, but now
trayIcon.displayMessage("Run!", null, TrayIcon.MessageType.ERROR);
does not display message window.
If it doesn't work with Swing maybe you could try
SWT: Tray Icons and Tooltips.

Java Swing Applet redrawing garbage after mouse event

I'm having issues with my Java Swing Applet. I recently reformatted my computer and reinstalled Eclipse to continue work on my application but I'm having an issue when the screen redraws. Up until now the code has worked 100% (No issues) so I'm certain its an issue with my configuration settings.
The Applet will load fine but after any form of event the screen redraws to something like this:
http://i.imgur.com/vODrs.png
I'm using Eclipse Helios with pretty much a bare bones installation. Its configured to use jre6 but I have no idea why this occurs.
**Please also note that if I embed the applet in an html file it works fine! I however need the applet to run for various debug features I need while working on the AI
Verify that you are constructing the GUI on the event dispatch thread. This is required for Swing applets, too.
Probably because you are missing a super,paintComponent(g) somewhere when you do custom painting.

Substance L&F seems to break when deployed as webstart in java

I think I am having a weird problem:
I 've written a small application in java implementing a JTable to display some results.
I am also using the Substance L&F as my "skin".
Everything seems to be working perfectly.
When I upload the app on my server as webstart, strange things start to happen:
At some point my app generates a little JTable. Every time I mouse over that table,
the app's JButtons or menus or any swing control in general will stop responding. My only option is to close the window and restart the application. Note that the interface seems not to be frozen but like it's lost its focus... if I try to click in any of the table's cells, the UI will still be responsive (not on the swing controls though).
If I get rid of Substance, the problem goes off and everything is working normally again.
If I use another "skin" like JTattoo everything works flawlessly as well.
This only happens when I use the webstart. Does anybody know why..?
or better has any hints on how to fix it?

Categories

Resources