473,909 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JTable - Filtering

144 New Member
hi,

i read from the java.sun.com tutorial about JTable, and it says i can use the TableRowSorter, the method setFillsViewpor tHeight(boolean ) of JTable and some other methods. but it seems that the class and the method is not available. i use jre 5. is it because that class and method available in different version?

how can i accomplish filtering in jre 5?

thx
Dec 13 '07 #1
16 5949
JosAH
11,448 Recognized Expert MVP
hi,

i read from the java.sun.com tutorial about JTable, and it says i can use the TableRowSorter, the method setFillsViewpor tHeight(boolean ) of JTable and some other methods. but it seems that the class and the method is not available. i use jre 5. is it because that class and method available in different version?

how can i accomplish filtering in jre 5?

thx
Upgrade to Java 1.6 for all those nice features; basically all you have to do is this:

Expand|Select|Wrap|Line Numbers
  1. yourTable.setAutoCreateRowSorter(true);
  2.  
and you get nice sorted tables according to a single column.

kind regards,

Jos
Dec 13 '07 #2
thesti
144 New Member
Upgrade to Java 1.6 for all those nice features; basically all you have to do is this:

Expand|Select|Wrap|Line Numbers
  1. yourTable.setAutoCreateRowSorter(true);
  2.  
and you get nice sorted tables according to a single column.

kind regards,

Jos
thx Jos. with the auto create row sorter, can i have a table with filtering feature?

thx
Dec 13 '07 #3
JosAH
11,448 Recognized Expert MVP
thx Jos. with the auto create row sorter, can i have a table with filtering feature?

thx
What sort of filtering? Either displaying a row or not type of filtering? If so, your
TableModel should be resposible for that. If not, I don't understand your question.

kind regards,

Jos
Dec 13 '07 #4
BigDaddyLH
1,216 Recognized Expert Top Contributor
thx Jos. with the auto create row sorter, can i have a table with filtering feature?
Sounds like to me your inner Java genie wants you to upgrade to 6 and use RowSorter. It has row filtering capabilities, too:

http://java.sun.com/developer/JDCTec.../tt1115.html#2
Dec 13 '07 #5
thesti
144 New Member
well, this is a task that is given to me, and i dunno if i may use the 6 version. so, i try to do it with Java 5 if it's possible.

i don't really know how the sorting and filtering JTable works in Java. in fact i never use that sorting and filtering feature. what i know is that

i need in my program like a searching feature. user type something in a textfield and if the user click a button, the table will only display rows that has what the user typed as a substring of a particular column (specified before by the user from a combo box).

hope someone could help.

thx
Dec 13 '07 #6
JosAH
11,448 Recognized Expert MVP
well, this is a task that is given to me, and i dunno if i may use the 6 version. so, i try to do it with Java 5 if it's possible.
I consider that a not-so-wise decision; if you don't know whether or not A, assuming
'not-A' is as silly as assuming the opposite 'A'. Why not ask your teacher first?

kind regards,

Jos
Dec 13 '07 #7
BigDaddyLH
1,216 Recognized Expert Top Contributor
You also haven't properly described your context. If the data is from a database, you could just do the filtering in a new query.
Dec 13 '07 #8
thesti
144 New Member
it's from a file. haven't reach the database connection section

ok then, thx for your help.
Dec 14 '07 #9
JosAH
11,448 Recognized Expert MVP
Better upgrade to Java 1.6; it'll only cost you ten minutes or so.

kind regards,

Jos
Dec 14 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
8641
by: Ben Munday | last post by:
Hi all, I have a problem with a Checkbox in a JTable. When i add the Checkbox into the JTable it displays the String representation of the Checkbox, which is not what i want. So, i created a CheckBoxRenderer which extens Checkbox and implements TableCellRenderer. This seems to have done the job, in that the Checkbox is displayed and not the String representation. But, and it's a big 'but', the column that holds the Checkbox continually...
1
8980
by: asd | last post by:
I need to make the cells in the 1st column look like the column header. I tried the following code but it didn't change anything: private void rendererTest() { TableColumn column = tblDecisions.getColumnModel().getColumn(0); TableCellRenderer renderer = column.getHeaderRenderer(); column.setCellRenderer(renderer); }
1
7988
by: raysaun | last post by:
I am trying to set a TableCellEditor for a JTable, however, the editor never seems to get called. I can not even get a simplified version (below) to work. When I put a breakpoint on the return statement in getTableCellEditorComponent, it never stops there even though I edit cells in the table. Can anyone tell me what I am missing. By the way, I have gotten TableCellRenderers to work with no problems. public class Frame1 extends...
0
3149
by: sivaprasad06 | last post by:
Hi, I have a editable combo box editor as a cell editor for JTable. I want use only key board to enter data into jtable. so i am using ALT+Down comobination for making cell editiable in the jtable. when user clicks that combination what ever editor present in that cell will appear. I am using tab for traversing all cells in table.
0
3404
by: nuria | last post by:
hi, I have an editable JTable, when you are editing it and press F8 shows a dialog and then go again to the JTable window but the focus goes to a JtextField component, go with the tab for the rest of the textfields and when have to get the focus again the JTable can´t get it !!! only if I go with the mouse!!!! I am trying all things, give the focus to other component before call the Jdialog, put visible(false) the JTable before call...
1
6748
by: Andrea Sansottera | last post by:
Hi fellows, I was wondering if in the Java API there's a way to easily map a disconnected RowSet to a JTable... I have looked at the doc but i did not found anything. What I want is simply do the follow: 1. Load: Database -> disconected Rowset -> automapping in a JTable 2. Editing of the data in the table/rowset
1
7400
by: onsir | last post by:
I have code like this, but still wrong. how to show data from database in JTable. package my.JavaNetBean; import java.sql.*; import java.io.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException;
7
17242
blazedaces
by: blazedaces | last post by:
Hi guys, what I'm I have is a jtable with boolean variables in the first column and text in the next two (checkboxes). I want my tableChanged method to make it so when I check one of the checkboxes then it would change whether that third column is editable or not. I have made a short array that would hold values of either 0 or 1, basically whether or not each cell is editable or not. Along with that is obviously a setEditable(int row, int...
5
9879
by: moizpalitanawala | last post by:
Hello friends, How to add data to JTable from a .txt file. I had seen this code from one of the tutorial from java.com. This code doesnt take any input. But shows what is written in the array. But i want the table to display the data from a .txt file in which i had stored information in this format. Can anyone please modify the codes and explain me. Name:Mr.xyz Phone:111111222222
0
10037
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9879
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11348
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11052
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9727
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7249
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6140
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3359
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.