Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
Images doesn't work in eclipse

I already did search on youtube and here and probably it is silly question but I couldn't find how to make it work.

Question is when I add pictures in my eclipse file they look like;

enter image description here

setLayout(new FlowLayout());

    image1 = new ImageIcon(getClass().getResource("view.jpg"));
    label1 = new JLabel(image1);
    add(label1);

    image2 = new ImageIcon(getClass().getResource("view1.jpg"));
    label1 = new JLabel(image2);
    add(label2);    // here my code

Any ideas?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

My got a use method to set icon for label, you can refer

private void loadAvartar(JLabel lbl, String path){
    try {
        BufferedImage image = ImageIO.read(new File(path));

        ImageIcon icon = new ImageIcon(image.getScaledInstance(100, 100, 50));
        lbl.setIcon(icon);
    } catch (IOException | java.lang.NullPointerException e) {
        lbl.setText("Failed");
    }

}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!