Right click on Table header

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.

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

  • We used to be able to sort by multiple columns/rows at once by right clicking on the header and choosing show more options-how do we do that in the new Numbers?

    We used to be able to sort by multiple columns/rows at once by right clicking on the header and choosing show more options-how do we do that in the new Numbers?  It doesn't appear anywhere.  Do I now have to sort massive tables by each column one at a time now?  Also there used to be an easier way to merge/unmerge cells without me having to go to the table menu each time.  Am I missing something?

    Multiple column sort is a missing feature in the new version.  Hopefully soon to return. You can do a multicolumn sort by sorting one at a time in reverse order of importance.
    For merging and unmerging cells, I select the cells and right click to bring up the contextual menu. Merge and unmerge are on the menu.  You could also create keyboard shortcuts for Merge Cells and Unmerge Cells in the Table menu.

  • How can I right-align a table header?

    Does anyone know a way to right-align a table header?
    For example, in the table below I want the word 'Price' to be right-aligned. I could set the table's 'header renderer' to be a right-aligned DefaultTableCellRenderer, but then the header would look like a cell, not a header. Why can't swing be simple, like table.getColumn(1).setAlignment(Column.RIGHT) ????
    public class TestTableHeader {
         public static void main(String[] args) throws Exception {
              JFrame frame = new JFrame("Test");
              Object[][] rowData = new Object[][] { { "General Electric", "$100.60" },
                        { "IBM", "$5.20" }, { "Wal-mart", "$17.00" } };
              JTable table = new JTable(rowData, new Object[] { "Name", "Price" });
              DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
              renderer.setHorizontalAlignment(DefaultTableCellRenderer.RIGHT);
              table.getColumnModel().getColumn(1).setCellRenderer(renderer);
              frame.getContentPane().add(new JScrollPane(table));
              frame.setSize(400, 300);
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              frame.setVisible(true);
    }

    I modified your code an came up with a solution to the problem.
    import java.awt.Component;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableCellRenderer;
    public class TestTableHeader {     
         public static void main(String[] args) throws Exception {
              JFrame frame = new JFrame("Test");
              Object[][] rowData = new Object[][] {
                        { "General Electric", "$100.60" }, { "IBM", "$5.20" },
                        { "Wal-mart", "$17.00" } };
              JTable table = new JTable(rowData, new Object[] { "Name", "Price" });
              RightAlignRender right = new TestTableHeader().new RightAlignRender();
              table.getColumnModel().getColumn(0).setHeaderRenderer(right);
              table.getColumnModel().getColumn(1).setHeaderRenderer(right);
              frame.getContentPane().add(new JScrollPane(table));
              frame.setSize(400, 300);
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              frame.setVisible(true);
         public class RightAlignRender extends DefaultTableCellRenderer {
              public Component getTableCellRendererComponent(JTable table,
                        Object arg1, boolean arg2, boolean arg3, int arg4, int column) {
                   Component toReturn = table.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(table,
                             arg1, arg2, arg3, arg4, column);
                   switch (column) {
                   case 0:
                        ((JLabel) toReturn).setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
                        break;
                   case 1:
                        ((JLabel) toReturn).setHorizontalAlignment(DefaultTableCellRenderer.RIGHT);
                        break;
                   return toReturn;
    }

  • 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);
            }

  • 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

  • Turning off right click on table in 6.1

    I have an application in 6.1 where I use a table to display some results. If someone right clicks, they can do all kinds of things (like reinitialize, delete, etc.) that I don't like. Looked under property node but could not figure out how to turn off that ability. Any suggestions?

    The above solution applies to the entire FP, so it is not very specific. You can also specifically disable right-clicks inside the table only by using a filtering event for the table: "mouse down?"
    Just check if the button is two and discard the event in that case. See attached example.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    DisableRightClick.vi ‏17 KB

  • Clicking on table header

    I am working with Jtable and want when i click on header that should behave like push button, i mean on clicking that should be in push state and looks different from other header cell.
    any idea????

    Take a look here:
    http://www.codeguru.com/java/articles/218.shtml

  • JTable - Clicking table header

    How do I call a JOptionPane or even a JFrame when clicking the table header?

    Thanks Sergio, it helped me but still I can't make event recognize which column was clicked. It seems to be a hard task since I can click a header column without having a column selected, otherwise I could get the column by getColumnName(getSelectedColumn()).
    Do you hv any idea about solving this problem?

  • Popup menu when right clicking DataGrid column

    I have a DataGrid and I'd like the user to be able to
    right-click on the header and pick from some options in a menu.
    Such as give them the ability to clear the rows in the grid. I saw
    on Flex Examples you can add an option to the normal Flash menu
    that pops up but thats not what I want. I want an actual Flex popup
    to appear with my options in there. I saw this done somewhere once,
    but can't find it now.
    This would replace the need for a button below the table,
    which I think will look nicer.
    Any ideas?

    Hi Miklos, you will have to hang your option in the GoTo Menu (id 5888) while creating your From. This menu is Form dependent, therefore when you open another form it will be reseted. After this you will see your option with the right mouse click.
    Catch the MenuEvent and bind it to the class you already use to bring your "Analysis Report" to the front.
    Check also object Form.Menu for further info.
    oMenuitem = B1_Application.Menus.Item("5888")
    MenuParam.Type = SAPbouiCOM.BoMenuType.mt_STRING
    MenuParam.UniqueID = "REPTMNU"
    MenuParam.String = "Analysis Report"
    MenuParam.Enabled = True
    oMenus = oMenuitem.SubMenus
    oMenus.AddEx(MenuParam)
    It's also possible to add it in your Xml Form file as follows:
    - <FormMenu>
    - <Menus>
    - <action type="add">
      <Menu Checked="0" Enabled="1" FatherUID="5888" Image="" Position="0" String="Analysis Report" Type="1" UniqueID="REPTMNU" />
      </action>
      </Menus>
      </FormMenu>
    Regards,
    Felipe

  • How to select the row on right click.

    Hi,
    I want row selection when user right click on the table.
    Right now when user right click on table a pop up menu comes but no row selected at this time.
    Can any body tell how select the row when right click over the table.

    Hi,
    look at this thread:
    http://forum.java.sun.com/thread.jspa?threadID=501957&messageID=2374481
    L.P.

  • Context menu on right-click

    How can i get a context menu popup when the user right-clicks a table row? Will the conflict with the selection listener? thanks

    [url http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html#popup]Bringing Up a Popup Menu

  • Getting acess to TableView table header

    Hi,
    How can I get access to the TableView table headers? I want to attach mouse listeners to them so that I can get a call back anytime a user mouse clicks a table header.
    Thanks in advance, best regards,

    You could call:
    tableView.lookupAll(".table-view .column-header .label")after the table has been displayed on a Stage, but the lookup solution seems even uglier than the setGraphic one.

  • How to disable right click option re-size on table column header?

    Hi All,
    Please let us know how to disable right click option re-size on table column header.
    The issue is that when I right click on the column header, the column is selected and the context menu with options like Sort, Columns, Resize Columns, etc.. is popping. we want to disable column  re-size option.
    We are binding the table values programatically (not using Bc4J) and the Jdeveloper version is 11.1.2.2
    Thanks in advance,
    - Vignesh S.

    Hi Gawish,
    Thanks for the reply.
    This will make the particular column frozen and only work for that particular column.
    My use case is that to remove the resize columns option from the context menu or to disable the right click option.
    Making column selection as none will disable the right click option but we need column selection for sorting.
    Is there any other way to achieve this?
    Thanks in advance,
    -Vignesh S.

  • Disabling thepivoting the table or formatting when right clicking..

    Hello Experts
    I have a report in the table format and currently the user can right click on the report and do sorting excluding the column etc.. also a little grey header on the column heading. Now the user wants to disbale all this, is there is a way that i will be able to do this?
    Thanks
    Ravi

    Hi,
    Just Edit your analysis and then click on "Analysis Properties dialog" then select Interactions tab here you uncheck all the Interactions link then save it and test it.
    Note: it will affect this report only. if you want to disable enitre report just add below content in your instanceconfig.xml file then restart bi presentation services then test it out.
    Include the elements and their ancestor elements as appropriate, as shown in the following example:
    <ServerInstance>
    <Analysis>
    <InteractionProperties>
    <InteractionPropertyAddRemoveValues>false</InteractionPropertyAddRemoveValues>
    <InteractionPropertyCalcItemOperations>false</InteractionPropertyCalcItemOperations>
    <InteractionPropertyDrill>false</InteractionPropertyDrill>
    <InteractionPropertyGroupOperations>false</InteractionPropertyGroupOperations>
    <InteractionPropertyInclExclColumns>false</InteractionPropertyInclExclColumns>
    <InteractionPropertyMoveColumns>false</InteractionPropertyMoveColumns>
    <InteractionPropertyRunningSum>false</InteractionPropertyRunningSum>
    <InteractionPropertyShowHideSubTotal>false</InteractionPropertyShowHideSubTotal>
    <InteractionPropertySortColumns>false</InteractionPropertySortColumns>
    </InteractionProperties>
    </Analysis>
    </ServerInstance>
    For More Refer Oracle Note:
    http://docs.oracle.com/cd/E23943_01/bi.1111/e10541/answersconfigset.htm#BIESG3772
    18.3.4 Manually Configuring for Interactions in Views
    Thanks
    Deva

Maybe you are looking for