JTable: set different cellEditors for cells within a column

I have a table that there could be different class types within the same column, such as Integer, String. How could I invoke different editors based on the class type from the cell? I would appreciate it for your help.
-fs

Thanks very much! However, after editoring, the returned value is always a String. How do I preserve the original class type from the cell? I copied the following codes from somewhere, but can I have just one number editor for both Integer and Double classes?
public class NumberEditor extends DefaultCellEditor{
public NumberEditor(JTextField t) {
super(t);
setClickCountToStart(2);
public Object getCellEditorValue() {
return new Integer/Double((String) delegate.getCellEditorValue());

Similar Messages

  • Jtable: set different icons for  selection/deselection

    Hai,
    I have designed a Jtable, I would like to set a column that has to show different icons when selected/deselected that row. To be specific when you click for the first time, it has to show ICON1 and if you click again it has to show ICON2. Any ideas ???
    Thanks,
    Bala.

    I haven't tried this - so take it with a grain of salt. In your table model, you can define the getColumnClass for the column as ImageIcon.class. In the getValue for that column, you would return the icon.
    In order to get the cell to act like a button .. so you can alternate between the icons ... is a little more complex. There is a book on Advanced Swing by Kim Topley that gets into making cells act like buttons. This part works because I have tried it -- but I wasn't displaying icons.
    good luck!

  • How to set different Icons for Jtreenode

    How to set different Icons for Jtreenode,i want to set icons for jtreenode,not only for leaf,open,closeicon,i hope that each node has a different icon.Thanks!

    you need to check for the node value within a renderer, then assign an icon based on what you expect to get back.
    check out this page. http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html

  • How to create a Platinum,Gold and Silver Customer and how to set different price for a single material based on customer?

    Hi All,
    How to create a Platinum,Gold and Silver Customer and how to set different price for a single material based on customer?
    Assume Material is Pen.
    While creating Sales Order in VA01 how to bring different price for the same material for Platinum,Gold and Silver Customers.
    Kindly help me out.
    Thanks,
    Renjith Jose

    A good place to start is http://www.javaworld.com/javaworld/javatips/jw-javatip34.html
    Also, do a search in this forum on HttpURLConnection. That class allows you to use POST method to send form data to a web server.
    "Hidden" variables are only hidden in HTML. The HTTP that gets POSTed to the web server doesn't distinguish between hidden and not hidden. That is, the content you would write to the HttpURLConnection.getOutputStream() would be something like:
    hidden=1&submit=ok(Of course, the variable names would depend on what the web server was expecting from the form.)
    Also, be sure to set the Content-Type request parameter to "application/x-www-form-urlencoded"

  • How to set different ringtones for contacts ?

    hi!, i got my iphone friday night and ive tried setting different ringtones for different people..but it doesnt work...my normal ringtone is disturbed..when my friends call..i want it to be different for each one of them..i changed it in the contacts...everytime they used to call it would say there name..ever since i put the ringtone in..the phone doesnt recognize the contact?

    Try a reset and/or restore.
    It should work, mine work properly.

  • How can i set different font for different tabs/pages

    I want to set different fonts for different tabs/pages?
    is it possible to do the same? If yes how?
    I can change the fonts under tools>options>contents>advanced. but that changes global settings.
    tried some add ons too- but that too changes the global settings.
    some pages like tweetdeck do not display icons etc properly under custom fonts.
    when i check "allow pages to select their own font" tweetdeck shows up fine but a number of other pages show fonts that are too big or some non standard fonts.
    Is there a way where i can select site default fonts for some sites/tabs, and custom fonts for other sites/tabs?
    otherwise i have to open different sites in different browsers- say i use my custom fonts- which apply globally, and open tweetdeck etc in Internet Explorer or Chrome etc. if i can have all tabs in one window/browser, that would be great.

    It's not a built-in feature to override a page's styles on a tab-by-tab or site-by-site basis, but perhaps someone has created an add-on for this?
    It also is possible to create style rules for particular sites and to apply them using either a userContent.css file or the Stylish extension. The Greasemonkey extension allows you to use JavaScript on a site-by-site basis, which provides further opportunity for customization. But these would take time and lots of testing to develop and perfect (and perfection might not be possible)...
    Regarding size, does the zoom feature help solve that part? In case you aren't familiar with the keyboard and mouse shortcuts for quickly changing the zoom level on a page, this article might be useful: [[Font size and zoom - increase the size of web pages]].

  • A quick way to set different color for certain items in JList?

    is there a quick way of setting different color for certain items in JList?

    Either use HTML strings as the values in your JList (quickest, but may not be the most convenient, especially if your model isn't just text), or create your own ListCellRenderer (e.g. extend DefaultListCellRenderer).
    There is no such thing as "list.setItemForeground(int index, Color c)". You'll have to use one of the methods above.

  • How to set different sounds for different events?

    Hello I had Xiaomi Mi2s before and I could set different sound for every email account I had, for sms, for facebook and so on. How do I do it on my Xperia? Of course that for example SMS is more important then some facebook comment, so I would like to hear what happened because not every time I want to reach my phone.

    Open each app > menu > settings > notification sound > change the sound > done > repeat as needed 
    "I'd rather be hated for who I am, than loved for who I am not." Kurt Cobain (1967-1994)

  • How to set different header for different Standard report page

    How to set different header for different Standard report page

    Hi,
    A easy answer would be use the 'set report header text.vi' but maybe you are talking about something else ?

  • How to set different icons for different windows which is seen in the top left corner?

    Hi
    How to set different icons for different windows which is seen in the top left corner? I know when building exe there is a option to edit icons or add icons and that icon is default for all the windows in the project. But i want different icons for different windows which is possible in VB.
    Is there any way to set icon by calling any dlls.
    Thanks & Regards
    Samuel J
    [email protected]

    Hi Sam,
    no problem. See the attachment.
    Mike
    Attachments:
    TestIcon_LV85.zip ‏44 KB

  • Is there a way to set different volumes for Alerts, phone ringing

    I would like to be able to set different volumes for Alerts, Phone ringing, and incomming mail.  Is this possible?

    No, not at this time. The alerts and phone ringing are all the same. You can provide feedback to Apple if you would like to let them know you would like to see this feature implemented by going to http://www.apple.com/feedback/iphone.html

  • IPhone 4: Setting different ringtones for contacts not working.

    I can't add personal ringtones for each contact. I have followed all contact editing info to the letter, yet I still only get the same one ringtone for each contact (the default ringtone I set for the phone). Setting different ringtones for text messages works fine, but not for telephone contacts. Is this feature broken? Is anyone else having this issue? Thanks.

    It happened to me also when I first added specific ringtones to contacts, but just turning the phone off/on fixed it for me. You can try a reset also if that doesn't work (hold down the home and sleep/wake buttons at the same time until the Apple logo comes up)

  • Can you set different sounds for different incoming email accounts?

    Can you set different sounds for different incoming email accounts? Example, I have multiple email accounts on Mail. I would like the sound for my roadrunner account to be different from my .mac and personal website accounts. Is it possible to configure this or is there a script out there that someone knows about.
    Thanks

    You could choose None in Preferences > General > New Mail Sound and set up a rule for each account in Preferences > Rules as follows:
    If [any/all] of the following conditions are met:
    [Account] [AccountName]
    Perform the following actions:
    [Play Sound] [Sound]
    Problem is, that would cause the sound to be played for junk mail as well — probably not what you want.

  • Setting different resolutions for different displays?, setting different resolutions for different displays?

    Hi,
    I have a 30" dell display that I have used with my MBP. I recently got a MBA and installed mountain lion.  One of the things they inexplicably removed was the ability in the menu bar to set different resolutions for different displays. The only way I can get my Dell Monitor to work is to use mirroring. But I don't want mirroring. I want two separate displays.  In Snow Leopard, the drop down display menu in the menu bar allowed you to pick different resolutions for different displays. Is there any possible way to do that in Mountain Lion?
    Tom

    Yes, assuming that the 8" display has a resolution that the Mac can support. When you open the Displays system preference, you'll get a settings window on each display (as long as the option for Mirroring isn't checked).
    Regards.

  • How to set different font for a particular row in jtables?

    How to set different font size and font type for a particular row in jtable?

    More than enough sample code here:
    [http://java.sun.com/docs/books/tutorial/uiswing/components/table.html]
    db

Maybe you are looking for

  • How export a pie graph(displayed in jspx page) into a PPT file.

    I am trying to export a pie graph(displayed in jspx page) into a PPT file using Apache POI. But I am facing a problem when I calling the below mentioned code from a button. Code: SlideShow slideShow = new SlideShow(); Slide slide = slideShow.createSl

  • Which parts of iWeb will not work on third-party servers?

    Hello, I'm migrating my site so some new parts I would like to know exactly which parts of iWeb will not work on third-party servers.

  • HP Recovery Manager disappeare​d

    Hi, after repair of my Notebook HP ProBook 4530s (problems with hard ddisc) the HP Recovery Manager totaly disappeared, ESC + F11 doesnt work - HPRM simply doesn´t appear. Any idea? I wanted to reinstall my Win7... Thanks very much!

  • How to load this type of record(s).

    Hi, I'm trying to figure out how I can load data where the # of columns ( fields ) in a record could change. e.g. 123, John, Doe, Sunnyvale, CA 234, Jane, Doe, Manager, IBM, Santa Clara, CA Thanks.

  • How to create a draft to a stocktransfer

    Hi, i want to creat a draf to a stock transfer. I know how to create do a sales/purchase document. But i can i do it to a stock trasnfer. Thanks in advance