473,288 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

Help for displaying an image on my application.

Alright so basically I have a logo named "DirSync.jpg" and I want to display it on the top portion of my application window in a container (either JLabel or JPanel which ever is normally recommended)

Expand|Select|Wrap|Line Numbers
  1. public class MainFrame extends JFrame 
  2. {  
  3.    public MainFrame()
  4.    {
  5.        super();
  6.        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  7.        this.setSize(500,500);
  8.        this.add(getMainPanel());
  9.        this.setVisible(true);
  10.    }
  11.  
  12.    private JPanel getMainPanel()
  13.    {
  14.        JPanel panel = new JPanel();
  15.        panel.setBackground(getLuckyPointColor());
  16.        panel.setLayout(new FlowLayout());
  17.        panel.add(getTitlePanel());
  18.        return panel;
  19.    }
  20. }
I want the getTitlePanel to return me a panel with my image as the background could someone add what I need to do here I've searched around and can't find anything of use... thanks.
Nov 16 '08 #1
1 1281
JosAH
11,448 Expert 8TB
The normal steps are:

1) get the URL of your file/resource (see the Class class);
2) get the ImageIcon given the URL;
3) feed the ImageIcon to a JLabel;
4) put your JLabel in a JPanel somewhere.

Alternatively you can change steps 1) and 2) by getting an ImageIcon given the
name of a file directly.

kind regards,

Jos
Nov 16 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Carolyn Gill | last post by:
It was working fine on the test server. loaded it onto iis6 server after installing php and got everything working (after redirecting it to the correct directory) except for 1 annoying error that I...
14
by: Akbar | last post by:
Hey there, Big-time curiosity issue here... Here's the test code (it's not that long)... it's to display a large number of image links with captions, ideally pulled in from an external file...
8
by: Jon Weston | last post by:
I'm setting up an Access2003 database with pictures. I put a bound ole picture ctrl on a form that's source is the table that contains the pictures and follow ALL the directions for embedding a...
0
by: Marcus Kwok | last post by:
I have written a class (Windows Form) in Managed C++ that accepts an array of image filenames and will display them sequentially. All images will be the same size. I got it to work, but I know...
4
by: John Smith | last post by:
Hello, I'm not sure if these are the appropriate forums for my question since it is closer to about Visual Studio 2005 than it is about .NET framework. So please pardon me and direct me to a...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
14
by: Brad | last post by:
I have a .net 2.0 web application project that creates a pdf file, saves the pdf to disk (crystal reports does this part), and then my code reads the pdf file and writes it to the httpresponse ...
10
by: gnewsgroup | last post by:
I've googled and tried various approaches, but could not resolve this problem. The article at MSDN: Displaying Images in a GridView Column only presents a simple case where all data (including the...
0
navneetkaur
by: navneetkaur | last post by:
hello every1 i have just heard of favicon.i want to implement in my .net application.i have used master pager 'd i am writing <link id="Link1" runat="server" rel="shortcut icon"...
7
by: hsegoy1979 | last post by:
Dear All Iam using file upload control and i want to display image in another pop up page .But image is not displaying in image control iam sending image path thru querystring . here is my code ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.