Search Results

Search found 159 results on 7 pages for 'jtable'.

Page 3/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • JTable horizontal scrollbar in Java

    - by Mr CooL
    Is there any way to enable horizontal scrollbar whenever necessary?? The situation was as such: I've a JTable on Netbeans, one of the cells, stored a long length of data. Hence, I need to have horizontal scrollbar. Anyone has idea on this? THanks in advance for any helps..

    Read the article

  • Java Swing jtable cell editor doubles E numbers

    - by Michael
    Hi I an issue with editors in a JTable. I have a column which displays data as 26,687,489,800.00 ie: Double. When the user clicks the cell to edit the data it is displayed as -2.66874908E10. I want the data to be edited as it appears when it is displayed ie: 26,687,489,800.00 - without the E10 etc... Any help would be appreciated. Mike

    Read the article

  • JTable .. colour of selected row

    - by dimitar
    Hello pip`s, I have a JTable in Java that has a custom dataMOdel and custom renderer. Now when i select some cell it has a dark blue border around it. I want the selected row to be all highlighted in some colour. How to do that?

    Read the article

  • Set Jtable/Column Renderer for booleans

    - by twodayslate
    Right now my Boolean values for my JTable display as JCheckBoxes. This would normally be fine but I would like to display them as either an alternative String or image. I can get them to display as true/false but I would like to display them as a checkmark (?) if true and nothing if false. Possibly an image but lets do a String first...

    Read the article

  • jRuby's Float to represent in JTable's cell

    - by guai
    Hello. I need to represent floats in jTable formatted. When I do tbl.model.add_row [obj, 1.3524632478].to_java, obj is represented as it's to_s method's return value, but float do not. Overriding float's to_s method does nothing. I want floats to be formatted like this class Float def to_s sprintf("%.2f", self) end end in all my tables.

    Read the article

  • get value from jtable

    - by jouzef19
    hi I have a jtable and I want the user to fill its cells then i get what he wrote! the problem is when i try getValueAt(row index,col index ) the programe give me null , and i am sure that the cell i choose has a value .

    Read the article

  • Java Swing - Adding a row # column (row header) to a JTable

    - by llm
    I have data from a database loaded into a JTable through a custom table model. I want to have a column (should be the first column) which simply shows the display row number (i.e. it is not tied to any data (or sorting) but is simply the row number on the screen starting at 1). These "row headers" should be grayed out like the row headers. Any idea how to do this? Thanks

    Read the article

  • Java Swing - Adding a row # column to a JTable

    - by llm
    I have data from a database loaded into a JTable through a custom table model. I want to have a column (should be the first column) which simply shows the display row number (i.e. it is not tied to any data (or sorting) but is simply the row number on the screen starting at 1). These "column headers" should be grayed out like the row headers. Any idea how to do this? Thanks

    Read the article

  • java swing, simulate JTable terminateEditOnFocusLost behaviour

    - by blow
    Hi all, i'm using putClientProperty("terminateEditOnFocusLost", Boolean); to make jtable end editing and clear current selected rows when it lose focus or when simply click over an other GUI component. This is very useful, but with "terminateEditOnFocusLost" there are some strange behaviours if it is used with editCellAt and changeSelection. There are also some undesiderable TableModelEvents fired for some fake table updates. So, im looking for an hack to simulate "terminateEditOnFocusLost without using it, is this possibile? Thanks all.

    Read the article

  • Adding Columns to JTable dynamically

    - by martilyo
    I have an empty JTable, absolutely nothing in it. I need to dynamically generate its table columns in a certain way. A simplified version for the code I have for my attempt: @Action public void AddCol() { for (int i = 0; i < 10; i++) { TableColumn c = new TableColumn(i); c.setHeaderValue(getColNam(i)); table.getColumnModel().addColumn(c); } } But I'm getting an Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0 error. What am I doing wrong?

    Read the article

  • JTable row filters updates

    - by Jeff Storey
    Is there a way to tell a JTable's row filter that it should update itself to display the filtered data? I'm currently using the fireTableDataChanged method in the AbstractTableModel but the underlying data for the table isn't actually changing, so this seems like it might be wasteful. The way my filter works is to check if data in the table is in some other list and only display it if it is in that list. So that other list changed and I need to tell the filter to refresh itself. Is fireTableDataChanged the correct way to do this? thanks, Jeff

    Read the article

  • JTable.setRowHeight prevents me from adding more rows

    - by Brent Parker
    I'm working on a pretty simple Java app in order to learn more about JTables, TableModels, and custom cell renderers. The table is a simple table with 8 columns only with text in them. When you click on an "add" button, a dialog pops up and lets you enter the data for the columns. Now to my problem. One of the columns (the last one) should allow for multiple lines of text. I'm already putting HTML into the field, but it is not wrapping. I did some research and looked into JTable#setRowHeight(). However, once I use setRowHeight, I can no longer add rows to the table. The data is put into the table model, but it does not show in the table. If I remove the setRowHeight line, then it adds data just fine. Is there another step to adding data to my data model that I'm missing? Thanks a lot!

    Read the article

  • JTable custom cell renderer to create row header

    - by hhj
    Can somebody please explain how I would create row headers? I already have the data and header texts set in the JTable: all I want to know is how I can use a cell renderer to take that first column (i.e. the row header column) and make it look like the column headers (i.e. the first row). Right now its background is white, so it looks like regular data. I want it to appear gray (or non-opaque I guess??). Oh and it should also not be selectable. Thanks.

    Read the article

  • How to set specific column settings in JTable?

    - by HansDampf
    How can I make my JTable show specific stuff for each column? Can I use an Object for more than one column? I want to have a column showing the date (dd.mm.yyyy) and another to show the time (hh:mm) but as I have it now it only shows the String representation of the Date object as a whole. public class AppointmentTableModel extends AbstractTableModel { ... @Override public Object getValueAt(int rowIndex, int columnIndex) { return appointments.get(rowIndex).getByColumn(columnIndex); } } public class Appointment { ... public Object getByColumn(int columnIndex) { switch (columnIndex) { case 0: return date; case 1: return date; case 2: return sample; case 3: return sample; case 4: return history; case 5: return comment; } return null; } }

    Read the article

  • Initial state of autoCreateRowSorter in Swing JTable

    - by Nazgulled
    I have this JTable on my Swing app with the autoCreateRowSorter enabled. My table only has 3 columns, two strings and one int, it works well for all of them when I click the column headers. However, I'm looking for way to do it programatically. I wanted to set the "initial state" for this table. With the Windows look and feel, the column header (when sorted) has a little arrow showing the sort order. But at startup that doesn't show, I have to do one initial click. How can I do that by code?

    Read the article

  • Invisible JFrame/JTable how much faster ?

    - by chacko
    I have a swing app. with a jframe with lots of internal frames containing large JTable. Those jtables get updated continuously so there is lots of repainting going on. in some circumstances I can simply keep the JFrame invisible. (frame.setVisible(false)) I was wondering if anybody knows if I will gain something in terms of performance (something considerable or not) such as 50% gain or you would only get 2% gain... and maybe some sort of explaination on what to expect. thanks

    Read the article

  • Column moved [finished] event in JTable

    - by chown
    How should I detect that column moved action is finished in JTable? I've added columnModeListener to my column model but the problem is columnMoved method is called every time a column moves (by certain pixels). I don't want this behavior. I just want to detect when the column dragging is finished. columnModel.addColumnModelListener(new TableColumnModelListener() { public void columnAdded(TableColumnModelEvent e) { } public void columnRemoved(TableColumnModelEvent e) { } public void columnMoved(TableColumnModelEvent e) { //this is called so many times //I don't want this, but something like column moved finished event System.out.println("Moved "+e.getFromIndex()+", "+e.getToIndex()); } public void columnMarginChanged(ChangeEvent e) { } public void columnSelectionChanged(ListSelectionEvent e) { } }); I hope it is clear what I'm looking for. Thanks.

    Read the article

  • create TableModel and populate jTable dynamically

    - by Julia
    Hi all! I want to store the results of reading lucene index into jTable, so that I can make it sortable by different columns. From index I am reading terms with different measures of their frequencies. Table columns are these : [string term][int absFrequency][int docFrequency][double invFrequency] So i in AbstractTableModel I can define column names, but i dont know how to get the Object[][]data with results from the following method: public static void FrequencyMap(Directory indexDir) throws Exception { List<Object>redoviLista = new ArrayList<Object>(); //final Map<String,TermRow> map = new TreeMap<String,TermRow>(); List<String>termList = new ArrayList<String>(); IndexReader iReader = IndexReader.open(indexDir); FilterIndexReader fReader = new FilterIndexReader(iReader); int numOfDocs = fReader.numDocs(); TermEnum terms = fReader.terms(); while (terms.next()){ Term term = terms.term(); String termText = term.text(); termList.add(termText); //Calculating the frequencies int df = iReader.docFreq(term); double idf = 0.0F; idf = Math.log10((double) numOfDocs / df); double tfidf = (df*idf); //Here comes important part Object oneTableRow[] = {termText, df, idf, tfidf}; redoviLista.add(jedanRed); // So i thaught to store them into list, and then later to copy into table, but didnt manage } iReader.close(); // So I need something like this, and i Neeed this array to be stored out of this method Object[][]data = new Object[redoviLista.size()][]; for (int i = 0; i < data.length; i++) { data[i][0] = redoviLista.get(i); } So I am kindda stuck here to proceed to implement AbstractTableModel and populate and display this table .... :/ Please help!

    Read the article

  • JAVA - Strange problem (probably thread problem) with JTable & Model

    - by Stefanos Kargas
    I am using 2 Tables (JTable) with their DefaultTableModels. The first table is already populated. The second table is populated for each row of the first table (using an SQL Query). My purpose is to export every line of the first table with it's respective lines of the second in an Excel File. I am doing it with a for (for each line of 1st table), in which I write a line of the 1st table in the Excel File, then I populate the 2nd table (for this line of 1st Table), I get every line from the Table (from it's Model actually) and put it in the Excel File under the current line of 1st table. This means that if I have n lines in first table I will clear and populate again the second table n times. All this code is called in a seperate thread. THE PROBLEM IS: Everything works perfectly fine ecxept that I am getting some exceptions. The strange thing is that I'm not getting anything false in my result. The Excel file is perfect. Some of the lines of the exceptions are: Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 = 0 at java.util.Vector.elementAt(Vector.java:427) at javax.swing.table.DefaultTableModel.getValueAt(DefaultTableModel.java:632) at javax.swing.JComponent.paint(JComponent.java:1017) at javax.swing.RepaintManager.paint(RepaintManager.java:1220) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:803) I am assuming that the problem lies in the fact that the second table needs some more time to be populated before I try to get any data from it. That's why I see RepaintManager and paintDirtyRegions in my exceptions. Another thing I did is that I ran my program in debug mode and I put a breakpoint after each population of the 2nd table. Then I pressed F5 to continue for each population of 2nd table and no exception appeared. The program came to it's end without any exceptions. This is another important fact that tells me that maybe in this case I gave the table enough time to be populated. Of course you will ask me: If your program works fine, why do you care about the exceptions? I care for avoiding any future problems and I care to have a better understanding of Java and Java GUI and threads. Why do you depend on a GUI component (and it's model) to get your information and why don't you recreate the resultset that populates your tables using an SQL Query and get your info from the resultset? That would be the best and the right way. The fact is that I have the tables code ready and it was easier for me to just get the info from them. But the right way would be to get everything direct from database. Anyway what I did brought out my question, and answering it would help me understand more things about java. So I posted it.

    Read the article

  • JTable Boolean cell .. how to read it

    - by dimitar
    Hello guys, i have a table with a column that contains Boolean type. now when i try to run a program i have a problem: System.out.println(table.getColumnClass(5)); b= (Boolean)table.getValueAt(row, 5); It prints class java.lang.Boolean but also: Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean and i even try with b= (Boolean)table.getValueAt(row, 5); b= Boolean.parseBoolean((String)table.getValueAt(row, 5)); b= table.getValueAt(row, 5); but those show error too. So how to fix this guys?

    Read the article

  • Mysql Query is not working in edited jTable code, why?

    - by Furkan Kadioglu
    I'm using this example: www.jtable.org I've downloaded the jTable PHP version. I then edited the script. The jTable simple version is working, but my edited version isn't. I can create a list, but I can't add a row; this code is causing problems. However, PHP doesn't display any error messages. else if($_GET["action"] == "create") { //Insert record into database $result = mysql_query("INSERT INTO veriler(bolge, sehir, firma, adres, tel, web) VALUES('" . $_POST["bolge"] . "', '" . $_POST["sehir"] . "', '" . $_POST["firma"] . "', '" . $_POST["adres"] . "', '" . $_POST["tel"] . "', '" . $_POST["web"] . "'"); //Get last inserted record (to return to jTable) $result = mysql_query("SELECT * FROM veriler WHERE id = LAST_INSERT_ID();"); $row = mysql_fetch_array($result); //Return result to jTable $jTableResult = array(); $jTableResult['Result'] = "OK"; $jTableResult['Record'] = $row; print json_encode($jTableResult); } What is the problem?

    Read the article

  • Using MigLayout, why is a JButton following a JTable unresponsive and how to fix this?

    - by M. Joanis
    Hi everyone, I am having a mind-boggling problem regarding the use of a JButton following a JTable with MigLayout. It is totally unresponsive unless I push it far enough past the JTable (then it can behave correctly). I have tried running the code with both the MigLayout JAR of the version we use for end user products and with the very most recent one; same result. Here is a sample code reproducing the problem (Main.java): import java.awt.Dimension; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.table.DefaultTableModel; import net.miginfocom.swing.MigLayout; @SuppressWarnings("serial") public class Main extends JFrame { private JPanel panel; private JTextField textField; private JButton chooseButton; private JTable table; private JButton reloadButton; private final DefaultTableModel model = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { return false; } }; public Main() { panel = new JPanel(new MigLayout("debug", "[][grow][]")); setContentPane(panel); setDefaultCloseOperation(EXIT_ON_CLOSE); /*** First row ***/ // "File:" panel.add(new JLabel("File:")); // textField for filename textField = new JTextField("No file selected yet!"); textField.setEditable(false); panel.add(textField, "growx"); // "Choose..." button chooseButton = new JButton("Choose..."); panel.add(chooseButton, "wrap, sg buttons"); /*** Second row ***/ panel.add(new JLabel()); table = new JTable(model); model.setColumnIdentifiers(new String[] {"col title"}); JScrollPane scrollpane = new JScrollPane(table); Dimension scrollpaneDimension = new Dimension(125, 110); scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); table.setPreferredScrollableViewportSize(scrollpaneDimension); table.setFillsViewportHeight(true); panel.add(table.getTableHeader(), "grow"); panel.add(scrollpane, "grow"); reloadButton = new JButton("Reload"); panel.add(reloadButton, "top, wrap, sg buttons"); pack(); setVisible(true); } public static void main(String[] args) { new Main(); } } I suppose it has something to do with the table header and the table itself ending up in the same layout cell, but I'm really not sure of this. As I said, if I push the button far enough past the JTable, it will work again. If I drop it on the next row, it doesn't work, I have to move it down one more row. The only library you need in your workspace to run the code is MigLayout. Thank you all for your help, much appreciated! M. Joanis

    Read the article

  • Java JTable, how to change cell data (write text in)?

    - by Bob Owuor
    Am looking to change a cell's data in a jtable. How can I do this? When I execute the following code I get errors. JFrame f= new JFrame(); final JTable table= new JTable(10,5); TableModelListener tl= new TableModelListener(){ public void tableChanged(TableModelEvent e){ table.setValueAt("hello world",2,2); } }; table.getModel().addTableModelListener(tl); f.add(table); f.pack(); f.setVisible(true); I have also tried this below but it still doesn't work. What gives? table.getModel().setValueAt("hello world",2,2);

    Read the article

  • Context Sensitive JTable

    - by Geertjan
    Here's a plain old JTable on the NetBeans Platform. Whenever the toolbar button is clicked, information about the currently selected row is displayed in the status bar: Normally, the above would be achieved in NetBeans Platform applications via Nodes publishing their underlying business object when the selection changes. In this case, there are no Nodes at all. There's only a JTable and a DefaultTableModel, i.e., all pure Java Swing. So, how does it work? To follow the logic, it makes sense to create the example yourself, starting with the Stock object: public class Stock {     String name;     String desc;     public Stock() {     }     public Stock(String name, String desc) {         this.name = name;         this.desc = desc;     }     public String getDesc() {         return desc;     }     public String getName() {         return name;     }     public void setDesc(String desc) {         this.desc = desc;     }     public void setName(String name) {         this.name = name;     } } Next, create a new Window Component via the wizard and then rewrite the constructor as follows: public final class MyWindowTopComponent extends TopComponent {     private final InstanceContent ic = new InstanceContent();     public MyWindowTopComponent() {         initComponents();         //Statically create a few stocks,         //in reality these would come from a data source         //of some kind:         List<Stock> list = new ArrayList();         list.add(new Stock("AMZN", "Amazon"));         list.add(new Stock("BOUT", "About.com"));         list.add(new Stock("Something", "Something.com"));         //Create a JTable, passing the List above         //to a DefaultTableModel:         final JTable table = new JTable(StockTableModel (list));         //Whenever the mouse is clicked on the table,         //somehow construct a new Stock object //(or get it from the List above) and publish it:         table.addMouseListener(new MouseAdapter() {             @Override             public void mousePressed(MouseEvent e) {                 int selectedColumn = table.getSelectedColumn();                 int selectedRow = table.getSelectedRow();                 Stock s = new Stock();                 if (selectedColumn == 0) {                     s.setName(table.getModel().getValueAt(selectedRow, 0).toString());                     s.setDesc(table.getModel().getValueAt(selectedRow, 1).toString());                 } else {                     s.setName(table.getModel().getValueAt(selectedRow, 1).toString());                     s.setDesc(table.getModel().getValueAt(selectedRow, 0).toString());                 }                 ic.set(Collections.singleton(s), null);             }         });         JScrollPane scrollPane = new JScrollPane(table);         add(scrollPane, BorderLayout.CENTER);         //Put the dynamic InstanceContent into the Lookup:         associateLookup(new AbstractLookup(ic));     }     private DefaultTableModel StockTableModel (List<Stock> stockList) {         DefaultTableModel stockTableModel = new DefaultTableModel() {             @Override             public boolean isCellEditable(int row, int column) {                 return false;             }         };         Object[] columnNames = new Object[2];         columnNames[0] = "Symbol";         columnNames[1] = "Name";         stockTableModel.setColumnIdentifiers(columnNames);         Object[] rows = new Object[2];         ListIterator<Stock> stockListIterator = stockList.listIterator();         while (stockListIterator.hasNext()) {             Stock nextStock = stockListIterator.next();             rows[0] = nextStock.getName();             rows[1] = nextStock.getDesc();             stockTableModel.addRow(rows);         }         return stockTableModel;     }     ...     ...     ... And now, since you're publishing a new Stock object whenever the user clicks in the table, you can create loosely coupled Actions, like this: @ActionID(category = "Edit", id = "org.my.ui.ShowStockAction") @ActionRegistration(iconBase = "org/my/ui/Datasource.gif", displayName = "#CTL_ShowStockAction") @ActionReferences({     @ActionReference(path = "Menu/File", position = 1300),     @ActionReference(path = "Toolbars/File", position = 300) }) @Messages("CTL_ShowStockAction=Show Stock") public final class ShowStockAction implements ActionListener {     private final Stock context;     public ShowStockAction(Stock context) {         this.context = context;     }     @Override     public void actionPerformed(ActionEvent ev) {         StatusDisplayer.getDefault().setStatusText(context.getName() + " / " + context.getDesc());     } }

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >