How is it possible to show contents of JComboBox that aren't in list

I have an application that I have developed over time that requires that I be able to select any item in a JComboBox list and send an actionEvent. In order to do this I set the value of the JComboBox selectedIndex to -1 indicating no selection. This enables me to select the first item in the list and send an actionEvent. The only problem is that the window where the items for the box appears is initially blank. (I don't know if window is the correct term). I would like the ability to place a message in this window such as "Please Select FooBar". Anyone know how to do this?

Maybe something like this:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.plaf.basic.*;
public class ComboBoxPrompt extends JFrame implements ActionListener
     JComboBox comboBox;
     public ComboBoxPrompt()
          String[] items = { "Bryan", "Nick", "Tom" };
          comboBox = new JComboBox( items );
          comboBox.setSelectedIndex(-1);
          comboBox.setRenderer( new PromptRenderer("Select Person") );
          getContentPane().add( comboBox, BorderLayout.NORTH );
          JButton button = new JButton("Clear Selection");
          getContentPane().add( button, BorderLayout.SOUTH );
          button.addActionListener(this);
     public void actionPerformed(ActionEvent e)
          comboBox.setSelectedIndex(-1);
     public static void main(String[] args)
          JFrame frame = new ComboBoxPrompt();
          frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
          frame.pack();
          frame.setLocationRelativeTo( null );
          frame.setVisible( true );
     class PromptRenderer extends BasicComboBoxRenderer
          private String prompt;
          public PromptRenderer(String prompt)
               this.prompt = prompt;
          public Component getListCellRendererComponent(
               JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
               super.getListCellRendererComponent(list,
                    value, index, isSelected, cellHasFocus);
               if (value == null)
                    setText( prompt );
               return this;
}

Similar Messages

  • HT201302 How do I get photos on my camera roll (that aren't on my photo stream) downloaded onto my Mac?

    How do I get photos on my camera roll (that aren't on my photo stream) downloaded to my Mac?

    See:
    iOS: Importing personal photos and videos from iOS devices to your computer

  • How is it possible to control content (also text) so that unsuitable sites cannot be searched?

    Is it possible to use a 'Content Advisor' (like Windows has) within Firefox. Even if I apply and enable certain settings in Internet Options (in Windows), these settings are not upheld by Firefox. Is it possible to get Firefox to uphold the Windows Internet Options settings? If not, is it possible to establish Content settings within Firefox?

    See the [[Parental Controls]] article for a list of ways you can do this.

  • Is it possible to show content from a laptop on an iPad?

    Hi,
    I have an Acer laptop (not mac) with karafun, a karaoke program. Is it possible to use my laptop as a karaoke machine and connect and display the lyrics on an iPad (or display the entire content from my computer on an iPad)?
    The laptop will contain all the songs and the karaoke software, but I want to use an iPad for the singer to watch the lyrics.

    There are apps that allow you to control your computer from the iPad. I have two of them and I find them to be clunky to use but I admit that I could very well be doing something wrong.
    One is called Splashtop.
    http://www.splashtop.com/personal
    Another is Team Viewer.
    http://www.teamviewer.com/en/index.aspx

  • How do I install the additional content file (PRE7_Cont_WWEFGJ) that I downloaded with Premiere Elements?

    Additional content for Premiere Elements 7 can be found by following the link in the article linked to at the end of this FAQ.
    You'll need to log in to your Adobe account, and then you'll see the link to the download on the same page as the Free Trial download.
    John Venediger received this from Tech Support, based on his problem installing additional content (including templates and themes):
    When trying to install/open the contents file (PRE7_Cont_WWEFGJ) you get this message - The setup has detected that premiere elements is currently in use. Please close Premiere Elements, then launch setup again despite the fact that Premiere Elements is not in use.
    To resolve this issue, please perform the following steps:
    1. Right-click the Microsoft® Windows XP® taskbar and select Task
    Manager.
    2. Under the Applications tab of the Task Manager, please ensure Adobe
    Premiere Elements or Photoshop Elements is not running in the background.
    3. If Adobe Premiere Elements or PhotoShop Elements is running in the background, please
    select the application and press End Task.
    4. Next, switch to the Processes tab and look for a process named Adobe
    Premiere Elements.exe. and Photoshop ElementsEditor.exe.
    5. If Adobe Premiere Elements.exe or Photoshop ElementsEditor.exe. is running, please select the process and press End Process.
    If you are still unable to install the additional content, please refer
    to our knowledge base document kb404997. Perform step 8 and try the
    installation again. Continue to step 7 if necessary. To access the
    document, simply copy the following and paste it in the address bar of
    your web browser:
    http://www.adobe.com/cfusion/tdrc/index.cfm?loc=en_us&product=premiere_elements

    Give Adobe Support a call or contact the TCS team at [email protected] - something in your environment is causing the installer to fail (I'd guess).

  • How can i watch a show on apple tv that is on ipad2

    I am wanting to watch a show that i have on the NBC app on my IPAD2 but i want to move it to my apple tv.  Can anyone tell me what i need to do to get this to happen? The apple tv shows that it has access to my apple ID but i am not a computer guy so i don't know what to do here.  Thanks for any help!

    Use AirPlay if the app supports it, not all do.

  • How can I watch tv shows on my iPad that require Adobe Flash?

    I am trying to watch a tv show but you have to have Adobe Flash Player!

    Download the app Photon, it will allow you to play adobe flash. It is a different browser. You use it to go to the site you want to watch and press the lightning rod in the upper right hand corner and it plays flash. I have only used it a few times so I don't know if it works for all adobe flash, but everything I have tried it on has worked. Hope this helps.FYI I have had my iPad for less than a week so I am by no means an expert.

  • How do you set new items within a JComboBox that is within a JTable

    I have searched and searched for the answer to this and do not thing there is one. I have a JTable that has 5 columns. 2 of the columns use DefaultCellRenderers where a JComboBox is used. One of the columns has a value of different football positions. The other has a value of the different players. When a user enters a particular position such as Kickers I want all the Kickers to be showin within the Players JComboBox within the table.
    The problem is that I ONLY want the cell to be modified within that row and column that the position was changed. I have found ways to modify the component but it modifies it for the whole Column. I only want it to be modified for the player cell within the row that the Position was modified. Bottom line is that I just want to modify the JComboBox's components.
    If anyone has had this challenge before please advise.

    I'm not sure I fully understood what you wanted. Does the following little program help you?import javax.swing.*;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableColumnModel;
    import java.awt.*;
    * User: weebib
    * Date: 29 janv. 2005
    * Time: 23:37:57
    public class FootballTable extends JPanel {
         private static final String[] COLUMN_NAMES = {"Position", "Name"};
         private static final String[] POSITIONS = {"goal", "arriere", "milieu", "avant"};
         private static final String[] GOALS = {"goal1", "goal2", "goal3"};
         private static final String[] ARRIERES = {"arriere1", "arriere2", "arriere3"};
         private static final String[] MILIEUX = {"milieu1", "milieu2", "milieu3"};
         private static final String[] AVANTS = {"avant1", "avant2", "avant3"};
         public FootballTable() {
              super(new BorderLayout());
              DefaultTableModel model = new DefaultTableModel(COLUMN_NAMES, 10);
              final JTable table = new JTable(model);
              TableColumnModel columnModel = table.getColumnModel();
              columnModel.getColumn(0).setCellEditor(new DefaultCellEditor(new JComboBox(POSITIONS)));
              columnModel.getColumn(1).setCellEditor(new DefaultCellEditor(new JComboBox()) {
                   public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
                        JComboBox nameComboBox = (JComboBox)super.getTableCellEditorComponent(table, value, isSelected, row, column);
                        Object position = table.getValueAt(row, 0);
                        if (position == null) {
                             nameComboBox.setModel(new DefaultComboBoxModel());
                        } else if (position.equals("goal")) {
                             nameComboBox.setModel(new DefaultComboBoxModel(GOALS));
                        } else if (position.equals("arriere")) {
                             nameComboBox.setModel(new DefaultComboBoxModel(ARRIERES));
                        } else if (position.equals("milieu")) {
                             nameComboBox.setModel(new DefaultComboBoxModel(MILIEUX));
                        } else if (position.equals("avant")) {
                             nameComboBox.setModel(new DefaultComboBoxModel(AVANTS));
                        } else {
                             nameComboBox.setModel(new DefaultComboBoxModel());
                        return nameComboBox;
              add(new JScrollPane(table), BorderLayout.CENTER);
         public static void main(String[] args) {
              try {
                   UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
              } catch (Exception e) {
                   e.printStackTrace();
              final JFrame frame = new JFrame(FootballTable.class.getName());
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setContentPane(new FootballTable());
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        frame.setSize(400, 300);
                        frame.show();
    }Sorry for the French words, I have no idea how they are called in english (and too lazy to search).
    There is another solution. You also can override the table's prepareEditor method and add the relevant code before returning the Component.

  • Can't delete an old email message on my iPhone, it also shows 2 new emails that aren't present

    My iPhone shows 2 new email messages in my inbox but there are none. It also has an email from January of 2012 that I can't delete. I think it may be somehow related to sync'ing with my Exchange account but don't know how to resolve. Anyone else have these problems and discover how to resolve them?
    Many thanks,
    -Paul.

    Turn off the Caps lock. That is considered yelling on the Internet and is very rude, plus it is very difficult to read.
    Who is your email provider? It sounds like you have an IMAP account and it is functioning just the way it is supposed to.

  • Shows e-mail notifications that aren't there

    E-mail notifications show 18000 messages there are no actual messages. How do you clear the notifications. Has occurred since updating to the new iOS 7 system

    Reset the device:
    Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears.
    If that doesn't help, tap Settings > General > Reset > Reset All Settings
    No data is lost due to a reset.

  • How do I change the paragraph format of paragraphs that comes before a list of bullets in one shot

    I receive word documents to convert to indesign files based on a template. I have a set of find and replace queries that do most of the work.
    The manual work I am doing is as follows:
    Changing the paragraph style of all body copy that comes before before bullets
    Changing the paragraph style of last bullets and last subbullets
    What is the simplest way of changing the paragraph styles of every body copy before a list of bullets.
    I am doing more and more of these on a daily basis and would REALLY appreciate some insight.
    Not sure if this can only be done in a script.
    Hope that made sense.
    Thanks.

    spktrm11 wrote: Thanks for the response. I already have established styles. I have a style for "last bullet" and one for "bullets before last". I am trying to do a find and replace so I don't have to individually change the paragraph style of every last bullet.  Document: Paragraph Text. (I want to be able to find this specific paragraph, which would be any paragraph before a bullet and change its style.)
    bullet text
    bullet text
    bullet text
    bullet text (I want to be able to find this specific bullet (bullet text) and replace it with (last bullet))
    Paragraph Text
    I want to avoid having to go through the document to change the style of every last bullet that i find manually. I would like to find (based on it's position - any bullet that is followed by a paragraph)
    Hope this makes more sense
    Have you considered following lists with a "paragraph after list" style, like your paragraph before list style? This might be more appropriate for authors to apply while they create content. The idea is that all list items use a single style, so that rearranging items within the list doesn't require retagging the first or last list paragraph to adjust space or numbering when the first or last item is moved into the list.
    If this is a common problem in your work, you might want to post a feature request for smarter paragraph styles that can detect whether they're first, last, or interior list items, and adjust their properties as appropriate to their position. You can post your request here: wish
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • Dock showing 10 unread mails that aren't there

    I have checked all the folders within both accounts (Gmail & MobileMe) & there are no unopened mails. I have checked both accounts on-line to see if there are any discrepancies. There are no RSS feeds to open no reminders & nothing in the trash but still, the icon on the dock is showing 10 unread e-mails.
    Any advice please???
    Thanks!

    Empty your mail trash, and then rebuild all of your mailboxes using the option in the mail application.

  • My iPhone is showing doubles of songs that aren't doubles on iTunes

    I just recently enabled the "Automatic Downloads" options for my iPod and ever since then all the songs I've purchased have been doubled on my iPhone. When I check iTunes there are no doubles and then when I hit "Display Duplicates" none come up. I checked the purchased playlist on my phone and there are doubles there as well but not on the iTunes purchased playlist. I deleted the ones on my phone and synced it but the doubles are still on my iPod. How do I get rid of these doubles and prevent futures ones?

    You can only import photos that are in the camera roll. Photos in other albums can not be imported that way.

  • How to hide pre-installed apps on iPhone 5s that aren't in use?

    I'd like to remove or hide pre-installed apps that I don't use on my iPhone (also iPad).  For example, I NEVER use the "Stocks"; "Game Center"; "Newstand" or "Weather" apps.  It's pretty annoying that the apps are there taking up screen space (yes, I'm a tad bit OCD'ish). Is it possible to hide or remove the pre-installed apps?  Thank you!

    No. You can group them into a folder and/or move them to another page of the home screen.
    Deleting, Rearranging and Grouping Apps
    (Note that I am affiliated with this site, it contains a donate button, and some pages contain ads).

  • 10.1.3.3 ADF BC:How to get a value of from a LOV that uses a fixed list?

    Hi,
    I create a dropdowlist on a JSP based on a list of items I type in. It's called " fixed List" I think instead of dynamic list which is from a DB table.
    In order to add a valuechangedlistener to the dropdownlist, I need to get the real value of the selected item on the list. I've changed the autosumit to true. Use this line I can get an object of a FaceCtrlListBinding.
    FacesCtrlListBinding TdIter = (FacesCtrlListBinding)bc.get("LandLegalView1Td");
    When value changed, I get only get the new index of the selected item. I tried to use TdIter.getAttributeValue(index) and it returns me null. I also tried TdIter.getAttributeFromRow(index,"Td") and it returns me null, too.
    Could someone share some idea, Please? Thank you very much.
    Regards,
    Annie

    Frank,
    Thank you very much for your reply. I've set "valuePassThrough" property of the dropdownlist to true. In the valueChangeListener, my code looks like this.
    public void TD_valueChangeListener(ValueChangeEvent valueChangeEvent) {
    System.out.println("+++++++++");
    System.out.println("TD_valueChangeListener");
    Number n = null;
    BindingContainer bc = this.getBindings();
    if(bc != null){
    System.out.println("bc is not null");
    //get the selected TD
    FacesCtrlListBinding TdIter = (FacesCtrlListBinding)bc.get("LandLegalView1Td");
    if(TdIter != null){ 
    System.out.println("TdIter is not null");
    if(valueChangeEvent.getNewValue() != null)
    try{n = new Number(valueChangeEvent.getNewValue());}
    catch(Exception e){
    e.getMessage();
    System.out.println("selected TD index="+n);
    //Object td = TdIter.getAttributeFromRow(n.intValue(), "Td");
    Object td = TdIter.getAttribute(n.intValue());
    System.out.println("real value of td=" + td);
    }else{
    System.out.println("TD is null");
    }else{
    System.out.println("TdIter is null");
    My question here is: I tried two ways of getting the real value of the new selected value. One is "Object td = TdIter.getAttributeFromRow(n.intValue(), "Td");". The other is "Object td = TdIter.getAttribute(n.intValue());". None of them give me the new selected value but the old value. Did I do anything wrong?
    Regards,
    Annie

Maybe you are looking for

  • How to do paging in a jsp and how to load data to specific pages

    I want to show 10 rows of data in a one page and remain in other pages. How to do it and let me know how to use tags inside display:table.Because I'm using a display:table tag to show data. Also I have already add requestURI attribute and map it insi

  • Freight/Other Charges to be included for 100% Downpayment Invoice

    Hi Currently in SAP 2007 version, where Freight/Other Charges is concerned, the information will not be copied/drawn to Down Payment Invoice. These charges will only be included in the final A/R Invoice. Even for 100% DownPayment Invoice, the freight

  • Portlet Invalid handle exception -- URGENT PLEASE HELP

    I am deploying our Portal application and portlets in a clustered environment. We have three machines and following weblogic servers are started in each machine: Machine1 - Admin Server Machine2 - Portal1, Portlet1 Machine3 - Portal2, Portlet2 Portle

  • Version XI of Adobe Reader! HELP

    My name is Scarlett with Dr. Indar M Jhamb's office. I have version XI of Adobe Reader and it is not compatible with my EHR system. I was told by customer support with my EHR that we need to uninstall XI and install 9.5. Please help.

  • How long can I take video on iPad mini 16gb?

    i want to be able to record a hockey game on the iPad. I'm freeing up as much space as possible. How much space can a 16gb hold of playing continuously for each period. I have tried whistle to whistle which leaves me with 60+ videos but will continuo