Jtable(Grid):urgent

Dear All
i m using JTable in my application and using JComboBox as editor for one cell in that table..the problem is that i want that combo to act like the combo acts outside of the table. e.g when i press any key, if the value starting with that key in the combo should be selected.not only this, it should not loose focus untill i press enter or tab key.if there are other values in that combo starting with the same key, they should be selected after pressing that key again.let me explain, if i have "snow" and "sand " in the combo, when i press s after reaching combo, then it should display sand first and when i press s again, it should display snow untill i press tab it should remain in focus so if i want to press anyother key to search from that combo...plz do reply as soon as possible... :|
take care...regards

Check out this [url http://forum.java.sun.com/thread.jsp?forum=57&thread=308478]post.

Similar Messages

  • How to display images in a Jtable cell-Urgent

    Hay all,
    Can anybody tell me that can we display images to JTable' cell,If yes the how do we do that(with some code snippet)? Its very urgent .Plz reply as soon as possible.

    Here is an example
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    class SimpleTableExample extends JFrame
         private     JPanel  topPanel;
         private     JTable  table;
         private     JScrollPane scrollPane;
         public SimpleTableExample()
              setTitle( "Table With Image" );
              setSize( 300, 200 );
              setBackground( Color.gray );
              topPanel = new JPanel();
              topPanel.setLayout( new BorderLayout() );
              getContentPane().add( topPanel );
              // Create columns names
              String columnNames[] = { "Col1", "Col2", "Col3" };
              // Create some data
              Object data[][] =
                   { (ImageIcon) new ImageIcon("User.Gif"), (String) "100", (String)"101" },
                   { (String)"102", (String)"103", (String)"104" },
                   { (String)"105", (String)"106", (String)"107" },
                   { (String)"108", (String)"109", (String)"110" },
              // Create a new table instance
    DefaultTableModel model = new DefaultTableModel(data, columnNames);
              JTable table = new JTable( model )
                   public Class getColumnClass(int column)
                        return getValueAt(0, column).getClass();
              };          // Add the table to a scrolling pane
              scrollPane = new JScrollPane( table );
              topPanel.add( scrollPane, BorderLayout.CENTER );
         public static void main( String args[] )
              SimpleTableExample mainFrame     = new SimpleTableExample();
              mainFrame.setVisible( true );
    }

  • Creating a "4 word phrase" out of selected answers (4 grids of 14 words.. 1 word out each grid)   ----[ Urgent ;) ]

    Okay this is rather simple and "should" be straight forward.
    i have a grid of 14 words (buttons or clickbox)
         1. the user has to choose one of these words.
         2. on clicking on it the smae word is shown in a dedicated area on the screen.
         3. the user then clicks the "next" button on goes to the next page
         4. here he will find another grid of 14 words
             (at the same time the word chosen in previous grid is still show in dedicated area...)
         5. the user selects a second word from the new grid... and this will then show up in the dedicated area next to the previous word
         6. the user then clicks the "next" button on goes to the next page
    ---- and so on .. in the end the user chooses 3 or 4 times a word that each stay visible throughout the selecting out of the 4 grids.
    creating a "phrase" out of the 4 selected words.
    I can of cause create for each option a a page:
    (example:
              grid1_word1, grid2_word1, grid3_word1, grid4_word1
              grid1_word2, grid2_word1, grid3_word1, grid4_word1
              grid1_word3, grid2_word1, grid3_word1, grid4_word1
    but this wil result in 14x14x14x14 = 38.416 pages... and well.. that's a bit much...
    so if someone has a more simple solution for me...
    you can email me at:  [email protected]
    or skype                 : rijswick
    as usual this is something that is very very urgent... (as usual.... so if you can help please dont wait..hahahha )
    thank you in advance
    Jean Marc van Rijswick

    Nederlandstalig vermoed ik? Maar ik zal in het Engels antwoorden. Beetje grappig, heb net deze week gewerkt voor een Nederlands bedrijf, en dat is heel zelden (klanten zitten meestal over de kleine of grote plas).
    I don't understand the work flow where you end up with 38416 slides? And which version do you use? Hope you can use shared actions (best in CP8)?
    Quick analysis, because I'm very busy on an urgent project.
    For the grids: do not use buttons, no click boxes but shape buttons in which you can put text (or a user variable, see further).
    The four words have to end up to be each in a user variable, will label them v_word1, v_word2, v_word3, v_word4. The 'dedicated area' can be a text container, set to display for the rest of the project, in which you insert those user variables in sequence.
    As for the grids, I would reuse a set of 14 variables on each slide: v_1,  v_2.......v_14
    Put those variables in the shape buttons.
    Hoping you are on CP8. Then create shared actions:
    To be used On Enter for the slide, where the vars v_1....v_14 are getting their value for that slide. Those values will be parameters, so that they can be changed for each slide.  Beware: you cannot have twice the same word in that case on one slide.
    To be used for each shape button, will be pretty easy shared action like    Assign v_word1 with v_10    (for the shape button on the 10th place and the first slide). Both variables have to be parameters.
    The first shared action will be used  4 times. The second shared action will be used 4*14=56 times.

  • Cell rendering the JRadioButton in JTable(Most Urgent)

    Hai guys,
    How can I rendering the JRadioButton in JTable ?
    In JTable JCombo,JTexrField,JTextArea to be rendered.But I can't rendering the JRadioButton.
    This is urgent for me.
    By kavi...

    http://onesearch.sun.com/search/onesearch/index.jsp?qt=JRadioButton+in+JTable&qp=siteforumid%3Ajava57&chooseCat=allJava&col=developer-forums&site=dev

  • JTable Grid Lines

    How can I make the Grid Lines (Vertical and Horizontal) of the JTable extend to the bottom even without data? Any suggestion is highly appreciated. Thank you.

    Well, you can add some custom painting yourself. Here is a simple example that might get you started:
    import java.awt.*;
    import javax.swing.*;
    public class TableLines extends JFrame
         JTable table;
         public TableLines()
              table = new JTable(10, 5)
                   public void paintComponent(Graphics g)
                        super.paintComponent(g);
                        g.setColor( Color.RED );
                        int y = getRowHeight(0) - 1;
                        g.drawLine(0, y, getSize().width, y);
              table.setPreferredScrollableViewportSize(table.getPreferredSize());
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );
         public static void main(String[] args)
              TableLines frame = new TableLines();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }

  • How do i add data from database to JTable ! Urgent

    How do i add data from database to the columns of JTable?.

    hi,
    Thanks for ur link. but this is just a part of my application which i am developing user interface in swing package for which i want to know how to show data to user in the table format where by table input data will be from the database. say something like todays activity is shown to the user in table format... So u have any idea of how to do this...

  • Excel view in ALV Grid---- Urgent

    Hi,
    On executing sample porgram BCALV_FULLSCREEN_DEMO, we get ALV grid display. After that, on Clicking "<b>Microsoft Excel View(controlshiftF7)</b>" we are getting blanck Excel screen view instead of the field values.
    I have the same scenario requirement in real time. I want the excel screen with values from ALV Grid.
    Thanks in Advance.
    -Mohan.

    Hi Mohan,
    Try this:
    Download Data in EXCEL from ALV list display
       1) Once you have alv report displayed in the screen.
       2) Click button 'View' ( next to print button) on application toolbar
       3) Select Excel in Place
       4) This will download the same format as of Report
    I hope your ALV have all the Standard functions in Toolbar. If not copy the status from and get the function as mentioned above.
    <b>Program - SAPLSALV
    Status  -  STANDARD</b>
    Reward points if this Helps.
    Manish

  • JTable Grid Lines became very light when changed to JGoodies L&f

    After changing to the JGoodies Look and Feel, my Table Grid Lines (Row and Column Lines) look very light. They are hardly visible. The former orinignal black grid lines looks light as gray. Is there a way to change the color of Grid lines using the Table Renderers or do I need to do anywhere else
    Can you help me in that. I checked through the API but did not find a function to set so..
    Update to my Question_
    I have placed the below statement in my Overridden getTableCellRendererComponent method as the first statement
    table.setGridColor(Color.red);
    The probelm is everytime I switch windows (between my application and any other program), my application is almost dying (GUI gets completely screwed) until I keep clicking on the Application and then it gets back
    Edited by: hemanthjava on Nov 10, 2008 5:25 AM
    Edited by: hemanthjava on Nov 10, 2008 5:27 AM

    I am not expert in these, but please check out the following things and see whether it would solve your issue. (All these changes can be easily rolled back in case I'm wrong :). So make note of what you do)
    As per your httpd.conf, you have chosen an automatic configuration of Apache by OWCI installer itself. What it does is create an imageserver.conf file in a separate directory and these settings will be included in your httpd.conf as you can see in the first line: Include "C:/bea/alui/plumtreeconf/".
    If you check the imageserver.conf in that location, you would find a line like: Alias /imageserver/ "C:/bea/alui/ptimages/imageserver/". This aliases the original path "C:/bea/alui/ptimages/imageserver/" to /imageserver"
    To confirm whether this is done right, check the following:
    1. Acces 'http://<server ip / server name / localhost >/' from your browser
    This should display the Apache home page (as per your httpd.conf, it uses the default port 80; so no port number required)
    2. Access 'http://<server ip>/imageserver/' from your browser
    This should display the directory structure (if its not disabled) inside your 'C:/bea/alui/ptimages/imageserver/' folder. Also confirm that all the subfolders are accessible.
    3. If all the above is right, it means that your imageserver settings are right. Please check your portalconfig.xml for the correct settings: For example, <setting name="HTTPPort"> should be 7001 in your case. If its something else, change it and restart Weblogic for the settings to take effect.
    Hope this helps.

  • Hiding individual row in JTable..Urgent

    Hi,
    I want to hide a row in a JTable when i select hide option from a popupmenu and bring it back when i select show from the menu.I did the same done for columns by setting column width to a minimum value and then restoring it to the initial size.But a bit confused on how to apply it for a row.Can anyone help me out?
    Thanx in advance..
    Pri..

    Thanks Greg. But my problem is when I select an item in the combobox still that column contains combobox in the table which I don't want. I want the combobox to be dissappear as soon as I select an item. This is important for me as I can change the values in the table dynamically by selecting the different panels underneath the dialog which contains this table. So, if user selects an item in the combobox ( without clicking the enter key)and then selects another panel (which loads different data ), then the selected value is set for the second panel not for the first panel(actually value shud be set for first panel).
    And one more problem is samething is happening for even textfield in the table. So, how can I fire editing stopped event before setting the new data. Actually, now when I directly set the data , it is setting the data first and then firing editing stopped event, so it is setting the data for second selected panel.
    Any help is appreciated.
    Thanks.

  • Please Help me in JTable Updating   - URGENT

    Hai all
    am corrently working on a project which am using swing of 1.4
    here in one screen when user enteres data in JTable and clicks submit button i must read the whole Table model of the table and i will insert it to DB.
    in this am gettting problem.
    that is
    when user enters data into jtable and user directly clicks submit i can take all the data iin the table but only on tablce colum value i cant take which is the user currencly entering or modifying the filed.
    if after entering data i need to click any other cell or i need to just click tab to come out of the cell then only i cant take the data from that cell when inserting .
    pls anybody help me how to come out of this problem.
    thanking you
    Rajesh

    Hi
    before you save the changes you have to call stopCellEditing method.

  • Dynamically adding a column to a jtable - simple & urgent

    I am new to using JTables.
    I have read the tutorial and looked at several examples, but I am still confused as to how to add/remove columns and how to add rows to the table.
    I want to have a totally dynamic table which will allow me to add/remove columns and to add rows.
    The table gets the data to be displayed (and the column header values) from an outside object. I thought about writing my own table model.
    Here is the code for my simple table model:
    import javax.swing.table.*;
    import java.util.Vector;
    public class MyTableModel extends AbstractTableModel{
       private Vector columnHeaders;
       private Vector data;
       // simple constructor
       public MyTableModel() {
          columnHeaders = new Vector();
          data = new Vector();  // data is a vector of vectors
       public int getColumnCount() {
          return columnHeaders.size();
       public int getRowCount() {
          if (data.size() == 0) {
              return 0;
          Vector columnData = (Vector)data.elementAt(0);
          return columnData.size();
       public Object getValueAt(int row, int column) {
          Vector columnData = (Vector)data.elementAt(column);
          return columnData.elementAt(row);
       // the method I call for dynamically adding a new empty column
       public void addNewEmptyColumn(String value) {
           columnHeaders.add(value);
           fireTableStructureChanged();
    }Here is how I use the table model with my table
    import javax.swing.*;
    public class Demo extends JFrame{
        private JTable table;
        public Demo() {
            super("test");
            table = new JTable(new MyTableModel());
            getContentPane().add(table);
            pack();
            show();
        public void addColumn(String value) {
            MyTableModel model = (MyTableModel)table.getModel();
            model.addNewEmptyColumn(value);
        public static void main(String[] args) {
            Demo demo = new Demo();
            // here I am trying to add columns...
            demo.addColumn("one");
            demo.addColumn("two");
    }I try to add columns, but nothing happens!!!
    What am I doing wrong?
    I would appreciate if someone who take himself/herslef to be a JTable expert could give me his/her e-mail and this way I won't bother the rest of the world with my stupid JTable questions...
    Sincerely
    Nir

    I have another question.
    What if I want to render the table headers in a certain way.
    I would like to use:
    TableColumn's setHeaderRenderer(TableCellRenderer headerRenderer).
    But in order to do it, I need to get a TableColumn.
    How do I get it from the model?
    I thought about subclassing JTable and overriding:
    public void tableChanged(TableModelEvent e)that function is called everytime I invoke fireTableStructureChanged().
    In that function, I am assuming that a column has been added, however, when I query for JTable's getColumnCount(), I keep getting 0!

  • JTable help Urgent need !!!!!

    hi, I am having problem in getting scrollBar arround my JTextArea that's in a cell of my JTable. If you run the following two files and see the output. The second cell should show me the scrollBars as the whole text is not visible. Please look at the code and see where I am doing wrong. I need to have scrollBars appear arround my individual JTextArea if the text doesn't fit in it. Any help is appreciated...
    /****** This is the main file ***********/
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.border.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MultiLineCellExample extends JFrame
    public MultiLineCellExample()
    super( "Multi-Line Cell Example" );
    DefaultTableModel dm = new DefaultTableModel() {
    public Class getColumnClass(int columnIndex) {
    return String.class;
    dm.setDataVector(new Object[][]{{"2"},{" Error 1Error 1Error 1Error 1Error 1Error 1 Error 1Error 1Error 1Error 1 Error 1Error 1Error 1 Error 1Error 1Error 1Error 1Error 1Error 1 Error 1Error 1Error 1Error 1Error 1Error 1Error 1"}},
    new Object[]{"Following are the Errors"});
    JTable table = new JTable( dm );
    int lines = 2;
    table.setRowHeight( table.getRowHeight() * lines);
    table.setDefaultRenderer(String.class, new TextCellRenderer());
    JScrollPane scroll = new JScrollPane( table );
    getContentPane().add( scroll );
    setSize( 400, 130 );
    setVisible(true);
    public static void main(String[] args)
    MultiLineCellExample frame = new MultiLineCellExample();
    frame.addWindowListener( new WindowAdapter() {
    public void windowClosing( WindowEvent e ) {
    System.exit(0);
    /********* This is the TableCellRenderer file **********/
    /* this code is from
    Copyright (c) 1999 Computer Engineering and Communication Networks Lab (TIK)
    Swiss Federal Institute of Technology (ETH) Zurich, Switzerland
    All rights reserved.
    Permission is hereby granted, without written agreement and without
    license or royalty fees, to use, copy, modify, and distribute this
    software and its documentation for any purpose, provided that the above
    copyright notice and the following two paragraphs appear in all copies
    of this software.
    import javax.swing.*;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.border.*;
    import javax.swing.table.*;
    import java.awt.Component;
    import java.awt.Color;
    import java.io.Serializable;
    public class TextCellRenderer extends JTextArea
    implements TableCellRenderer, Serializable{   //,Scrollable{  Need to implement this too to get scrolls on individual JtextAreas too.
                                                                                    //currently not working, have to look into too.     
    protected static Border noFocusBorder;
    private Color unselectedForeground;
    private Color unselectedBackground;
    public TextCellRenderer() {
         super();
    noFocusBorder = new EmptyBorder(1, 1, 2, 1);
              this.setOpaque(true);
    this.setBorder(noFocusBorder);
    this.setColumns(6);
    this.setWrapStyleWord(true);
              this.setLineWrap(true);
              this.setAutoscrolls(true);
              //this is not working yet, trying to figure out some other way
         JScrollPane pane = new JScrollPane( this,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                      JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    public void setForeground(Color c) {
    super.setForeground(c);
    unselectedForeground = c;
    public void setBackground(Color c) {
    super.setBackground(c);
    unselectedBackground = c;
    public void updateUI() {
    super.updateUI();
              setForeground(null);
              setBackground(null);
    JTable table;
    // implements javax.swing.table.TableCellRenderer
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    this.table = table;
         if (isSelected) {
         super.setForeground(table.getSelectionForeground());
         super.setBackground(table.getSelectionBackground());
         else {
         super.setForeground((unselectedForeground != null) ? unselectedForeground
         : table.getForeground());
         super.setBackground((unselectedBackground != null) ? unselectedBackground
         : table.getBackground());
         setFont(table.getFont());
         if (hasFocus) {
         setBorder( UIManager.getBorder("Table.focusCellHighlightBorder") );
         if (table.isCellEditable(row, column)) {
         super.setForeground( UIManager.getColor("Table.focusCellForeground") );
         super.setBackground( UIManager.getColor("Table.focusCellBackground") );
         } else {
         setBorder(noFocusBorder);
    setValue(value);
         return this;
    protected void setValue(Object value) {
         setText((value == null) ? "" : value.toString());
    if (table != null) {
    String s = getText();
    //count the number of returns
    int ind = 0;
    //add an extra line for the scroll bar if required
    int num = 2;
    do {
    ind = s.indexOf("\n", ind);
    if (ind >= 0) {
    num++;
    ind++;
    } while (ind > 0);
    //set the row height to fit in this cell
    int newHeight = (table.getFont().getSize()*9*num)/5;
    if (table.getRowHeight() < newHeight) {
    table.setRowHeight(newHeight);
    public static class UIResource extends DefaultTableCellRenderer
    implements javax.swing.plaf.UIResource
    public Dimension getPreferredScrollableViewportSize()
              return this.getPreferredSize();      
         public int getScrollableBlockIncrement(Rectangle r, int orietation, int direction)
              return 10;      
         public boolean getScrollableTracksViewportHeight()
              return false;      
         public boolean getScrollableTracksViewportWidth()
              return false;      
         public int getScrollableUnitIncrement(Rectangle r, int orientation, int direction)
              return 10;      

    Hi,
    You want to have a cell in the JTable with a JTextfield and a JScrollBar??? Can you specify and put the source code enclose in   JRG

  • JCheckBox in JTable..urgent!!!

    hello all, can you please help me on how to add JCheckBox on each row of JTable?..the value of JCheckBox is not true or false..i just use it for user options.. please help!!

    Are you trying to create a checkbox in each row or just a few? Let me know.
    Yinka...

  • JTable Problem(Urgent)

    I want to add two components in a Column in JTable (a combobox and radio button in a single column and different rows of the column) How will I do it is it possible to have this in two different CellEditor and Renderers or something else has to be done. Please give the code.

    There are several good examples of table rendering and editing out there. Here are two:
    http://www-106.ibm.com/developerworks/java/library/j-jtable/
    http://www.javapractices.com/Topic168.cjp
    Niether addresses different renderers / editors on a cell by cell basis but I know I have seen an example somewhere. But you should be able to get there from the above examples and using your own JTable implementing:
    public TableCellEditor getCellEditor(int row, int column)
    and
    public TableCellRenderer getCellRenderer(int row, int column)
    IL

  • JTable grid line not appearing

    http://www.instaprint.com/images/helptable.gif
    I've tried...
    making the total width of the columns smaller than the width of the table,
    making the width of the table smaller than the preferred width of the JScrollPane,
    jobTable.getColumnModel().getColumn(0).setPreferredWidth(65);
    jobTable.getColumnModel().getColumn(1).setPreferredWidth(75);
    jobTable.getColumnModel().getColumn(2).setPreferredWidth(70);
    jobTable.getColumnModel().getColumn(3).setPreferredWidth(60);
    (Total Width = 270)
    scrollPane = new JScrollPane(jobTable);
    scrollPane.setPreferredSize(new Dimension(270, 191));
    scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));
    constraints.insets = new Insets(0, 0, 0, 0);
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridbag.setConstraints(scrollPane, constraints);
    displayPanel.add(scrollPane);
    I'm using GridBagLayout, any ideas??

    thanks a lot guys
    i solved that using a post in the forums.
    i just had to write
    super..setBorderPainted(true);
    and it worked
    thanks

Maybe you are looking for

  • Album Ratings

    Every now and then while in iTunes I will notice that some of my songs have an assigned album rating, because I will see the regular song rating and it will have the weird "clear" stars, instead of the regular filled ones. This is really annoying and

  • Maximum characters in file name of links?

    Is there a maximum number of characters in file names of links that InDesign can handle? If so, what is the character count? What about Mac OS X? Thanks in advance.

  • Import local mailboxes from one account to other in the some computer

    I need to import local mailboxes from one account to other in the some computer. I have tried copy/paste from one user/library to other, but mail went crazy with permission and even if I changed them manually now Mail can't save the passwords of the

  • [solved] external hdd no write access

    i am using xfce, in thunar i have no access to delete and create files inside the hdd. my 2 external hdd also using ntfs. normal user no access right do with hdd? only root user? Last edited by Dogs1985 (2013-08-18 19:57:01)

  • Elements 11 - images removed from files.

    I indavertenly hit keys that resulted in the 20 files being emptied.  If I go to Find By Media Type - Photo all the images are brought up, however I am unable to repopulate the files.  How do I do that?