How to set column alignment in JTable

I make a table with JTable(Vector a, Vector b).
I don't know how to set the alignment to right while the column type is Integer or Long.
Do i have to use JTable(Object[][] a, Object[] b) ?

Well , you can configure the alignment when you are creating the column, like
for (int i=0; i<7; i++){
//Size of cell
int colunaTam = 50;
//Define Allingment
int cellAlinhamento = 4; //Right Aligment
//Column
javax.swing.table.TableColumn coluna;
BusinessObjects.CellColorRenderer renderer = new BusinessObjects.CellColorRenderer();
//Define alingment in cell render
renderer.setHorizontalAlignment(cellAlinhamento);
coluna = new javax.swing.table.TableColumn(i, colunaTam, renderer, null);
ivjJTableDespachos.addColumn(coluna);
Hope i help you...
Ice

Similar Messages

  • Setting column names in JTable

    can n e one tell me how to set column names for JTable..
    i don't wanna use the JTable constructor ... cuz
    my column names change...

    this is how i did it once...hope it helps
    Vector columnNames = new Vector();
    JTable previewTable = new JTable();
    previewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    previewScrollPane.getViewport().add(previewTable, null);
    int colNo = 2; // i am displaying 2 columns
    columnNames.add("Col One");
    columnNames.add("Col Two");
    String[] tableColumnNames = {"Id Name","Type"};
    DefaultTableModel aModel = (DefaultTableModel) previewTable.getModel();
    aModel.setColumnIdentifiers(tableColumnNames);
    //add data to the table
    .//loop
    aModel.addRow(objects);
    previewTable.revalidate();
    previewTable.setModel(aModel);

  • How can I set column width in JTable?

    How can I set column width in JTable?

    Also, read the JTable API before posting questions. You will find a link to the Swing tutorial on "How to Use Tables", which contains an example of doing exactly this.

  • How to set field alignment in a table in jdev 11.1.2.3?

    hi,
    How to set field alignment in a table in jdev 11.1.2.3?
    eg: to diplay a number field in a table as right aligned.
    I have tried to set field(amount) VO UI Hint Format Type:Number; Format: 0000.00
    and jspx as flowing, but it doesnot work.
    Thanks.
    bao
    <af:column sortProperty="#{bindings.VO1.hints.Amount.name}"
    sortable="true"
    headerText="#{bindings.VO1.hints.Amount.label}"
    id="c44" width="60"
    align="center">
    <af:inputText value="#{row.bindings.Amount.inputValue}"
    label="#{bindings.VO1.hints.Amount.label}"
    required="#{bindings.VO1.hints.Amount.mandatory}"
    columns="#{bindings.VO1.hints.Amount.displayWidth}"
    maximumLength="#{bindings.VO1.hints.Amount.precision}"
    shortDesc="#{bindings.VO1.hints.Amount.tooltip}"
    id="it58"
    secret="false"
    inlineStyle="text-decoration:overline;">
    <f:validator binding="#{row.bindings.Amount.validator}"/>
    </af:inputText>
    </af:column>

    Works for me:
            <af:column sortProperty="#{bindings.EmployeesView1.hints.Salary.name}" sortable="false"
                       headerText="#{bindings.EmployeesView1.hints.Salary.label}" id="c7" align="right">
              <af:inputText value="#{row.bindings.Salary.inputValue}" label="#{bindings.EmployeesView1.hints.Salary.label}"
                            required="#{bindings.EmployeesView1.hints.Salary.mandatory}"
                            columns="#{bindings.EmployeesView1.hints.Salary.displayWidth}"
                            maximumLength="#{bindings.EmployeesView1.hints.Salary.precision}"
                            shortDesc="#{bindings.EmployeesView1.hints.Salary.tooltip}" id="it6">
                <f:validator binding="#{row.bindings.Salary.validator}"/>
              </af:inputText>
            </af:column>JDeveloper 11.1.2.3
    Salary is shown right-aligned.
    What happens if you get rid of your inlineStyle on the af:inputText

  • How to set H align of title for columnGroup

    Hi
    advancedTable has columnGroup and this columnGroup has two different columnGroups as child.
    The title of top columnGroup is located at left side however thoes of two children(columnGroup) are at center.
    I want to place the title of top columnGroup at center.
    Please advise how to set H align of columnGroup's title or show me any other ways.
    Thanks..
    Message was edited by:
    user604638

    The following assumes that you are using ICM with an IPIVR etc (not using CVP), as the answer is different for CVP
    What you are looking for is called "Ring no answer time".  It is set in the Agent Desk Setting List tool.
    Regards,
    Kevin

  • How to set column width in alvgrid

    hi
    how to set column width in alvgrid.
    thanks.

    Hi,
    Check this,
    REPORT  ztest.
    DATA: BEGIN OF i_scarr_tab OCCURS 0.
            INCLUDE STRUCTURE  scarr.
    DATA: END OF i_scarr_tab.
    DATA: i_scarr LIKE TABLE OF i_scarr_tab WITH HEADER LINE,
          w_scarr LIKE LINE OF i_scarr_tab.
    DATA: o_grid      TYPE REF TO cl_gui_alv_grid,
          o_container TYPE REF TO cl_gui_custom_container.
    DATA: lt_fcat     TYPE lvc_t_fcat,
          ls_layo     TYPE lvc_s_layo,
          ls_sort     TYPE lvc_s_sort,
          lt_sort     TYPE lvc_t_sort,
          ls_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    START-OF-SELECTION.
      CALL SCREEN 9000.
    *&      Module  status_9000  OUTPUT
          text
    MODULE status_9000 OUTPUT.
      SET PF-STATUS '9000'.
      SET TITLEBAR '9000'.
    ENDMODULE.                 " status_9000  OUTPUT
    *&      Module  user_command_9000  INPUT
          text
    MODULE user_command_9000 INPUT.
      CASE sy-ucomm .
        WHEN 'BACK' OR 'EXIT'.
          SET SCREEN 0.
          LEAVE SCREEN.
      ENDCASE.
    ENDMODULE.                 " user_command_9000  INPUT
    *&      Module  init_9000  OUTPUT
          text
    MODULE init_9000 OUTPUT.
      IF o_container IS INITIAL.
        SELECT * FROM scarr INTO CORRESPONDING FIELDS OF TABLE
           i_scarr UP TO 100 ROWS.
        IF cl_gui_alv_grid=>offline( ) IS INITIAL.
    Create a custom container control for ALV Control
          CREATE OBJECT o_container
              EXPORTING
                  container_name = 'CONTROL'.
    Create a ALV Control
          CREATE OBJECT o_grid
              EXPORTING i_parent = o_container.
          PERFORM build_field_catalgue.
          ls_layo-sel_mode = 'A'.
          CALL METHOD o_grid->set_table_for_first_display
            EXPORTING
              i_save          = 'A'
              i_default       = 'X'
              is_layout       = ls_layo
            CHANGING
              it_outtab       = i_scarr[]
              it_fieldcatalog = lt_fcat
              it_sort         = lt_sort[].
        ENDIF.
      ENDIF.
    ENDMODULE.                 " init_9000  OUTPUT
    *&      Form  build_field_catalgue
          text
    -->  p1        text
    <--  p2        text
    FORM build_field_catalgue .
      DATA: ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = sy-cprog
          i_internal_tabname     = 'I_SCARR_TAB'
          i_structure_name       = 'SCARR'
         i_client_never_display = 'X'
        CHANGING
          ct_fieldcat            = ls_fieldcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      IF sy-subrc <> 0.
        MESSAGE 'FCAT Error' TYPE 'I'.
        EXIT.
      ENDIF.
      LOOP AT  ls_fieldcat.
        CLEAR ls_fcat.
        ls_fcat-fieldname = ls_fieldcat-fieldname.     "Fieldname
        ls_fcat-ref_table = ls_fieldcat-tabname.       "DDIC ref struct
        ls_fcat-inttype   = ls_fieldcat-inttype.       "Data type
        ls_fcat-outputlen = ls_fieldcat-outputlen.     "Column width
        ls_fcat-coltext   = ls_fieldcat-seltext_m.     "Column Header
        ls_fcat-seltext   = ls_fieldcat-seltext_m.     "Column Desc
        ls_fcat-ref_field = ls_fieldcat-ref_fieldname. "Reference field
        ls_fcat-ref_table = ls_fieldcat-ref_tabname.   "Reference table
        CASE  ls_fieldcat-fieldname.
          WHEN 'LUGGWEIGHT' OR 'FORCURAM'.
            ls_fcat-edit      = 'X'.
            ls_fcat-do_sum    = 'X'.
          WHEN 'URL'.
            ls_fcat-no_out = 'X'.
          WHEN OTHERS.
            ls_fcat-edit      = ' '.
            ls_fcat-do_sum    = ' '.
        ENDCASE.
        APPEND ls_fcat TO lt_fcat.
      ENDLOOP.
    ENDFORM.                    " build_field_catalgue
    check the programs bcalv_grid*.
    check this link for more detailed example.
    http://www.supinfo-projects.com/fr/2005/alv_display_fr/2/
    Regards
    Sruthi

  • How to set columns for Zip Codes?

    I am new to iMac and in my first week using trial version of Numbers. I work in sales and we do lots of mailings using merging of data and addresses for post cards, labels, etc.
    I cannot see how to set columns to a zip code setting. All zips entered beginning with a 0 drop the front 0. I tried calling the column as Text, but it did not help. I can type a ' in from of the 0 and it works, but this takes an insane amount of time and will not work for us.
    How do you deal with Zip Codes? Are there labeling options for mailing built into Numbers? I really want to dump all MS products but will have to drop mac and return buy Office if this is not correctable.
    Thank you,
    Brownie

    Hello
    Setting the column format to text do the trick on my french version too.
    With AppleWorks, I was accustomed to use a zeroSlashed so it remained in my zip codes when I moved codes here and there.
    Yvan KOENIG (from FRANCE jeudi 13 septembre 2007 17:44:38)

  • How can I set column headers in JTable?

    I only want to set 3 column headers in JTable (without TabelModel). Can you help me?

    Hello dn77,
    Here's is a little sample I just rigged up, hope it helps.
    import java.awt.*;
    import javax.swing.*;
    public class TestOne{
         public static void main(String arg[]) {
              Object rows[][] = {
                   {"One", "1", "I"},
                   {"Two", "2", "II"},
                   {"Three", "3", "III"},
                   {"Four", "4", "IV"},
                   {"Five", "5", "V"},
                   {"Six", "6", "VI"},
                   {"Seven", "7", "VII"},
                   {"Eight", "8", "VIII"},
                   {"Nine", "9", "IX"},
                   {"Ten", "10", "X"},
                   {"Eleven", "11", "XI"},
                   {"Twelve", "12", "XII"},
                   {"Thirteen", "13", "XIII"},
                   {"Fourteen", "14", "XIV"},
                   {"Fifteen", "15", "XV"},
                   {"Sixteen", "16", "XVI"},
                   {"Seventeen", "17", "XVII"},
                   {"Eighteen", "18", "XVIII"},
                   {"Nineteen", "19", "XIX"},
                   {"Twenty", "20", "XX"}
              String headers[] = {"Notation", "Decimal", "Roman"};
              JFrame frame = new JFrame("3 Column header");
              JTable table = new JTable(rows, headers);
              JScrollPane scrollPane = new JScrollPane(table);
              frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
              frame.setSize(300,150);
              frame.setVisible(true);
    }-Merwyn,
    Developer Technical Support,
    http://www.sun.com/developers/support.

  • How to set special rows in jtable not selectable

    Hello programmers,
    anybody knows how to set special rows(p.E. row 0) in jtable not selectable.
    in advance thanks for your answers

    table = new JTable(...)
         public void changeSelection(int row, int column, boolean toggle, boolean extend)
              if (row == 0)
                   return;
              else
                   super.changeSelection(row, column, toggle, extend);
    };

  • How to set column names when not using object of row data in  constructer

    hello i am using JTable constructer as
    public JTable(int numRows,
    int numColumns)
    can i set column names for the columns .How?

    hi,
    sure you can: Create a subclass of DefaultTableModel and overwrite the method public String getColumnName(int) which returns the column name of a specific column. Then use this subclass as the data model for the table.
    best regards, Michael

  • How to set default alignment in transition?

    Hi!
           Please tell me how to set as DEFAULT, the alignment "Center at Cut" of the transition for video?
    Thank you andvance!

    The default is center at cut. But if one of the clips has not enough handles it will set it self off center, using the frames of the clip that does has enough handles.
    If you want your transition always in the middle make sure both clips have at least 15 frames trimmed off.

  • How to set column widths in tables for selected table only, not globally throughout document?

    I've been utilizing the below script (thank you so much Ramkumar. P!) to set column widths throughout a sizable InDesign book with tables on every page and it is truly a time saver. At this point in time, I have three versions of it because there are different column widths throughout the book. Is it possible to augment the script to run only on a selected text frame (containing a table)? If so, would someone be kind enough to share the augmented script with me? I've been trying to figure out this seemingly simple change through trial and error with no success as yet. I realize this is a totally newbie request and I'm entirely at the mercy of the kindness of the Javascript gods that contribute within this forum. Seeing that in a different post related to this script, one such guru responded to a request as simple as "Where do I put the scripts in InDesign" gave me enough courage to ask for some help! Thank you in advance to anyone willing to provide a solution.
      var myDoc = app.activeDocument;
         var myWidths = [100, 100, 150, 150];
         for(var T=0; T < myDoc.textFrames.length; T++){
             for(var i=0; i < myDoc.textFrames[T].tables.length; i++){
                 for(var j=0; j < myWidths.length; j++){
                     myDoc.textFrames[T].tables[i].columns[j].width = myWidths[j];
         alert("Table width updated successfully...");

    Hello all
    I have the same problem in that I'm not a scripting person, but was able to get the above script working without problem, and it does set irregular table column widths perfectly, so thanks to Ramkumar. P for that.
    BUT, it changes the column width for ALL tables in the document, whereas I would like to just target the selected table.
    Any ideas as to how I might amend this script to achieve this?
    Thx, Christian

  • How to set components aligned in left when we use BorderLayout

    Hello All,
    How to set the components aligned in the left when we use BorderLayout in a panel.Right now,the components are getting aligned in the center.
    Any solutions?
    Thanks in advance,
    Vijay

    By default a JPanel uses a FlowLayout when created and by default a FlowLayout uses center alignment. Read the FlowLayout API to find out how to use left alignment.
    Also each individual component has an alignmentX and alignmentY value which is set to 0.5 (center aligned). Some LayoutManagers will take this value into consideration. Read the Component API for more information.
    Also, check out this section from the Swing tutorial on "Using Layout Managers":
    http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html

  • How to set column width in GridPane in FXML?

    I would like to set width, for ex, of column 4 in GridPane.
    I can do like this:
    <columnConstraints>
                <ColumnConstraints prefWidth="100"/>
                <ColumnConstraints prefWidth="200" />
                <ColumnConstraints prefWidth="200" />
                <ColumnConstraints prefWidth="200" />
    </columnConstraints>If i have 10 columns should i add 10 column constraints? (i need to set only width of 4th column)
    How can i do it easier?

    >
    Hi, Can someone please help on how to set the columnwidth in csv file using javacode.
    I used FileWriter class to upload data into the csv file but csv file is taking default width while showing content. Is there a way to set the fixed column width or set width dinamically based on value?
    >
    The fields in CSV (Comma-Separated-Value) files are separated by commas; they do not have a fixed width.

  • How to set column size in sqlplus.exe ?

    SQL> select * from dba_cons_columns where user='USER1' and table_name='PARENT1';
    OWNER                          CONSTRAINT_NAME
    TABLE_NAME
    COLUMN_NAME
      POSITION
    USER1                          PARENT1_PK
    PARENT1
    COL2
             2
    OWNER                          CONSTRAINT_NAME
    TABLE_NAME
    COLUMN_NAME
      POSITION
    USER1                          PARENT1_PK
    PARENT1
    COL1
             1doesn't it seems bit ugly to see these data.Why length of columns is so long ?please tell how to set the length of columns and other parameters so that data that is displayed should come out in screen in a well managed and beautiful way.
    Like this:
    OWNER     CONSTRAINT_NAME     TABLE_NAME       COLUMN_NAME   POSITION
    USER1        PARENT1_PK              PARENT1             COL2                  2
    USER1        PARENT1_PK              PARENT1             COL1                  1I have written this by hand. How to get display in sqlplus.exe ?

    This command sets column size for all forthcoming commands. Suppose there is select command for different columns, and i want to set different size for different columns. e.g.,select name,address,zone from table1;
    How can i set column size for name to (say) 20 char, address to 30 char and zone to 3 char ?
    You need to do it in some sort of sql script which would set the column formatting before the query would start and then would clear the formatting after the query gets finished. See an example below,
    SQL> column ename format a20 heading emp_name
    SQL> select ename from emp
      2  ;
    emp_name
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    emp_name
    JAMES
    FORD
    MILLER
    14 rows selected.
    SQL> column ename clear
    SQL> select ename from emp;
    ENAME
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    ENAME
    JAMES
    FORD
    MILLER
    14 rows selected.
    SQL>So likehtis you have to format all the columns on individual lines and then clear the fomattings of each once th query isdone.
    HTH
    Aman....

Maybe you are looking for

  • Error in uploading excel sheet data into internal table

    Dear all, i am facing problem when uploading data from excel. i used KD_GET_FILENAME_ON_F4.i select the file and pass on to ALSM_EXCEL_INTO_INTERNAL_TABLE.and i get the ERROR....   Illegal type when transferring an internal table to a FORM. this is m

  • Undefined method addEventlistener

    ERRORS ON LINE 10 AND 11 1061: Call to a possibly undefined method addEventlistener through a reference with static type FunButton. package import flash.display.MovieClip; import flash.events.MouseEvent; public class FunButton extends MovieClip publi

  • BI content cube or copy of Bi content cube is recommended

    Hello all, in any implementation , we should use Standard BI content  activation of cube or copy the BI content as  Z and use? Please suggest. Thanks.

  • DEVLOPING BAR GRAPHS USING PERL..urgent

    Hi I want to do devlop bargraphs,pie charts for my project..i don't know perl..i want o devlop graphs dynamically..can any body tell me where will i get sample code to generate bar graphs dynamically...urgent. Thanks Anand

  • What happens to my existing apps post VPP using Configurator

    Hi there, I work for a library and we have invested a fair amount on the apps for two of our ipads. I've just heard of Configurator and would love to get all 8 of our ipads setup with it but I'm worried that the existing apps (on a private account) w