Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Image not changing??

Posted on 2004-09-01
4
Medium Priority
?
166 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
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 80 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses

824 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