How display numeric datas in a JTable column on the right side?

Hallo !
I have a JTable using the AbstractTableModel.
How can I display the numeric values on the right side of the column?
Wolfgang

It works, if I overwrite the TabModel-method "getColumnClass". But I cannot use this, because in german I have a "," in a double an not a "." as comma. So I get an Exception if the table tries to format 123,34 as a double.
But I think there must be a possibility to format strings in a column. On the left side, in the center, on the right side. Do you know something to position Strings in a JTableColumn ?
Wolfgang

Similar Messages

  • How can I align a character exactly flush with the right side of a text box?

    I'd like to automatically align some text so it touches the right side of its text box exactly for all characters ("Optical Margin Alignment" doesn't work). Figure-1 shows the default behavior for right-aligned text. Figure-2 shows what I want it to look like. Since these characters are inputs from a large Data Merge, manually adjusting each instance is not a practical solution.
    Selecting the "Align Left Edge" checkbox in "Drop Caps and Nested Styles" is exactly the kind of behavior I'm looking for, except it needs to be the "Right Edge" not the "Left Edge".
         Figure-1: This is the default behavior for right-aligned text.
         Figure-2: The is what I want the result to look like.

    Rob, thanks for the link with the thread. At least I know I'm not missing some obvious function somewhere.
    Olfar, I follow what you did with "Indent to Here" and the Hair Space, and I understand how to use tracking to manually align the second line, but I don't know much about grep styles, so I didn't follow that part. Does the technique you used work for all characters? For instance, if you replaced the "1" with a "7", would it automatically align the rightmost part of the "7" with the "N"? Also, I need something that works with double digit numbers, and I don't think the Hair-Space-and-Tracking trick is going to work in those cases, but I could be wrong.
    Thanks.

  • How Can I set up a JTable columns?

    Dear All,
    How can I set up my JTable columns to have the amount the user specifies?
    for example when the user types in 50 in JTextField 1 I want the JTables columns to then set to 50.
    How can this be done?
    Thanks
    lol
    import javax.swing.*;
    import javax.swing.table.TableModel;
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class si1 extends javax.swing.JFrame implements ActionListener {
        JTextField name = new JTextField(15);
        JTextField name1 = new JTextField(15);
        public si1() {
            super("DataBase Loader");
            setSize(1025,740);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel pane = new JPanel();
            JPanel pane1 = new JPanel();
            JPanel pane2 = new JPanel();
            JPanel pane3 = new JPanel();
            JPanel pane4 = new JPanel();
            pane.setLayout(new GridLayout(20,1));
            pane1.setLayout(new BorderLayout());
            int j=10;
            String[][] data = new String[j][2];
            for (int k=0; k<j; k++){
               String[] row = {"",""};
               data[k] = row;
            String[] columnNames = {"First Name", "Last Name"};
            JTable perstab = new JTable(data, columnNames);
            perstab.setGridColor(Color.yellow);
            perstab.setPreferredScrollableViewportSize(new Dimension(500,500));
            JScrollPane scrollPane = new JScrollPane(perstab);
            pane1.add(new JPanel(), BorderLayout.EAST);
            JButton btn = new JButton("What are the names?");
            btn.addActionListener(this);
            btn.putClientProperty("DATABASE", perstab);
            pane1.add(new JPanel().add(btn), BorderLayout.SOUTH);
            pane2.add(name);
            pane3.add(name1);
            pane.add(pane2);
            pane.add(pane3);
            pane1.add(pane, BorderLayout.WEST);
            pane4.add(scrollPane);
            pane1.add(pane4, BorderLayout.CENTER);
            setContentPane(pane1);
            show();
        public static void main(String[] args) {
            si1 frame = new si1();
            frame.setVisible(true);
        public void actionPerformed(ActionEvent e) {
            JTable table = (JTable)((JButton)e.getSource()).getClientProperty("DATABASE");
            TableModel model = table.getModel();
            int count = model.getRowCount();
            String[] firstnames = new String[count];
            String[] lastnames = new String[count];
            for (int i=0; i < count; i++) {
               firstnames[i] = (String)model.getValueAt(i, 0);
                System.out.println("first name at row " + i + ": " + firstnames);
    lastnames[i] = (String)model.getValueAt(i, 1);
    System.out.println("lastname name at row " + i + ": " + lastnames[i]);

    As you can see I have tried this, but no success.
    If I am doing something wrong please accept my apology, and address me in the right direction.
    Thanks
    Lol
    import javax.swing.*;
    import javax.swing.table.TableModel;
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class si1 extends javax.swing.JFrame implements ActionListener {
        JTextField name = new JTextField(15);
        JTextField name1 = new JTextField(15);
        public si1() {
            super("DataBase Loader");
            setSize(1025,740);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel pane = new JPanel();
            JPanel pane1 = new JPanel();
            JPanel pane2 = new JPanel();
            JPanel pane3 = new JPanel();
            JPanel pane4 = new JPanel();
            pane.setLayout(new GridLayout(20,1));
            pane1.setLayout(new BorderLayout());
            int j=10;
            String[][] data = new String[j][2];
            for (int k=0; k<j; k++){
               String[] row = {"",""};
               data[k] = row;
            String[] columnNames = {"First Name", "Last Name"};
            JTable perstab = new JTable(data, columnNames);
         ((DefaultTableModel)perstab.getModel()).setColumnCount(Integer.parseInt(name.getText()));
            perstab.setGridColor(Color.yellow);
            perstab.setPreferredScrollableViewportSize(new Dimension(500,500));
            JScrollPane scrollPane = new JScrollPane(perstab);
            pane1.add(new JPanel(), BorderLayout.EAST);
            JButton btn = new JButton("What are the names?");
            btn.addActionListener(this);
            btn.putClientProperty("DATABASE", perstab);
            pane1.add(new JPanel().add(btn), BorderLayout.SOUTH);
            pane2.add(name);
            pane3.add(name1);
            pane.add(pane2);
            pane.add(pane3);
            pane1.add(pane, BorderLayout.WEST);
            pane4.add(scrollPane);
            pane1.add(pane4, BorderLayout.CENTER);
            setContentPane(pane1);
            show();
        public static void main(String[] args) {
            si1 frame = new si1();
            frame.setVisible(true);
        public void actionPerformed(ActionEvent e) {
            JTable table = (JTable)((JButton)e.getSource()).getClientProperty("DATABASE");
            TableModel model = table.getModel();
            int count = model.getRowCount();
            String[] firstnames = new String[count];
            String[] lastnames = new String[count];
            for (int i=0; i < count; i++) {
               firstnames[i] = (String)model.getValueAt(i, 0);
                System.out.println("first name at row " + i + ": " + firstnames);
    lastnames[i] = (String)model.getValueAt(i, 1);
    System.out.println("lastname name at row " + i + ": " + lastnames[i]);

  • How to populate data in a JTable?????????

    hi there
    can anyone tell me how to populate data in a JTable? when a table is displayed, the table should have data retrieved from a file. thank you.

    Hi,
    it is correct, that the best way to learn about JTable is to read the online tutorial about JTable. To give you a quick guideline, where to start your implementation, I will add this:
    A JTables data is hold in a TableModel. TableModel is an interface, so if a class implements this interface correctly, you can simply populate the data hold by this TableModel by constructing a JTable this way
    JTable jt = new JTable(MyTableModel);
    where MyTableModel is your class, which implements the TableModel interface.
    When JTable has to render a cell, it will call the getValueAt(...) method of the TableModel for example.Your implementation of this method must deliver the requested data - if you prefetch a bunch of data from a file and store it internally in this TableModel or fetch it from the file just in time, is up to you.
    greetings Marsian

  • I want to display my bookmarks in a vertical column whenever the browser is on, like IE does. How can I do this?

    I want to display my bookmarks in a vertical column whenever the browser is on, like IE does. How do I do this?

    Also accessible via:
    * View > Sidebar > Bookmarks (Ctrl+B)
    Press F10 or press and hold the Alt key down to bring up the "Menu Bar" temporarily.

  • How display a DATE IN BOXS IN SAPSCRIPT

    how display a DATE IN BOXS IN SAPSCRIPT

    use cal = Calendar.getInstance() to get the current date/time
    use cal.get(Calendar.DAY_OF_WEEK) to get what today is
    calculate n = days to next Thursday
    advance the calendar with cal.add(Calendar.DATE, n).

  • How to decrypt data when you can't get the private key in Windows?

    I'm very confuse. My english is poor, but I try to say my question clearly.
    When browser connects to a https website which needs client certificate to authenticate the identity, the browser will send client certificate to web server.
    Then the web server will use the certificate to encrypt some data and send it to browser.
    Then broswer should have private key to decrypt that.
    But as I know, if I install a pfx format personal certificate, I can set can't export private key, which means you can't get the private key to use it. So how can
    the browser decrypt the data without private key?
    By the way, what is CSP, use CSP's interface can we use CryptoAPI
    to decrypt data without private key?

    Answer for question is  "you cant".. 
    "How to decrypt data when you can't get the private key in Windows?"
    Read more 
    http://msdn.microsoft.com/en-us/library/windows/desktop/aa387460(v=vs.85).aspx
    http://msdn.microsoft.com/en-us/library/windows/desktop/bb427432(v=vs.85).aspx
    http://technet.microsoft.com/en-us/library/dd277320.aspx
    http://en.wikipedia.org/wiki/Public-key_cryptography

  • When I press the down arrow on the right side of my location bar and history is displayed, how can I get it to display history from most recently accessed site on down?

    When I click the down arrow on the right side of the location bar (without having typed a full or partial URL in, I am just clicking the down arrow) a history dropdown is displayed which shows 12 website URLs that I have visited, but there does not appear to be any rhyme or reason as to what is being displayed. How can I cause this dropdown to display sites visited from the most recently accessed on down? And how can I cause more than 12 URLs to be listed in this dropdown? Why I can't I scroll down through my entire history in chronological order from most recently accessed site?

    Upgrade your browser to Firefox 8 and check
    * getfirefox.com

  • How can I reduce the display width of Firefox: I have my monitor in portriat mode, and the right side of the screen does not display.

    How can I reduce the size of the Firefox monitor display?
    I use my monitor in portrait mode, and the right side of the Firefox window is not displayed.

    Try using this extension. <br />
    https://addons.mozilla.org/en-US/firefox/addon/textarea-cache/

  • Hello I have the Latest version of Adobe Lightroom 5 to date (8/26/14) however just recently when I open the develop tab I'm missing two options on the right side column "Lens correction" and "Effects"  I do not know I've hit some setting to remove those

    Hello I have the Latest version of Adobe Lightroom 5 to date (8/26/14) however just recently when I open the develop tab I'm missing two options on the right side column "Lens correction" and "Effects"  I do not know I've hit some setting to remove those options or if this latest version deleted those options?  Any help would be greatly appreciated and please excuse my ignorance :/

    Right click next to one of the other headers and you will get a pop-up to enable the missing ones.

  • How to retrieve data from domain(Value Range)  of the table

    hi
    how to retrieve data from domain(Value Range)  of the table
    thanks

    Hello,
    You can try using the FM: DOMAIN_VALUE_GET TB_DOMAINVALUES_GET.
    BR,
    Suhas
    Edited by: Suhas Saha on Mar 24, 2009 10:08 AM

  • Need to display data on the right side in the header area of alv report.

    hi experts,
                       I want to display data in the header area of alv report on the right side  . I have already used function for events on the header side data is getting displayed on the left side .but i want data to be displayed on the right side.
    regards,
    andrews.

    Hi,
    Hope this below code helps you.
    Take care,
    Çağatay.
    * build header for alv
    FORM top_of_page_split USING r_top TYPE REF TO cl_dd_document.
    DATA: s_tab TYPE sdydo_text_table,
          c_area TYPE REF TO cl_dd_area,
          text TYPE sdydo_text_element.
    TYPES: BEGIN OF tab_text,
    text TYPE sdydo_text_element,
    END OF tab_text.
    DATA: i_text TYPE TABLE OF tab_text.
    DATA: w_text TYPE tab_text.
    CALL METHOD r_top->initialize_document.
    CALL METHOD r_top->vertical_split
    EXPORTING
    split_area = r_top
    split_width = '70%'
    IMPORTING
    right_area = c_area.
    CONCATENATE sy-datum+4(2)
    sy-datum+6(2)
    sy-datum(4)
    INTO date1.
    CONCATENATE 'DATE'  date1
    INTO w_text-text
    SEPARATED BY ':'.
    APPEND w_text TO i_text.
    CONCATENATE 'time:' sy-uzeit INTO w_text .
    APPEND w_text TO i_text.
    CONCATENATE 'uesr:' sy-uname INTO w_text .
    APPEND w_text TO i_text.
    CONCATENATE 'local date:' sy-datlo INTO w_text .
    APPEND w_text TO i_text.
    CONCATENATE 'time zone:' sy-zonlo INTO w_text .
    APPEND w_text TO i_text.
    s_tab[] = i_text[].
    CALL METHOD c_area->add_text
    EXPORTING
    text_table = s_tab
    fix_lines = 'X'
    sap_fontsize = cl_dd_document=>medium
    sap_emphasis = cl_dd_document=>strong.
    CALL METHOD r_top->add_gap
    EXPORTING
    width = 60.
    text = 'THIS IS REPORT HEADING'.
    CALL METHOD r_top->add_text
    EXPORTING
    text = text
    sap_emphasis = 'STRONG'.
    CALL METHOD r_top->new_line.
    CALL METHOD r_top->add_gap
    EXPORTING
    width = 70.
    text = 'THIS IS REPORT HEADING1'.
    CALL METHOD r_top->add_text
    EXPORTING
    text = text
    sap_emphasis = 'STRONG'.
    CALL METHOD r_top->new_line.
    CALL METHOD r_top->add_gap
    EXPORTING
    width = 80.
    text = 'THIS IS REPORT HEADING2'.
    CALL METHOD r_top->add_text
    EXPORTING
    text = text
    sap_emphasis = 'STRONG'.
    CALL METHOD r_top->new_line.
    text = 'Report Subheading1'.
    CALL METHOD r_top->add_text
    EXPORTING
    text = text
    sap_emphasis = 'NORMAL'.
    CALL METHOD r_top->new_line.
    text = 'Report Subheading2'.
    CALL METHOD r_top->add_text
    EXPORTING
    text = text
    sap_emphasis = 'NORMAL'.
    CALL METHOD r_top->new_line.
    text = 'Report Subheading3'.
    CALL METHOD r_top->add_text
    EXPORTING
    text = text
    sap_emphasis = 'NORMAL'.
    CALL METHOD r_top->new_line.
    ENDFORM. "TOP_OF_PAGE_SPLIT

  • I have a white vertical line down the right side of my internal brand new macbook pro 13" display

    I have a white vertical line down the right side of my internal brand new macbook pro 13" display. I've done the following:
    -Shutdown the computer, and restarted in Safe Mode by pressing the Shift key after the restart tone
    -Shutdown the computer, and restarted by pressing Command, Option, P & R after the restart tone
    -Checked display resolution, Best for Retina
    -Hooked it up to a Dell external monitor and via projection to screen. There are no lines on the external or secondary screens
    -Just curious, I ran a color utility which can not repair 4 items, maybe this is another issue.
    This is a brand new Macbook Pro, just out of the box. It was fine for two days without any issues, fine last night while in use, opened it up this morning with the line.
    Anyone now how I can fix this on my own?
    Details atta
    <Edited by Host>

    If you are within the first 14 days from the date of purchase, return the MBP for a refund or an exchange.  If you are after the first 14 days of the date of purchase, have the MBP repaired under the warranty provisions.
    Ciao.

  • How to add a new field on the right side of 'Part function' in Opportunity

    HI All
    I have a requirement wherein I need to add a new field for 'first name/last name' on the right side of 'Partner function' field in opportunity search criteria..
    Ex:(here i'm showing overview how the search criterial screen appears in UI since i can't attach screen shot)
    Partner function                 is                     sales lead            firstname/lastname
    It is similar to...when we select the option 'Is between' for date field then automatically one extra field will appear
    on the extreme right to enter a range for the date so similary I need to add one field to the extreme right where
    the user will select 'first name/lastname' using 'F4' help in addition the abvoe 'Partner function'.
    Could you please let me know how can we add it??
    Regards
    Anil

    Hi,
    First try to find out if you already have that field available in your view configuration. If yes, then you just need to add that to visible/displayed fields. Other wise you'd have to extend the context nodes using AET/EEWB. After you add the fields using configuration you can move them where ever you want to place them. I believe for first name/last name F4 comes by default.
    Regards
    Prasenjit

  • How do I get the word Bookmarks to appear on the right side of my bookmarks toolbar? It has disappeared.

    In my Bookmarks toolbar there is a star, an arrow, and a house. There used to be the word "bookmarks" but it disappeared. I want the word "bookmarks" back so that I can click on that. If I right click in the blue area, all I get is Open all in Tabs, etc. There is nothing to say how I get the word bookmarks.

    Firefox has two bookmark buttons with a star in the Customize window.<br />
    One star button has a drop-marker that open the Bookmark menu and may appear on the Navigation Toolbar or on the Bookmarks Toolbar if the menu bar is hidden.<br />
    The other star button without the drop-marker opens the bookmarks in the sidebar (View > Sidebar > Bookmarks).
    *https://support.mozilla.org/kb/How+to+customize+the+toolbar
    *https://support.mozilla.org/kb/Back+and+forward+or+other+toolbar+items+are+missing
    You can drag the Bookmarks menu button with the drop-marker in the Customize window from the toolbar palette on a toolbar (e.g. Navigation Toolbar or Tab Bar or to the left side of the Bookmarks Menu Items).<br />
    If you do not see the drop-marker then try them both to see which works.
    You only see the Bookmarks Menu button when the Menu bar with the Bookmarks menu is hidden (View > Toolbars or Firefox > Options).<br />
    If the Bookmarks Toolbar is visible then the Bookmarks Menu button is displayed on the Bookmarks Toolbar as part of the Bookmarks Toolbar Items (bookmarks), but you can move it from the right side to the left side of the Bookmarks toolbar if the Customize window is open.<br />
    Otherwise the Bookmarks Menu button will appear on the right hand side of the Navigation Toolbar.

Maybe you are looking for