Solved

Image not changing??

Posted on 2004-09-01
4
160 Views
Last Modified: 2010-03-31
Hi..

I am doing a small GUI application a movie ticket vending machine..

I have this combo box...Inside the combo box are 3 Movie titles..

I want my program to trigger when a user selects a movie my program should display an image...

To trigger im using a actionListner... Here are my codes below..I do not know why my image doesnt seem to change...

selectTitleList.addActionListener( new ActionListener() {
     public void actionPerformed(ActionEvent evt) {
     
         String pic = selectTitleList.getSelectedItem() + ".jpg";
        displayTextPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 1));
        imageLabel1 = new JLabel(new ImageIcon(pic));
        displayTextPanel.add(imageLabel1);
        bookingDisplayArea = new JTextArea(12,50);
        displayTextPanel.add(bookingDisplayArea);      
                                                     
        }
});

I have tried using repaint() but it doesntwork...Please help me..

Thanks
0
Comment
Question by:segar123
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 20 total points
ID: 11958692
>       imageLabel1 = new JLabel(new ImageIcon(pic));
>        displayTextPanel.add(imageLabel1);
>       bookingDisplayArea = new JTextArea(12,50);
>        displayTextPanel.add(bookingDisplayArea);      

replace those lines with:

       imageLabel1.setIcon(new ImageIcon(pic));
       displayTextPanel.setText("");

0
 
LVL 12

Expert Comment

by:Giant2
ID: 11961102
displayTextPanel is visible in your Frame, Dialog, Panel (or someother Container)?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Checkbox and ListView in Android Layout 4 56
Image decoding from Camera 3 72
github account with ecipse 1 42
java jdbc batch example 8 21
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now