logo on a panel


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: logo on a panel

  1. #1
    Join Date
    Feb 2007
    Posts
    60

    logo on a panel

    Peace..
    and happy new year
    ..can someone help me fo find how can I do to put a logo or a picture on a panel ..i think I have to pass throw the paintComponent methode .. if someone know a tuto or a way to do it..
    thanks

  2. #2
    Join Date
    May 2005
    Location
    Denmark / Copenhagen
    Posts
    15

    ImageIcon

    You can use the swing component imageIcon.
    Try:
    Code:
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
     
    public class ImagesExample {
        public static void main(String[] args) throws MalformedURLException {
            JPanel cp = new JPanel(new GridLayout(0,3));
            addImage(cp, "http://today.java.net/jag/bio/JagHeadshot-small.jpg");
            addImage(cp, "http://today.java.net/jag/Image95-small.jpeg");
            addImage(cp, "http://today.java.net/jag/Image69-small.jpeg");
            addImage(cp, "http://today.java.net/jag/Image56-small.jpeg");
            addImage(cp, "http://today.java.net/jag/Image25-small.jpeg");
            addImage(cp, "http://today.java.net/jag/Image24-small.jpeg");
     
            JFrame f = new JFrame("ImagesExample");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(cp);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        }
     
        static void addImage(JPanel cp, String url) throws MalformedURLException {
            cp.add(new JLabel(new ImageIcon(new URL(url))));
        }
    }
    Last edited by Hack; 12-28-2007 at 01:56 PM. Reason: Added Code Tags

  3. #3
    Join Date
    Feb 2007
    Posts
    60
    great!!it works....THANKS ALOT

Similar Threads

  1. Drag and drop a panel on Ajax TabPanel
    By Raj2007 in forum ASP.NET
    Replies: 0
    Last Post: 07-03-2007, 02:20 AM
  2. Managing a panel control dynamically
    By k_rads in forum ASP.NET
    Replies: 2
    Last Post: 02-17-2006, 07:22 AM
  3. Replies: 1
    Last Post: 06-25-2005, 12:58 AM
  4. Replies: 0
    Last Post: 08-02-2002, 08:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center