I use a JLabel
to view an image in a JFrame
. I load it from a file with an ImageIcon
.
JFrame frame = new JFrame(String);
frame.setLocationByPlatform(true);
frame.setSize(500, 500);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel cpu = new JLabel(new ImageIcon(String));
cpu.setLocation(20, 20);
cpu.setSize(20, 460);
frame.add(cpu);
frame.setVisible(true);
I can't set location and size of the JLabel
because it is done automatically.
I have to manually set these values because I want to truncate the image (vertical progress bar).