Solved

Image not changing??

Posted on 2004-09-01
4
163 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
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.
Suggested Courses

751 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