I have a program that outputs the calculation result in a JFrame that contains a JPanel (for extensibility), which contains a JLabel, which displays the said output (which is a string).
I found JLabel's default font to be rather small and hard to read, and so increased the font size and replaced it with a Windows specific font, but didn't think much of it since I checked with a font that doesn't exist, and noticed the program worked fine even if the font doesn't exist. (on both Windows 7 and 8)
However, when run on Ubuntu, the result was a JFrame that was the minimal size.
So now I'm wondering if this is an example of some incompatibility on JVM, or a problem with the copy of Ubuntu it was run on.
The following code should replicate the problem on Ubuntu (or maybe Linux in general) if this is a JVM issue.
import java.awt.BorderLayout;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Main {
public Main(){
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel lbl = new JLabel("SOME TEXT");
lbl.setFont(new Font("font that doesnt exist", Font.PLAIN, 20));
JPanel pnl = new JPanel();
pnl.add(lbl);
frame.add(pnl, BorderLayout.CENTER);
frame.setVisible(true);
frame.pack();
frame.setLocationRelativeTo(null);
}
public static void main (String[] args)
{
Main main = new Main();
}
}
PS the Ubuntu computer is not mine, so I can't exactly test as I want