JTable


Hi Friends,
I've a JTable and i want to show some of the rows and want to hide some.
What technic i've to use to hide those rows.How do i achive this.Can any body give me a tip on this.
Posted On: Tuesday 23rd of October 2012 10:54:22 PM Total Views:  53
View Complete with Replies

RELATED TOPICS OF Swing / AWT / SWT PROGRAMMING LANGUAGE




inserting jtable into database

hi friends..i m using javax.swing.JTable..with defalutSetModel..it has three columns..i want to insert it into the mysql database.can i insert whole table in one column of database..please help me.. i m new to usiing the swings components
VIEWS ON THIS POST

304

Posted on:

Wednesday 17th October 2012
View Replies!

jtree to jtable (need help in coding)

Hai all, i was build an jtree from an xml,now for each node there are child elements and the child elements consists of static and dynamic fields,when i select a node in the jtree the child elements should be displayed in jtable format (and one more thing is that my tree consists of 1 supernode and it consists of 4 subnodes and each subnode consists of 3 child nodes).can anyone suggest or give a code to display jtable from jtree. and i should able to edit the values and save to jtree as well as jtable.
VIEWS ON THIS POST

190

Posted on:

Wednesday 17th October 2012
View Replies!

how run tim data in jtable or show data in jtable from my database table

i use DefaultTableModel. or swing jtable some body give me idea i use dumy class and use getColumnClass() and isCellEditable() class for modify the swing defult jtable or swing jtable give class because swing jtable give me defult data that read only but i want show data in jtable form my database table i change the title of table form give propery bu i have lot of row how i run time or dynamicly give data to jtable form my database table in jtable such as my table have data this type sname sno class address marks fahim 34 4 xxxx 545 aamir 43 4 ljfd 55 kashif 33 5 gd 444 and swing defult jtable give me this type data private String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"}; private Object[][] data = { {"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)}, {"Alison", "Huml", "Rowing", new Integer(3), new Boolean(true)}, {"Kathy", "Walrath", "Knitting", new Integer(2), new Boolean(false)}, {"Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true)}, {"Philip", "Milne", "Pool", new Integer(10), new Boolean(false)} }; or null data please give me ida how i show my database table data in jtable and how i set the jpanel location such as setlocation(12,14,3,5) but this code not give me right result please give right code
VIEWS ON THIS POST

236

Posted on:

Thursday 18th October 2012
View Replies!

get correct values from sorted jtable

hi! maybe you can help me get the correct row value from a sorted jtable i am able to be a value using getValueAt() but when i sort the table the value i get dont match the one on display. i believe there is an extra step to retrieve the real row, but i dont know how.
VIEWS ON THIS POST

177

Posted on:

Thursday 18th October 2012
View Replies!

Removing a jtable from a jpanel/Changing the table

.. I've written this code, which creates a table with a scrollpane, and loads the results of a search, when a button is pressed. The problem is that each time i press the button a new jtable is created. How can i make it either: a) refill the same table b) remove the table and make another one which displays the new results. My code: searchBt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pd.contains(qTxt1.getText(),true); System.out.println(pd.dictSearchStore.size()); if (pd.toObject()!= null && pd.toObject().length!=0) { JTable resTable = new JTable(pd.toObject(),tableTitles); JScrollPane scrollPane = new JScrollPane(resTable); resTable.setPreferredScrollableViewportSize(new Dimension(170, 160)); panel.add(scrollPane); panel.validate(); } } });
VIEWS ON THIS POST

210

Posted on:

Thursday 18th October 2012
View Replies!

jtable and jscrollpane question

hey, I have a JTable in a JScrollPane. My application is designed to have this table take up most of the screen. Sometimes the table has hundreds of rows of data in it and everything works well. However, sometimes it only has three rows in it and it looks very bad inside of the scrollPane. I would like my table to be full screen all the time regardless of the actual number of rows of data it has. Is there an easy way to do this or do I have to add "blank" rows to my table whenever I detect this condition
VIEWS ON THIS POST

192

Posted on:

Thursday 18th October 2012
View Replies!

jtable, table model, column headers

Dear all, I am using jbuilder 10 for an application and I have bumped on a glitch. I create my own tablemodel (which inherits from the AbstractTableModel) do the necessary work (implementing the abstract methods) and I also override getColumnName method. However, when the application starts no column headers appear (even though when I pass my tabled model in teh JTable constructor getColumnName is called). At first I believed that I had made a mistake with my table model class but when I used the FileTableModel class from O'Rilley's JFC book same thing happened. Does anyone have any idea why this is happening thanks in advance dimitris ps this is my table model -------------------------------------------------------------------------- package testapp; import javax.swing.table.*; import java.util.Vector; public class DataModel extends AbstractTableModel { protected String[] columnNames; protected Vector data; protected Class[] columnClasses = new Class[] {String.class, Boolean.class}; public DataModel(Vector data, String[] columnNames) { this.data = data; this.columnNames = columnNames; fireTableStructureChanged(); } public int getRowCount() { return data.size(); } public int getColumnCount() { return columnNames.length; } public Object getValueAt(int rowIndex, int columnIndex) { switch (columnIndex) { case 0: return data.elementAt(rowIndex); case 1: return (Object) new Boolean(true); default: return null; } } public void removeValueAt(int rowIndex, int columnIndex) { data.removeElementAt(rowIndex); fireTableRowsDeleted(rowIndex, columnIndex); } public void insertElementAt(Object o, int index){ this.data.insertElementAt(o, index); fireTableRowsInserted(index, index); } public void append(Object o) { this.data.add(o); fireTableRowsInserted(data.size()-1, data.size()-1); } public String getColumnName(int columnIndex) { return columnNames[columnIndex]; } public Class getColumnClass(int col) { return columnClasses[col]; } } ---------------------------------------- and this is how i call it from the mainFrame Vector data = new Vector(); String[] columnNames = new String[] {"column 1", "column 2"}; DataModel dm = new DataModel(data, columnNames) JTable table = new JTable(dm) , yeap that was it. I needed either a scrollpane or explicitly get the headers there. Thanx for the help. good day
VIEWS ON THIS POST

183

Posted on:

Thursday 18th October 2012
View Replies!

Can we set an image in a cell of a jtable.

[color=red][/color][size=24][/size][size=18][/size][size=24]Can we set an image in a cell of a jtable.[/size]
VIEWS ON THIS POST

187

Posted on:

Sunday 21st October 2012
View Replies!

update rows in jtable

I can update rows in database, but in jTable I see the changes only after I close the application and rerun it. What should I do This is my code: private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection con = (Connection) DriverManager.getConnection("jdbc:derby://localhost:1527/Proiect","aneresia","aneresia"); int rowNumber=jTable1.getSelectedRow()+1; // Statement stmt1 = con.createStatement(); // int rowsUpdated; con.setAutoCommit(false); stmt1.executeUpdate("Update Carti set nume_autor='"+jTextField2.getText()+"' , pren_autor='"+jTextField3.getText()+"', nume_carte='"+(String)jTextField4.getText()+ "' , nr_car_stoc="+jTextField5.getText()+" ,editura='"+jTextField6.getText()+"' , an_aparitie="+jTextField7.getText()+ " , pret_v="+jTextField8.getText()+" where cod_carte="+rowNumber); model.fireTableRowsUpdated(rowNumber, rowNumber); con.commit(); con.close(); } catch (SQLException ee) { ee.printStackTrace(); } catch (Exception f) { } }
VIEWS ON THIS POST

218

Posted on:

Sunday 21st October 2012
View Replies!

Ordering jtable

Hi all, I have a JTable with just one column. Every cell contains a picture thumbnail with a name and a timestamp below. The pictures themselves are represented by JPA Entities, which have tags associated to them (a comma separated String, which does not appear in the table). Now I want my user to be able to sort the table based on the timestamp or the tag String. I would like a popup menu that lets the user select the way he want the ordering to take place. What would be the best way to implement this I can compare Strings or timestamps, but just making my picture Entity implement Comparable won't do the trick, because that won't let me choose what field should be used to compare the pictures.
VIEWS ON THIS POST

150

Posted on:

Monday 22nd October 2012
View Replies!

Calculate sum in jtable and display the sum in jtextfield

Hi all,i got a table that contains codes,names,qty,price and totals.What i want to ask is how to calculate the qty*price and the total was putted in the the totals column and also putted in the JTextField..When there are new rows,or deleted rows,it will automatically edited in the JTextField.
VIEWS ON THIS POST

181

Posted on:

Monday 22nd October 2012
View Replies!

jcombo box and jtable

, I'm fairly new to Java (so please bear with me ) and am learning to use swing. I've created a simple JFrame. I have a JComboBox in the frame and below this a JTable. I have some values (a series of name) added to the JComboBox and when I select a value, such as the name 'Mary' then I want their information (grade etc) to appear in the columns of the table. So far, I've made little or no progress. I can get the chosen value from the JComboBox to appear in a textfield, but not in the table. Do you think I am going to right way Any advice would be great.
VIEWS ON THIS POST

152

Posted on:

Monday 22nd October 2012
View Replies!

color in jtable cell

i have this code (to be entirely frank i cant recall where i found it), that paints every other line with a diferent color Color cor = table.getBackground(); if((row%2) == 0 && cor.getRed() > 20 && cor.getGreen() > 20 && cor.getBlue() > 20) setBackground(new Color(cor.getRed() - 20, cor.getGreen() - 20, cor.getBlue() - 20)); else setBackground(cor)
VIEWS ON THIS POST

144

Posted on:

Monday 22nd October 2012
View Replies!

how use the jtable in java applete

hi master sorry i again Disturb you pleae give me idea how i use the jtable in java applete please send me code
VIEWS ON THIS POST

126

Posted on:

Monday 22nd October 2012
View Replies!

jtable help

In jtable when a value is being edited a border is highlighted arround the cell. But once the cursor is out of focus for instance to another component on the form, the border on the cell is still highlighted and the value that was entered on the cell doesnt get saved to the database. Is there a way to solve this issue.
VIEWS ON THIS POST

123

Posted on:

Monday 22nd October 2012
View Replies!

jtable help

In jtable when a value is being edited a border is highlighted arround the cell. But once the cursor is out of focus for instance to another component on the form, the border on the cell is still highlighted and the value that was entered on the cell doesnt get saved to the database. Is there a way to solve this issue.
VIEWS ON THIS POST

117

Posted on:

Monday 22nd October 2012
View Replies!

jtable rendering problem

I have problem in displaying the default AND values in the combo boxes in the table. The table in its empty state, that is when it is contructed and before the user has a chance to make any changes, a row with no data and 2 columns is created. The table looks like: (empty)|(empty) When the user hits the button once, the new row is added at position 0 in the table and the row that was created first without the user hitting the button moves down. Now the table looks like : (empty)|(some value) (empty)|(empty) When the user hits the button the second time, the new row is added at the last but one row and the table looks like : (empty)|(some value) AND|(some value) (empty)|(empty) When the user hits the button the third time,the new row is added at the last but one row and the table looks like : (empty)|(some value) AND|(some value) AND|(some value) (empty)|(empty) When the user hits the button the fourth time,the new row is added at the last but one row and the table looks like : (empty)|(some value) AND|(some value) AND|(some value) AND|(some value) (empty)|(empty) Addtional rows can be added thus expanding the table.
VIEWS ON THIS POST

119

Posted on:

Monday 22nd October 2012
View Replies!

jtable right mouse click

hi! how can i set a selection with right mouse click in jtable it only works with left mouse clicks. my table has single_selection mode. thx martin
VIEWS ON THIS POST

142

Posted on:

Tuesday 23rd October 2012
View Replies!

How do i add label/textbox to a jtable

Hi all, Can anybody help me in this regard. I have a JTable with n number of rows. I want to implement a key search functionality on the table in such a way that after selecting a column and when i type a character, the character typed should be displayed in a small textbox on the table. (Similar to JBuilder - projects window, wherein when u keyin a character, a small yellow color label is visible displaying the different characters we typed in). How do i do the same in a jtable. Please help me in this regarsd as early aspossible
VIEWS ON THIS POST

109

Posted on:

Tuesday 23rd October 2012
View Replies!

jtable and the scrollbar

Has anyone ever programitcally changed their horizontal scrollbar I'm using a JTable in a scrollPane and I need to take three simple steps: 1. get the current position of the horizontal scroll bar 2. recreate the table with new data (not a problem) 3. reposition the scrollbar on the new table to the same position as the old table Can anyone give me an idea how to get the horizontal scrollbar position I tried this approach but haven't had much luck: scrollPane.remove( oldTable ); Point p = scrollPane.getViewport().getViewPosition(); scrollPane.setViewportView( newTable ); scrollPane.getViewport().setViewPosition(p);
VIEWS ON THIS POST

108

Posted on:

Tuesday 23rd October 2012
View Replies!