Results 1 to 2 of 2
Thread: JCombo Box and Hashmap confusion
- 12-10-2011, 05:54 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 1
- Rep Power
- 0
JCombo Box and Hashmap confusion
Hi, I am trying to create JCombo Box for sorting images by name, title, most recent etc.
First I created Hashmap below is the code which does the sorting orders.
My question is how do I connect this sorting with JComboBox drop down menu. Please can you make this work for me by writing the code.
Java Code:import java.util.*; // For collections. import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; // ************************************************************************* /** An application for handling a simple photo database. * // ************************************************************************* public class RunPhotoApp2 extends JFrame implements ActionListener { /** Creates a simple photo database and displays simple query results. * @param args Command line arguments (ignored). */ public static void main(String[] args) { // Create the two tables. Map<Long,Photo> photos = new HashMap<Long,Photo>(); photos.put(3609624150L,new Photo("Female Rabid Wolf Spider","7539598@N04","08062009")); photos.put(3596720576L,new Photo("Head of Long Legged Fly", "7539598@N04","04062009")); photos.put(4336541668L,new Photo("Bronco", "55186440@N00","06022010")); photos.put(4162213878L,new Photo("P1050942v01-frost-rose", "14884524@N08","05122009")); Map<String,Contributor> contributors = new HashMap<String,Contributor>(); contributors.put("7539598@N04", new Contributor("Thomas Shahan",230)); contributors.put("55186440@N00", new Contributor("Brian DeMeester",610)); contributors.put("14884524@N08", new Contributor("Kilarin",104)); // Create a sorted list of photos. TreeSet<Photo> sortedPhotos = new TreeSet<Photo>(photos.values()); // Do a query and display the results. for (Photo photo : sortedPhotos) { Contributor contributor = contributors.get(photo.getContributorID()); System.out.println(photo.getTitle()+" by "+contributor.getName()); } } }Last edited by JosAH; 12-10-2011 at 07:48 AM. Reason: added [code] ... [/code] tags
-
Re: JCombo Box and Hashmap confusion
Similar Threads
-
AutoSuggest JCombo box
By vsmilejay in forum AWT / SwingReplies: 2Last Post: 09-03-2010, 06:34 AM -
JCombo Box selection index?
By Prajin in forum AWT / SwingReplies: 3Last Post: 07-19-2010, 08:12 PM -
jcombo in jtable
By anilkumar_vist in forum Advanced JavaReplies: 0Last Post: 12-12-2009, 06:47 AM -
Sort jcombo in jtable
By anilkumar_vist in forum Advanced JavaReplies: 1Last Post: 12-11-2009, 05:23 PM -
How to create a new HashMap from a HashMap entries of other methods
By pandeyalok in forum Advanced JavaReplies: 7Last Post: 12-08-2009, 07:17 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks