Hey,
I'm playing around with JavaSwing and the normal white title kinda doesnt fit the theme so i disabled it and added a close button that it looks cleaner, is there a way to let the user to be able to drag the whole window in a specific panel?
I disabled it with frame.setUndecorated and just added a JButton, a ActionListener to it and added that to the panel
frame.setUndecorated(true);
JButton closeButton = new JButton("X");
closeButton.setForeground(Color.WHITE);
closeButton.setBackground(Color.BLACK);
closeButton.setFocusPainted(false);
closeButton.setBorder(null);
closeButton.setPreferredSize(new Dimension(50, 50));
closeButton.setFont(customFont.deriveFont(40f));
Also another question, is there a way to "fill" images to a Label / Panel?
I have a whole panel & split it up to a Text Area & a Image Label. The Text Area is at the Bottom used with BorderLayout.SOUTH and the Picture is at CENTER so the text should just fill out the rest that the Text Area is not using.
But if you look at the picture the image is not filled since it does not have the exact resolution it should. Right now im using this to scale the image but that does not feel like a good resolution and wanted to ask if there is a better resolution:
try {
ImageIcon image = new ImageIcon("images/resting.jpg");
Image scaledImage = image.getImage().getScaledInstance(350, 350, Image.SCALE_SMOOTH);
ImageIcon scaledFinish = new ImageIcon(scaledImage);
characterImageLabel.setIcon(scaledFinish);
} catch (Exception e) {
System.out.println("Bild konnte nicht geladen werden.");
}