Go Back   Java Programming Forums > Java Standard Edition Programming Help > AWT / Java Swing


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 15-02-2010, 04:16 PM
Junior Member
 

Join Date: Jan 2010
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
joachim89 is on a distinguished road
Default Showing a picture in a GUI

I'm doing a lending register inwhich different types of objects (books, cd's and films) are represented. I have a GUI consisting of a AbstractTableModel with an ArrayList in it. The different classes (books etc.) all inherit from a class "Item" I've written. When the objects in the list are shown in teh GUI, I want different pictures to appear in the cells, depending of what kind of objet it is. (the first row of the table should show pictures). The classes all have the method getType, and I've written something like:
PHP Code:
   public Object getValueAt(int rowint col){
                
                
                
Item i ItemsTable.get(row);
        
                switch (
col){
                case 
0: return i.getType();
                case 
1: return i.getTitle();
                case 
2: return i.getOriginator();
                case 
3: return i.getPublicationYear();
                
                case 
5: return i.islended();
                
                default: return 
null
                }
        
        } 
I've seen something like a method (i("randomfilename.jpg") ), and i'm trying to use that method, but how do I make it appear in the GUI? i.e what code would do that(in the switch-statement above)?



Reply With Quote Share this thread on Facebook
Sponsored Links
Java Training from DevelopIntelligence
  #2 (permalink)  
Old 15-02-2010, 06:42 PM
copeg's Avatar
Moderator
 
9 Highscores

Join Date: Oct 2009
Posts: 570
Thanks: 7
Thanked 131 Times in 125 Posts
copeg will become famous soon enoughcopeg will become famous soon enough

I'm feeling Sleepy
Default Re: Showing a picture in a GUI

You first need references to the images (probably in the form of an ImageIcon). You can then define a custom cell renderer for the column in the table you wish to have images in and do the image setting from there. See How to Use Tables (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components) and also google "images in JTable" and you'll pull up a number of examples.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with a program to make a landscape picture noseeds Java Theory & Questions 1 16-12-2009 02:25 AM
Modify Colors in a Picture theuniverse Java Theory & Questions 0 17-10-2009 09:49 PM
Need help with a Picture! Scout Java Theory & Questions 1 12-10-2009 10:33 PM


100 most searched terms
Search Cloud
2 dimensional arraylist java 2d arraylist java actionlistener actionlistener in java addactionlistener addactionlistener java convert double to integer java double format java double to integer in java double to integer java drag en drop programmeren java eclipse shortcut keys exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double in java format double java get mouse position java java 2d arraylist java actionlistener java double format java double formatting java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programming forum java programming forums java programming practice problems java send keystrokes to another application java two dimensional arraylist java.io.ioexception: premature eof java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton action jbutton actionlistener jtextarea font jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream programming mutators and generics smack api two dimensional arraylist two dimensional arraylist java unable to sendviapost to url what is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

All times are GMT. The time now is 01:59 AM.
Powered by vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.