I unterSmaller auf die Bildgröße in JPanel
jedoch eine GUI als Bild zu erstellen versuchen, wenn ich meine Datei ausführen, die Größe des Bildes bleibt immer noch die ursprüngliche Größe
Wie kann ich die Größe des Bildes reduzieren, so dass ich Text neben hinzufügen kann?
public class HomePage extends JFrame {
public static void main(String[] args) throws IOException {
new HomePage();
}
public HomePage() throws IOException {
this.setTitle("Picture Application");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setBackground(Color.yellow);
BufferedImage myPicture = ImageIO.read(new File("C:\\Users\\seng\\Desktop\\logo.png"));
myPicture.getScaledInstance(10,30,Image.SCALE_SMOOTH);
JLabel picLabel = new JLabel(new ImageIcon(myPicture));
add(picLabel);
this.pack();
this.setVisible(true);
}
}
Von dem, was ich sagen kann, das ist die Antwort, die Sie suchen: http://stackoverflow.com/questions/16343098/resize-a-picture-to -fit-a-jlabel – sahilkmr78