java swing aplication components out of place - java

I have problem with Java application
Components seems to be out of place.
Problems apear only on one computer. Operating system is Windows 10 with anniversary update. I am not sure if it is relevant but one of the other computers i tested application doesnt have anniversary update.
Other thing which makes this computer different is graphic card which is Intel HD graphics 3000 (also not sure if it is relevant).
I am no expert and i feel like child in a fog when i try to solve this issue.
Application is written with java 7 sdk. But it doesnt look good on both jre 7 and 8 on this computer while it looks good with both jre's on every other computer i tested. I am not sure if i am going right direction but setting the environmental variable J2D_D3D_NO_HWCHECK to "true" only made things worse.
I am posting 2 screenshots. First one is from computer where it is misplaced and second one of how it is supposed to look like. It is only one difference of many i can see in application.
UPDATE:
I narrowed down this problem. Gap created in Windows and Windows Classic LookAndFeel is bigger.
try {
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
}
System.out.println(javax.swing.LayoutStyle.getInstance().getPreferredGap(new javax.swing.JLabel(), new javax.swing.JLabel(), javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.SwingConstants.SOUTH, new javax.swing.JPanel()));
Code i provided is giving me 7 or 6 depending on machine. I tried running it on 2 machines with Windows 10 anniversary update both but still i got different results. Changeing LookAndFeel to CrossPlatform fixes problem in this situation. Although it might cause more problems in different panels in application.
I am unable to determine what might be the reason to getting different values from the same class on different computers with the same operating system version.

If anyone is interested i solved this issue
Changing Control Panel > Appearance and Personalisation > Display > Make text and other items larger or smaller
makes default button font size to get bigger. Default button font size is used by windows LookAndFeel to calculate gap size between components in LayoutStyle. LayoutStyle is used as default Layout on all components if one is not set.
Making text larger to 125% caused font size to increase by 2 points. After all math included in Windows LookAndFeel it made default small gap size increase from 6 points to 7.

Related

Swing looks zoomed after upgrading java

I have a old application running a Swing client. I upgraded from Java 7 to 8 a long time ago. The upgrade went fine. Ever since I have wanted to upgrade to Java 9, then 11 and now 13. However this is where I meet problems.
The UI looks fine and as intended with Java 8, but any newer Java version will somehow change the font sizes and maybe components for some reason. I do not have any pictures to show because the application is maintained on a network without internet access because of security reasons. The client looks like most thing is multiplied with a factor of 2.0 or something. It appears as zoomed or maybe something you would create with universal design in mind. Even the splash screen is doubled in size for some reason and that is an image. There are some exeptions. The title text in the windows is the same. Also text on buttons and lables seems to be equal. Icons, images (splash) and text inside textfields/editors is much larger.
I have tried to find a solution for a long time but have not found anything. I am hoping someone else have experienced this problem or at least know what the problem could be.
Holgers comment about OS scaling was the issue. I have a 4K screen with 150% scaling set in the OS. Putting it back to 100% made the Java Swing Client look the same as when running Java 8.
To override add -Dsun.java2d.uiScale=1
Se also https://superuser.com/questions/988379/how-do-i-run-java-apps-upscaled-on-a-high-dpi-display

JavaFX sporadic rendering issue - disappearing buttons / controls

I have a Java/JavaFX application deployed as a native install for Windows and Mac. The bundled runtime is currently 8.121. You can find the installers and the Java code here: George download
I have been using this application in the classroom weekly (with 20 children) for the last 15 months, and right from the start I have seen the following problem:
From time to time, buttons disappear. That is to say, they are simply rendered as a white rectangle, making them effectively almost invisible. Both the background and label/text disappear.
This mainly happens on mouse-over, but then does not correct itself.
The buttons are still there, and clickable.
It only happens sporadically, but it seems to recur on certain machines more than others. Windows 10 now, but used to the same happened on tiny Windows 7 machines previously.
I am not able to reproduce it myself and have never seen it on a Mac, I think.
It now also happens sometimes with other widgets/controls, and even before any user interaction.
Is there some known issue around this?
Has anyone else described something similar?
Might it have something to do with certain minor operating system adjustments?
Any thoughts or ideas would be much appreciated.
Update (2018-11-06)
Just started testing my application in Java 8 in VirtualBox with Windows 10, and I now get the rendering error myself. Hurra!
Looking into the -Dprism.xxx options, I found this article:
http://werner.yellowcouch.org/log/javafx-8-command-line-options/
Testing with -Dprism.threadcheck=true, I get a lot of
"ERROR: PrismPen / FX threads co-running: DIRTY: false" with stack traces.
Setting -Dprism.dirtopts=falsedoes not solve it for me, though.
But running with -Dprism.order=sw does. But this is not a good solution for an application that may do some demanding rendering (Turtle Geometry).
Will keep digging.
I've been having the same issue, I tried updating to Java 10 but the issue remained. I then edited the properties on java.exe and on the 'Compatibility' tab I set 'Override high DPI scaling behavior' to 'System (enhanced)' and the problem seems to have gone away (or at least it hasn't happened again yet).
I observed the same thing: Visually disappearing (but still functional) buttons and other controls (except labels) especially in areas outside the original size of the window after I have resized it manually)
In my case -Dprism.dirtopts=false reduced the problem but also didn't solve it (and was not really a satisfying solution anyway).
Additionally I observed that some TextField controls also showed rendering glitches (looked like the same text was rendered twice with a little offset). That finally put me on the right track:
It turned out to be just a missing Platform.runLater(...) around some calls to TextField.setText(...) (from another thread) for exactly these TextField controls, which was causing this (even for e.g. a Button which is at a totally different place - also in the widget hierarchy).
I know, this is probably not the answer in all cases, but hopefully it helps at least some others facing the same problem (took me a full day to find out).

Parts of the icon in a JOptionPane is missing on my computer regardless of screenresolution but works on other computers

So, as the title states, the icons that appears in JOptionPanes has missing parts on my computer regardless of screenresolution but works on other computers (the image shows using of lower resolution, 1366x768, but I usually have it on 1920x1080)
The other computer I tried on has 1366x768, and it works just fine!
The question is: Why is this happening (or what might be causing this) and how can I make sure this doesn't happen on other computers?
Since the text I have in for example tables appears tiny I was suspecting it might be because of ClearType is turned on, but it didn't help much to turn it off, and the other computer has that turned on too.
The GUI is set to apply the host OS's Look and Feel, but it has been working before (I develop this software from time to time so for me this just happened suddenly without knowing what might have caused it...)
Both computers I've tried this with runs Windows 8.1
I've searched a lot about this but all I could find was how to put custom icons in a JOptionPane dialog, however that is not what I want.
The picture shows the issue with the icon (to the right), while it also shows the screen resolution I tried. Maybe the appearance of the text/icons in the control panel may give a hint of the problem?
So I just did more searching on everything from ClearType to Fonts and just found a solution to my problem!
Apparantly the problem was that my screen had a very high screen resolution so Windows scaled up icons "without telling me".
The slider has the options "smaller" and "larger" (and had also "Medium" when the highest resolution was applied) (Picture #1).
One expect the "smaller" option on the slider to represent scaling of 100% or lower, but when I tick the checkbox for "Let me choose one scaling level for my all displays" (Picture #2), I can see that "Medium (125%)" is equivalent to the "smaller" option on the slider.
Of course this solved my problem with my own java program, but it also solved other problems I had before with icons in Windows UI itself (e.g. non-system icons in the notification-area had bad quality)
Picture #1 Showing the slider with the missleading options
Picture #2 Showing the radio buttons choices with scaling percentage values. Please note: Slider value of "Smaller" in picture one corresponds to "Medium (125%)" in the options of this picture.

java applet using Next-generation plug-in

I have a web application (struts 1.3, Weblogic 10.3.0, Toplink, Oracle) that has a Java applet which isn’t working in the browser (IE7/8) when the Next-Generation Plug-in setting is enabled in the Java control panel but works fine when it’s disabled. The trouble is that this setting is set to disappear in an upcoming Java release meaning that my users would have to keep using Java 1.6_xx on their workstations as they are currently. I have little influence over which version they use because they are all governed by their local IT departments across the country. So, either I have to find a simple fix to allow the Next-Generation setting to work, or we have to look at replacing/rewriting the applet with something else (but would be a last resort due to funding constraints), most likely something AJAX-friendly so as to avoid the need for a plugin. This application is quite old, written around 2001 before AJAX was really around.
The main window has a left, right, and top frame (JSP’s), as well as a center frame which is where the applet is. The applet has a main content area in the middle and a lower panel at the bottom which has some buttons. The buttons tell the content area (which is basically a treegrid) what to do (Save, Copy, change status, etc ). When I press one of the buttons the entire window (surrounding frames plus the applet itself) repeat inside the area where the applet is. It’s like a kaleidoscope or like a repeating fractal pattern kind of thing, or like when you take a picture of yourself in the mirror and you see the room repeated over and over in the mirror. In this case it repeats for each button press and the repeated set gets smaller each time. Weird!!
So, based on my research, the Java Next-Generation plugin works differently by allowing more than one process or thread whereas the classic plugin only uses a single thread. So my suspicion is that a new process is being spawned for each button press. I tried using the “separate_jvm” applet parameter but it made no difference whether it was set to true or false. I don’t see any other applet parameters which seem to be relevant.
Another idea I had is that maybe it’s something to do with the JSP frameset, maybe something like “target=_top” needs to be added somewhere…but I’m not sure how this relates to applet threads if at all.
Anyone have any suggestions, ideas or experiences that might help?
you can use velocity to handle these type of problem and it will also help you for future enhancement also.
The problem is not related to version of IE but rather to version of Java. Below excerpt from letter of certificate provider (they took it from some forum, so direct link to source cannot be provided):
For JDK version higher than 1.6.0 and below 1.6_15, you can just
clear all kinds of cache in web browser, java console and java control
panel. Then it should works fine!
For JDK version between 1.6_15 and 1.6_30, you should disable the "next-generation java" option in java control panel.
For JDK version higher than 1.6_30, you should turn on "next-generation java" option in java control panel.

Printer output from java applet is no longer in vector format?

I have an online sheet music generator that for draws sheet music graphics to an area about 600pixels square. This looks OK on the screen but if printed each note would look blocky.
I always used to be able to print this applet in Internet explorer and get a full vector output of the sheet music so the notes were perfectly rounded, even though they are only a dozen pixels in radius.
Sometime over the summer there must have been an update to java, or (internet explorer?) so my printouts now look horribly blocky. Can anyone think of a reason for this?
I have two versions of my applet, one is double buffered for animation purposes,(which would obviously produce a rasterised image unsuitable for printing) the other draws straight to the screen which is the one which I have been using for printing and has worked fine up until now!
Any help would be much appreciated as I use this program professionally and I have to print several thousand pages from it next week!
Can anyone think of a reason for this?
The obvious answer to that might be 'a change to Java', which can be tested by disabling the later Java version in the Java Control Panel (1), and using the earlier version only.
(1) Java Control Panel
(Close the Java Cache Viewer.)
Navigate to the Java tab of the JCP.
Select the View button
In the Java Runtime Environment Settings dialog, check the earlier versions, uncheck the later ones.
Java Runtime Environment Settings dialog
If that works
Use the earlier version for the 'several thousand pages'.

Categories

Resources