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.

Similar Messages

  • How do you set a default on the Mac that automatically starts a sentence with a capital letter after a full stop? Thanks guys....

    How do you set a default on the Mac that automatically starts a sentence with a capital letter after a full stop? Thanks guys....

    I use SpellCatcher.  
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD + OCZ Vertex 3 SSD Boot HD 

  • How do You set -noverify in an HTML page that calls an applet

    I have an applet which runs fine from inside JBuilder when I specify a
    -noverify switch in the debugger. (java -noverify myapplet.class)
    Without this switch, I get a verification exception.
    So I need to specify the -noverify switch from inside a webpage so that when the client runs it, he does not get the same exception.
    The question is how do you pass -noverify to JVM from an HTML page that uses <applet> tag and javascript?
    Thanks

    Odd, because I work on an applet that gets built with 1.4. We have 30,000+ clients who use it every day, and I'm sure we don't tell them about setting -noverify switches in their plug-in control panel, and we don't (cuz we can't) set it in the applet (object/embed, actually) tag.
    Of course, I suppose it could be a backwards compatibility issue going from compiling in newer version than it's run in.

  • How do you set new App. Tabs? have followed directions and tabs won't set and stay

    when I try and add new tabs for frequent websites I use the tabs won't save and stay on. also when clicking on + for tabs it's showing a blank screen isn't it suppose to show websites?

    If you click the plus on the tab bar then you open a new tab. New Tabs are blank by default.
    You can use an extension if you want to open a specific page in a new tab.
    * NewTabURL : https://addons.mozilla.org/firefox/addon/newtaburl/
    * New Tab Homepage : https://addons.mozilla.org/firefox/addon/new-tab-homepage/
    *Speed Dial: https://addons.mozilla.org/firefox/addon/4810
    *Fast Dial: https://addons.mozilla.org/firefox/addon/5721

  • How do you set new tabs to open with home page

    when I open a new tab I would like it to open with my home page. Currently I have to click the home icon to go to my home page. The first tab opens with my home page but not extra ones.

    Remove the '''Searchqu''' Malware - see this: <br />
    https://support.mozilla.org/en-US/kb/removing-babylon-searchqu-or-mystart

  • How do you update multiple items in a JSP that are only checked...

    I have list of items in my jsp pages and that are being generated by the following code
    and I want to be able to update multiple records that have a checkbox checked:
    I have a method to update the status and employee name that uses hibernate that takes the taskID
    as a paratmeter to update associated status and comments, but my issue is how to do it with multiple records:
    private void updateTaskList(Long taskId, String status, String comments) {
    TaskList taskList = (TaskList) HibernateUtil.getSessionFactory()
                   .getCurrentSession().load(TaskList.class, personId);
    taskList.setStatus(status);
    taskList.setComment(comments);
    HibernateUtil.getSessionFactory().getCurrentSession().update(taskList);
    HibernateUtil.getSessionFactory().getCurrentSession().save(taskList);
    <table border="0" cellpadding="2" cellspacing="2" width="98%" class="border">     
         <tr align="left">
              <th></th>
              <th>Employee Name</th>
              <th>Status</th>
              <th>Comment</th>
         </tr>
         <%
              List result = (List) request.getAttribute("result");
         %>
         <%
         for (Iterator itr=searchresult.iterator(); itr.hasNext(); )
              com.dao.hibernate.TaskList taskList = (com.dao.hibernate.TaskList)itr.next();
         %>     
         <tr>
              <td> <input type="checkbox" name="taskID" value=""> </td>
              <td>
                   <%=taskList.empName()%> </td>           
              <td>          
                   <select value="Status">
                   <option value="<%=taskList.getStatus()%>"><%=taskList.getStatus()%></option>
                        <option value="New">New</option>
                        <option value="Fixed">Fixed</option>
                        <option value="Closed">Closed</option>
                   </select>          
    </td>
              <td>               
                   <input type="text" name="Comments" MAXLENGTH="20" size="20"
                   value="<%=taskList.getComments()%>"></td>
         </tr>
    <%}%>
    _________________________________________________________________

    org.hibernate.exception.GenericJDBCException: could not load an entity: [com.dao.hibernate.WorkList#2486]
    org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
    org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
    org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
    org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
    org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
    org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
    org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
    org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
    org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
    org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:161)
    org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
    org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:889)
    org.hibernate.impl.SessionImpl.load(SessionImpl.java:808)
    org.hibernate.impl.SessionImpl.load(SessionImpl.java:801)
    com.web.UpdateWorkListAction.execute(Unknown Source)
    org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    before I was running a single update as below and it worked fine:
    session.beginTransaction();
    int taskId = Integer.parseInt(request.getParameter("taskId"));
    String action_taken = request.getParameter("action_taken");
    WorkListErrors worklistErrors
    = (WorkListErrors) session.load(WorkListErrors.class, new Integer(taskId));
    worklistErrors.setAction_taken(action_taken);
    session.update(worklistErrors);
    session.save(worklistErrors);
    session.getTransaction().commit();
    but when I try an an update on multiple records it does work when I have a check box checked :
    session.beginTransaction();
    int taskId = Integer.parseInt(request.getParameter("taskId"));
    String action_taken = request.getParameter("action_taken");
    WorkListErrors worklistErrors
    = (WorkListErrors) session.load(WorkListErrors.class, new Integer(taskId));
    worklistErrors.setAction_taken(action_taken);
    session.update(worklistErrors);
    session.save(worklistErrors);
    session.getTransaction().commit();
    session.beginTransaction();
    String[] tickedTaskId = request.getParameterValues("tickedTaskId");
    String[] taskId = request.getParameterValues("taskId");
    String[] action_taken = request.getParameterValues("action_taken");
    for(int i=0; i<tickedTaskId.length; i++) {
    for(int j = 0; j < taskId.length; j++) {
    if(tickedTaskId.equals(taskId[j])) {
    WorkListErrors worklistErrors
    = (WorkListErrors) session.load(WorkListErrors.class, tickedTaskId[i]);
    worklistErrors.setAction_taken(action_taken[j]);
    session.update(worklistErrors);
    session.save(worklistErrors);
    session.getTransaction().commit();
    /*Close session */
    session.close();

  • How do I set a variable on the main timeline from within a symbol?

    Just getting started with Animate and coming to it from Flash, as may be apparent from my question. How do you set a variable to the main timeline from within a symbol?
    I have 24 pairs of clickable elements, each in their own symbols, and all 24 of those symbols sit inside another symbol. I want all 24 to be able to set the same global variable when clicked. I can't find that this question is addressed anywhere, which makes me think I may be stuck in a Flash mindset and approaching the task in the wrong way. (There are however MANY discussions of how to address objects at different levels in the hierarchy. That's well covered.)
    Relatedly, how do you access a function on the main timeline from within a symbol?
    Adobe should consider putting together a support page (or pages) just for folks migrating form Flash. In the materials I've encountered so far there seems to be a studied effort to refrain from mentioning Flash in any way. I imagine there are a lot of people out there like me who have a deep background in Flash coding, but are just getting started with Animate. We don't need help with most of the basic concepts, but we may still have some pretty basic questions about how to accomplish some things in Animate because our Flash knowledge is getting in the way.

    Hi Bill,
    There are plenty of threads on here about scope, but here's one way to create a global variable:
    // code on Stage.compositionReady
    sym.myGlobalVar = 1;
    Then, anywhere in your project, you can check/set that var like so:
    sym.getComposition().getStage().myGlobalVar = 2;
    And here's one way to create a global function:
    // code on Stage.compositionReady
    sym.myGlobalFunction = function(){
              console.log('myGlobalFunction');
    Then, anywhere in your project, you can call that function like so:
    sym.getComposition().getStage().myGlobalFunction();

  • How do you set up iTunes 10.5 on a new computer?, How do you set up iTunes 10.5 on a new computer?

    I have a new computer  with Windows 7, Outlook and I use iTunes with an Apple iPhone 4 and a iPad. My devices have iOS5. How do you set up iTunes 10.5 on a new computer and sync these devices. I have already downloaded iTunes 10.5 on my computer. Also, I use MobileMe. Thanks for your help. LCP

    Thank you for your response. I have all of my files, etc. and am sitting here on the old computer. I just wasn't sure if I should simply save the iTunes program I am using or insall a new version.
    After I get iTunes onto my new computer do I authorize the new computer before I plug in my IPod or after?
    I'm sorry I didn't point out that I had all of my files available. For some reason, working with iTunes and my iPod make me nervous.
    Thanks again.
    Rustyglo

  • How do you set the number of rows in a spreadsheet, so that even when you drag data in, in writes over those rows instead of adding a new row?

    How do you set the number of rows you want in a spreadsheet, so that even when you drag data in, in writes over those rows instead of adding a new row?

    After the discovery reported above, I filed this report :
    Bug ID# 10073038
    Summary:
    When Numbers is used on a system with decimal comma a csv file may be good AND wrong
    Steps to Reproduce:
    With Numbers v2, you introduced an interesting enhancement.
    In system using the comma as decimal separator, Numbers requires csv files using the semi-colon as values delimiter.
    In fact it’s true if we OPEN the document dragging its icon on Numbers one or thru the open dialog.
    This said.
    (1) Drag and drop a csv built with the 'semi-colon' standard on a table or on a sheet
    (2) Drag and drop a csv built with the 'comma' standard on a table or on a sheet
    Expected Results:
    Every normally constituted user assume that in
    case (1) he will get a perfectly built table
    case (2) he will get every cells of a row in a single cell
    Actual Results:
    In fact you forgot the drag and drop way of use and in
    case (1) every values separated by semi-colon are inserted in a single cell
    case (2) values separated by comma are correctly spread in a table
    isn’t it ridiculous ?
    Regression:
    Except looking in  QuickView to see which is exactly the structure of the file to decide the way we will insert it in a Numbers document, we may use an applescript fair enough to replace the semi-colons by TAB characters
    or
    to replace the commas by TABs and the decimal periods by commas
    Notes:
    While I am on this subject, I wish to make two proposals:
    (1)  It would be fine to format the date according to the ISO format year-mm-dd when you export a Numbers doc to csv.
    Doing that, dates would be imported correctly in every countries.
    At this time, on an English system, you export as mm/dd/year.
    If the doc is open on a system using the format dd/mm/year, the results will be odd.
    On a system using the format dd/mm/year, you export this way and so, if the doc is open on a system using the format mm/dd/year the results are odd too.
    As every localized versions accept the ISO format (at least on entry), using it in the export scheme would give a correct behavior everywhere.
    (2) It would be fine to add the format Tab Separated Values in the Export pane.
    TSV + ISO date format would give documents opening flawlessly everywhere.
    Yvan KOENIG (VALLAURIS, France) dimanche 4 septembre 2011 21:27:41
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • How do you set up repeating alerts for a new voicemail

    how do you set up repeating alerts for a new voicemail

    makblv wrote:
    Please,  Apple, offer this convenience to your loyal customers.  Thank you.
    If you want Apple to know how you feel, Submit your feedback directly using the appropriate link on the Feedback page:
    http://www.apple.com/feedback

  • HT2513 How do you set up reminders if the New Reminders tab is not located under file?

    How do you set up reminders if the New Reminders tab is not located under file? This is a iCal question.

    You set up reminders in the Reminders app.

  • How did you set up your spouses account?

    How did you set up your spouses iOS device, iCloud account, etc?  And what do you recommend? 
    My wife and I have one iMac we share (with two login accounts - so basically two computers), an iPad, and two iPhones.  Since there are certain things we really like to share between accounts (PhotoStream, Find My iPhone, Documents/iCloud Drive), we've shared the same master iCloud account for the last few years.  This has had some drawbacks with things we *don't* want to share, such as we now have to sync our Safari bookmarks, and our keychain/logins for personal websites sometimes overlap, or the "Recent Contacts" shows the last people my wife contacted, not mine, etc. 
    The pros have outweighed the cons, but it has always left me wanting.
    And now that things have changed a bit with iOS 8 and iCloud Drive, Handoff, and Family Plan. I figured now would be a good time to revisit our setup and what would work best for our family.  (Of course, this might be a bit premature, with the looming new Photos App from Apple coming, that might make us buy storage in iCloud, but if you have any forethoughts into that, I'd appreciate hearing them!)

    You may wish to look at alternatives to sharing the items you've been sharing. For example, you could use shared streams instead of my photo stream, in many ways it might be better, that way you share selected items rather than everything. You really don't need to share Find my phone, you can still use find my phone to find a device associated with any account if you sign in with that account, if you want to see where someone is find friends is a much better choice. You can also share links to iWork documents using iCloud document by document.

  • HT1373 how can you set up another iTunes account but keep all your purchases and music from a previous account

    how can you set up another iTunes account but keep all your purchases and music from a previous account

    An iTunes account is something you log into online to buy music.
    An iTunes library is a collection of media and other items (including apps) on your computer.  This is what you see when you open iTunes.
    So, do you mean account or library?  You can set up a new iTunes account but all your purchases made in that account will remain in the old account and cannot be moved.  You can set up a new library by starting iTunes and immediately hold down the option key.

  • How do I use the time capsule to share itunes music between multiple apple devices? Also, is it possible to control the music on one device using another, and how do you set this up?

    How do I use the time capsule to share itunes music between multiple apple devices? Also, is it possible to control the music on one device using another, and how do you set this up?

    unless i'm missing something, i think you got mixed up, this is easy google for walk throughs
    i'm assuming this is the new 3tb tc AC or 'tower' shape, if so, its wifi will run circles around your at&t device
    unplug the at&t box for a minute and plug it back in
    factory reset your tc - unplug it, hold down reset and keep holding while you plug it back in - only release reset when amber light flashes in 10-20s
    connect the tc to your at&t box via eth in the wan port, wait 1 minute, open airport utility look in 'other wifi devices' to setup the tc
    create a new wifi network (give it a different name than your at&t one) and put the tc in bridge mode (it may do this automatically for you, but you should double check) under the 'network' tab
    login to your at&t router and disable wifi on it
    add new clients to the new wifi network, and point your Macs to the time machine for backups

  • How do you Set up a Family Pack sub-account

    how do you Set up a Family Pack sub-account i have purchased a Family Pack account and enter the activation key and i can not find where to set up the sub-account.
    please help
    Denis

    Thanks Shepart
    when i activated the account i ticked the upgrade button, should i have ticked the new account button?
    anyway, when i do what you say (below) there is not a manage "Accounts button" so i went to reactive it again ( for a new account) and is says that the activation key is all ready in use.
    Denis, go to www.mac.com and sign into your account. Click on the word "Account" at the top of the left hand column. You will need to sign in again for security purposes. Once your account settings show up, click on the "Manage Accounts" button and you can take care of everything.
    i think i hit a brick wall !!
    Cheers
    Denis

Maybe you are looking for

  • JDBC 2 RFC Scenario

    Hi Experts,    I have a scenrio JDBC -PI7.1- RFC syn. I got a table in JDBC . First i have to read the table and responce i need to update back to same table.. Jdbc table: H     Delivery no  stutus  cust  addre    XX     XXXXX   XX  XXXXX D     Deliv

  • News:  JDBInsight 2.1EA 40 - XA Transaction Performance Analysis

    JInspired has made available a new Early Access milestone build which previews its XA transaction analysis. JDBInsight is the only product on the market providing true in-depth JDBC resource transaction analysis in a J2EE environment. With its new XA

  • Problems with Yahoo! business email since 3.0

    iPhone 3G My business email, which is served by Yahoo, is not longer able to send messages from the phone. I can receive, but when the phone tries to load the Sent message folder, I get an error. Also, when I send a message, it makes the "sent sound"

  • Dynamic Service Invocation from OSB

    Hi,      I have around 50 services in SOA Suite.  I have to invoke these 50 services dynamically from OSB service based on the input parameters.      For example, The OSB proxy service will receive the input in the below format                       

  • Help with QOS rules while using Actiontec router as a bridge

    In my family's house I have a Verizon Actiontec MI424-WR Rev F currently acting as strictly a modem with WiFi turned off. I connected a Netgear N600 from its LAN port to the Actiontec's LAN port and that is acting as my wireless network. I did this b