1 18 package org.apache.batik.util.gui; 19 20 import java.awt.BorderLayout ; 21 import java.awt.Dimension ; 22 import java.awt.event.ActionListener ; 23 import java.net.URL ; 24 import java.util.Locale ; 25 import java.util.MissingResourceException ; 26 import java.util.ResourceBundle ; 27 28 import javax.swing.ImageIcon ; 29 import javax.swing.JComboBox ; 30 import javax.swing.JLabel ; 31 import javax.swing.JPanel ; 32 33 import org.apache.batik.util.gui.resource.ResourceManager; 34 35 41 public class LocationBar extends JPanel { 42 45 protected final static String RESOURCES = 46 "org.apache.batik.util.gui.resources.LocationBar"; 47 48 51 protected static ResourceBundle bundle; 52 53 56 protected static ResourceManager rManager; 57 static { 58 bundle = ResourceBundle.getBundle(RESOURCES, Locale.getDefault()); 59 rManager = new ResourceManager(bundle); 60 } 61 62 65 protected JComboBox comboBox; 66 67 70 public LocationBar() { 71 super(new BorderLayout (5, 5)); 72 JLabel label = new JLabel (rManager.getString("Panel.label")); 73 add("West", label); 74 try { 75 String s = rManager.getString("Panel.icon"); 76 URL url = getClass().getResource(s); 77 if (url != null) { 78 label.setIcon(new ImageIcon (url)); 79 } 80 } catch (MissingResourceException e) { 81 } 82 add("Center", comboBox = new JComboBox ()); 83 comboBox.setEditable(true); 84 } 85 86 89 public void addActionListener(ActionListener listener) { 90 comboBox.addActionListener(listener); 91 } 92 93 96 public String getText() { 97 return (String )comboBox.getEditor().getItem(); 98 } 99 100 103 public void setText(String text) { 104 comboBox.getEditor().setItem(text); 105 } 106 107 110 public void addToHistory(String text) { 111 comboBox.addItem(text); 112 comboBox.setPreferredSize 113 (new Dimension (0, comboBox.getPreferredSize().height)); 114 } 115 } 116 | Popular Tags |