Clicking the table header column programmatically
Hi
For sorting of the JTable I've used the TableSorter API provided in this site. What I need to do is by clicking on another panel the panel containing the JTable should be displayed sorting the respective column. So what I need to do is click the table header column programmatically. Do you know how can I do that.
Thanx.
Take a look at setSortingStatus function in TableSorter.
If you want ascending sort just call:
setSortingStatus(columnIndex, 1);This is the code executed when you press table header, it might give you some more insight:public void mouseClicked(MouseEvent e) {
JTableHeader h = (JTableHeader) e.getSource();
TableColumnModel columnModel = h.getColumnModel();
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
int column = columnModel.getColumn(viewColumn).getModelIndex();
if (column != -1) {
int status = getSortingStatus(column);
if (!e.isControlDown()) {
cancelSorting();
// Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
// {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
status = status + (e.isShiftDown() ? -1 : 1);
status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
setSortingStatus(column, status);
}
Similar Messages
-
Programatically click the table header?
hello
how do you programatically click the table header? i have some panels in a table...there is a button in each one that says "remove" to remove that panel from the table. when i tablemodel.removeRow(thisRow), it sorta does: the row is gone, the overall count is reduced, but it displays wrong until i click on the table header..
for example..if it lists job 1, 2, 3, 4, and 5. if i delete job #2. 1, 2, 4, 5 are left. when i click on the header it shows: 1, 3, 4, 5 as it should. any query i make to what is there before the header shows the same thing: 1, 2, 4, 5. wierd eh? so i need a way to click on that header programatically. i know its a hack, but i cant figure out why its not deleting the right oen for that little time before the header-click.When you say table, I'm assuming you mean JTable since you're using
a TableModel.
You might try just encouraging the table to redraw itself as that's
probably what is happening when you click the header. I've noticed
that is often required when removing components. Anyways, I'd try
experimenting with calls to
repaint() and/or
validate() or invalidate()
on the JTable or its parent and see what happens.
: jay -
Clicking on table header throws exception
I'm using Windows Look and Feel. I made a table and applied the custom renderer to the table header. When I click the table header it throws a NullPointerException relating to the plaf.
javax.swing.plaf.basic.BasicTableHeaderUI$MouseInputHandler.mouseClicked(Unknown Source)+
Anybody any Idea. Adding the mouse Listener solves this problem but I dont want to use the listeners just for that reason.Take a look here:
http://www.codeguru.com/java/articles/218.shtml -
Some of the pivot table header column not center-aligned
I've dragged a pivot table model from Data Controls. The generated pivot table on page does not display some of the header columns center-aligned. I tried to set a css style in HeaderFormat listener for the columns, but it did not work. I checked the html source code and found the problem was caused by "colspan" not created properly. I'd like to know how pivot table header columns are created, anyone who knows please kindly give some tips,thanks!
Try setting the Header Row to allow to repeat. I've had to set that Repeat option to get things to break over pages correctly.
Ryan D. Lunka
Cardinal Solutions Group
[email protected] -
How to hide the table header if no data present
Hi
I need to hide the table header if no data present. Table has 5 column. if no any clolumn has data then this table section should not be display.
i am using <?if:count(Installation_Event_S19)= 0?> but this is not work for me.
Could you please help me out.
Thanks
Indrajeet KumarHi Priya,
Thank you very much !!! its work fine.
Thanks
Indrajeet Kumar -
How to add the Row count(number of rows in table) in the table header?
Hi,
I'm having a table. This table is viewed when i click on a search button.
<b>On the table header it should dynamically display the number of rows in the table, i.e., the row count.</b>
How to do this? could any one explain me with the detailed procedure to achieve this.
Thanks & Regards,
SureshIf you want to show a localized text in the table header, you should use the <b>Message Pool</b> to create a (parameterized) message "tableHeaderText" like "There are table entries".
Next, create a context attribute "tableHeaderText" of type "string" and bind the "text" property of the table header Caption UI element to this attribute.
Whenever the table data has changed (e.g. at the end of the supply function for the table's data source node), update the header text:
int numRows = wdContext.node<TableDataSourceNode>().size();
String text = wdComponentAPI.getTextAccessor().getText
IMessage<ComponentName>.TABLE_HEADER_TEXT,
new Object[] { String.valueOf(numRows) }
wdContext.currentContextElement().setTableHeaderText(text);
Maybe you want to provide a separate message for the case that there are no entries.
Alternatively, you can make the attribute calculated and return the header text in the attribute getter.
Armin -
Preserve the table header while scrolling table
Hi,
How do I preserve the table header (giving details of what column contains what data)-- I mean: |
v
Name I-number department
to stay on the screen, and have only my table as scrollable?
currently my table contains a lot of data and the second page on scroll comes with the problem of what each column on each row of data means.
Thanks,
AdiHello Thomas,
I am facing the same problem.To resolve this I made two containers one is transparent type for header column and another scroll container to display table contents.These two containers are inside the root container with the flow layout .
But the prob is the table that is inside scroll cotainer is displaying in the next row instead of the new row.
Is there any solution of this.
Best Regards,
Shikha -
Hi,
Is there any way to capture the right click on the table header of JTable? Can anyone tell me the way to do this.
Thanks and Regards,
R.Vishnu Varadhan.Thanks for the help.
Its working.
Regards,
R.Vishnu Varadhan. -
Can we hide the tables and columns from subject areas in the front end
Hi,
Is there any way to hide the tables and columns from the subject area in front end.I need to create a report with some tables which the user does not want to see.So after creating the reprot can I hide those tables and columns in the front endHi,
Your question is not that clear to me...do you want to hide the entire table/column that dont want to show up in the front end then you could do in Presneation Layer in the RPD by going Permissions in the property of that object.
But if you want to hide the column in the report that can be visible in the subject Area: go to column properties -> Column fomat...thereis Hide option.
Can you please elaborate your question...what exactly you are looking for...
--SK -
How to add One Button to the Table Header.
Hi,
I would like to have few Table Header columns as Button and Other Table Header Columns as String. And each Button should have separate action. Please let me know, how can i implement this one.
Thanks
Mohando not cross post, this is a bad habit. now do you know about www.google.com. well this is a search engine, learn how to use it before you post. i got this link with this keyword search.
http://www.exampledepot.com/egs/javax.swing.table/pkg.html
http://forum.java.sun.com/thread.jspa?threadID=560605&tstart=15
hope this helps you
regards
Aniruddha -
How to add a Button to the Table header
Hi,
I would like to have few Table Header columns as Button and Other Table Header Columns as String. And each Button should have separate action. Please let me know, how can i implement this one.
Thanks
Mohancross post
http://forum.java.sun.com/thread.jspa?threadID=5195296 -
Fixing the Table Header in the default JSF Table
I am using the default JSF Table in Sun JS Creator (Version JSC 2 EA 2) with a
Scroll Bar Option (instead of Pagination Control). However I have not
been able to fix the table header and scroll only the data rows in the
table.
I have tried to use CSS style for table header, but it has not worked
either. Where do I set the CSS style - in JSCreator JSF Datatable or
JSCreator Table component, neither seems to work for me?
Is there any other way to fix the table header default JSF Table in Sun
JS Creator?
Using the scroll bar is critical user requirement for me and fixing the
table header will ensure that I can use the default JSF Table in Sun JS
Creator, alternatively we will have to use some other JSF table e.g.
from myFaces or an HTML Table and lose on the productivity benefit of
JSCreator.Hi,
There please just replace the If with IIF mentioned in Visakh Post. There is spell mistake
It should be
=IIF(CountRows("Dataset") > 0, True,False)
Regards, PS -
Changing the table header's cursor on roll over
Hi,
I would like to change the cursor when the user rolls the mouse pointer over the table header.
I have tried with header.setCursor(new Cursor(Cursor.HAND_CURSOR)); but it didn't work out.
Thanks.Hi, problem is causing this method in BasicTableHeaderUI:
public void mouseMoved(MouseEvent e) {
  if (canResize(getResizingColumn(e.getPoint()))) {
    setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
  } else {
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
  } -
How to set a Excel-like column-Filtering in the Table Header using swings
I am currently working on the Database applications.Where i need to do column filter in the header field of the jTable, (i.e i need to keep a button in the Column header and when i click the button, it should pop-up a jList which has a unique values of the entire column. when i select that value it will show corresponding rows in the jTable). Can anyone pls help me....
Thanks
KarthikYou can [get the table column header|http://java.sun.com/javase/6/docs/api/javax/swing/JTable.html#getTableHeader()] and add a mouse listener to it which waits for a popup menu trigger to display a popup menu.
In that popup menu, you can display a list which contains the unique values of the column which was clicked on. Once a value is
selected, you can filter the rows using that value. -
How To apply bold property to the table header
Hi All,
Please advice me that how to apply bold property and backgroud color to the table column header.?
Any help is greatly appreciated.
Thanks in advance.
Sathya Rani MYou can loop through the rows and apply the "fillColor" property for rows. Loop length is the "headerRowCount" of the table.
In the same loop you could also loop (a loop within a loop) through all cells of a row and set its "texts" obejct, which is an array, to the text style you wish. Or you could apply a paragraph style or a character style, that is pre-defined.
Uwe
Maybe you are looking for
-
Cisco wireless and Apple Mac woes
Hello all, I've been working with Cisco wireless and WLC's for a couple of years now but the recent onslaught of Apple Mac's is giving me heart burn. I've seen this at numerous sites now and need to throw it to eht community for guidance. Basically
-
Photoshop CS6 Stops Functioning Please Help
System Information Windows 8 x64 AOC 2243fW 1920x1080 monitor (x2) Processor: Intel Core i3 2120 3.40GHz (Dual Core) Ram: 6GB GPU: nVidia geForce GTX 760 TI 2GB DDR5 Notes: Photoshop is up to date. Performance settings in photoshop are set correctly.
-
hi, I trouble in the problem with this: when i program in CMU200 with NI visa,like the samples.there a error curror,the code like this: viOpendefaultRM(&defaulrRM); viOpen(defaultRM,"GPIB0::14::0::INSTR",VI_NULL,VI
-
Fusion Absence Status stuck 'In Progress'
Hi ! I'm trying to complete a full cycle of recording an absence. I've created the accrual plan, the absence type and enrolled employees in accrual plan. At employee level I added an absence ( of the type created before ) and is stuck in status 'I
-
Deleting package names in TDMS as well as Project and subpro
Hi All, I created project name and description and inside the project i created a subproject and given its description and inside the subproject i created a package name in <b>TDMS</b> . Just i created the names only. Now i want to delete these all