How to change font size on a desktop Java application? - java

I wrote a program, exported it as ".jar" and ran it on a computer other than my developer desktop PC. The problem arose that the entire JFrame on the laptop was smaller and therefore certain texts were replaced with "..." because the component was too small to display it completely. Now the question arises is there the possibility to change my text size dynamically that it is always getting displayed completely?
Edit 1:
My problem is that I first have to get the font size at which my text is replaced by "...".
|that is the code|
|that is how the gui should look (It looks like this on my desktop pc)|
|that is how the gui looks on my laptop|

I have not really a solution to the problem but I know what was the fault. My windows was scaled to 125% so some text dissapeared...

Related

Can I change the JComboBox thumb style?

I am getting a strange discrepancy between the preview and actual running of my jar file with a combo box, and it seems to be a default in both of my laptops which are entirely different design. I included a simple example image (below). The combobox does have 36 entries and should only allow one selection - which is why I prefer to use this element type. My issue is a strange look of the combo box thumb (image on right) in comparison with the typical and expected look shown in the image on the right from viewing the Preview Design in NetBeans. See image
Scouring the internet I cannot find much that shows this discrepancy. Thank you.
This looks like a matter of "Look and Feel":
https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
The Preview Design is using a different default L&F than the environment where you're running the application.

Swing components won't display some characters correctly in Netbeans

I'm using netbeans and can't get to write SOME UTF-8 symbols in JLabel components, for example ȵ and ʮ. The weird thing is that both are printed in console normally while they are shown as 口 in labels.
I don't think it's a font problem because they can display without any problem in eclipse. Note they are using exactly the same font, Tahoma.
Any idea what the problem might be?

JavaFx application font on different os

I've finished my JavaFx application and compiled the program. However, my application uses a font from "Apple". When I opened the application on a different OS like my Windows 10 PC, the font was completely different and the things such as buttons and text labels were too long that is created ellipsis ("..."). Is there a way I can transfer fonts over, or force the application to only run under a certain font?
Thanks in advance.
How about setting your controls (buttons,labels etc) to use a safe font family (as described by ampsoft.net and referenced in this question) in your CSS file?
For example:
.button{
-fx-font-family:'serif';
}
.label{
-fx-font-family:'serif';
}

Animated GIF leads to SplashScreen being null

I know this is probably close to a duplicate of this thread: Animated GIF in Splashscreen
But since it seems unanswered and I can't comment on it or anything I'm sorry to repost this but it would be awesome if someone could give me an answer.
I am making a game and this game takes quite a lot of time to start. Therefore I want to give the user feedback during the loading screen so he knows the application hasn't crashed. That's why I use the SplashScreen API from java 7.
In eclipse, when I run my application using the following configuration in VM Arguments, SplashScreen.getSplashScreen() returns null.
-splash:src/aapplication/Splash.gif
But when I use this configuration, it works fine (I have to files in the same package, one is Splash.png and the other Splash.gif):
-splash:src/aapplication/Splash.png
In a jar file (in MANIFEST.MF), this doesn't work:
SplashScreen-Image: aapplication/Splash.gif
While this does:
SplashScreen-Image: aapplication/Splash.png
My GIF is about 1Mb in size while the PNG is 50kb.
Can anyone explain to me why does the GIF can't even be loaded while the PNG does (I know it's not the path since they have the same)?
Everywhere I looked, it said it should work just as fine as for PNGs.
Thanks for your help!
I think you'll find that the problem comes down to two things...
Using the command line parameter (-splash), Java expects the image to be a file on the file system, whereas the manifest file expects it to be an embedded resource.
Java doesn't seem capable of playing optimised gifs, that is gifs whose frames represent the difference between the last and current frame, instead of a complete image (as far as the splash screen goes).
I tried using
and
The first image failed, but the second worked, the difference, as near as I can tell, is the first is optimised and the second is not...

JasperReports rendering issue

I have a very weird JasperReports rendering problem.
I am using an old version of the free Java Reporting Tool JasperReports: 1.3.4. It's being heavily used on a Swing finance application.
I use JasperViever class to show a preview of the report to print, and my weird problem is that the report shows perfectly fine on some computers while it erases some end-paragraph-lines in others. Paragraph is laid out on the title section and it's four or five lines length. It's being rendered from a string field value.
All computers run the exact same version of the application, compiled report, operating system (Windows XP) and Java Virtual Machine (1.6.0).
What is JasperReports' JasperViewer class using to render the report that is causing different outcomes with different computers? Different installed fonts on Windows? Different Video Cards?
One more thing to it: if I export the report to a PDF or HTML, the problem disappears. The resulted file I generate on every computer shows every single line of the paragraph. So I know the info is there. It's just not being rendered on some computers when I user JasperViewer class. When I print it, I get exactly what JasperViewer class shows on preview.
My reports are displaying loan contracts to print them and hand them to customers. So it's extremely important to have them complete! :-)

Categories