Cell horizontal alignment

Hi,
does someone know how to set the horizontal alignment of a cell ???
Thanks, Fred.

A JTable object provides a TableCellRenderer object for each of its column. It usually takes it from the TableColumn object provided by its own TableColumnModel, if available, or otherwise provides a DefaultTableCellRenderer object. This default cell renderer is basically a JLabel formatted according to the type of value it has to display.
You can write your own cell renderer, e.g. a JLabel that you format as you wish, and set it as the default cell renderer for the table using the setDefaultRenderer method.
Or you can overwrite the getCellRenderer method of the table and have it return the appropriate cell renderer for a column.
Or you can write your own TableColumnModel and have it used by the table.
The chosen solution depends on what you really need to do. Hope it helps.

Similar Messages

  • Control horizontal alignment of table cell?

    Is it possible to control the horizontal alignment of text within a table cell using some form of xsl:attribute code? I wasn't able to find any alignment attributes supported in the user guide and was hoping there was a way to manage it- the problem is that I don't know ahead of time which cells need to be left justified and which ones need to be centered.
    Thanks,
    Kevin

    I've tried the following in the
    advanced properties but with no success.
    <?if:number(EMPID)>6?>
    <xsl:attribute
    xdofo:ctx="block" name="text-align">center
    </xsl:attribute>
    <?end if?>
    Change the attribute to the following and the formatting works.
    <?if:number(EMPID)>6?>
    <xsl:attribute
    xdofo:ctx="block" name="background-color">red
    </xsl:attribute>
    <?end if?>
    I'm previewing in PDF.
    If anyone has any ideas they would be greatly appreciated.
    Thankyou
    John.

  • Custom Table Cell Renderer Unable To Set Horizontal Alignment

    Hello,
    I have a problem that I'm at my wit's end with, and I was hoping for some help.
    I need to render the cells in my table differently (alignment, colors, etc) depending on the row AND the column, not just the column. I've got this working just fine, except for changing the cell's horizontal alignment won't work.
    I have a CustomCellRenderer that extends DefaultTableCellRenderer and overrides the getTableCellRendererComponent() method, setting the foreground/background colors and horizontal alignment of the cell based on the cell's value.
    I have a CustomTable that extends JTable and overrides the getCellRenderer(int row, int column) method to return a private instance of this CustomCellRenderer.
    This works fine for foreground/background colors, but my calls to setHorizontalAlignment() in the getTableCellRendererComponent() seem to have no effect, every cell is always displayed LEFT aligned! It's almost like the cell's alignment is determined by something else than the table.getCellRenderer(row,column).getTableCellRendererComponent() method.
    I've also tried setting the renderer for every existing TableColumn in the TableModel to this custom renderer, as well as overriding the table's getDefaultColumn() method to return this custom renderer as well for any Class parameter, with no success.
    No matter what I've tried, I can customize the cell however I want, EXCEPT for the horizontal alignment!!!
    Any ideas???
    Here's the core custom classes that I'm using:
    class CustomTable extends JTable {
    private CustomRenderer customRenderer = new CustomRenderer();
    public CustomTable() {
    super();
    public TableCellRenderer getCellRenderer(int row, int column) {
    return customRenderer;
    } // end class CustomTable
    class CustomRenderer extends DefaultTableCellRenderer {
    public CustomRenderer() {
    super();
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    if (row % 2 == 0) {
    setForeground(Color.red);
    setHorizontalAlignment(RIGHT);
    } else {
    setForeground(Color.blue);
    setHorizontalAlignment(LEFT);
    return this;
    } // end class CustomRenderer
    Even worse, I've gotten this to work fine in a trivial example I made to try and re-create the problem. But for some reason, this same thing is just not working for horizontal alignment in my actual project?!?
    Anyone have any ideas how the cell's horizontal alignment set in the getTableCellRendererComponent() method is being ignored or overwritten before the cell is being displayed???
    Thanks, any help is appreciated,
    -Alex Blume

    Ok, so I've looked into their source and I think I know where and what the trouble is. The JTable.java has a method called:
    3658> public TableCellRenderer getCellRenderer(int row, int column) {
    3659> TableColumn tableColumn = getColumnModel().getColumn(column);
    3660> TableCellRenderer renderer = tableColumn.getCellRenderer();
    3661> if (renderer == null) {
    3662> renderer = getDefaultRenderer(getColumnClass(column));
    3663> }
    3664> return renderer;
    3665> }
    starting at line 3658 of their source code. It retrieves the TableCellRenderer on line 3660 by calling the tableColumn's getCellRenderer method. This is found in the TableColumn.java class:
    421> public TableCellRenderer getCellRenderer() {
    422> return cellRenderer;
    423> }
    See the problem? Only ONE cell Renderer. It's referring to a variable found at line 140 which is of type TableCellRenderer ... well actually it's created as a DefaultTableCellRenderer at some point since TableCellRenderer is an interface.
    Basically the fix is this:
    In the TableColumn.java file, a collection (Vector, LinkedList, whatever) needs to keep track of each cell's renderer. This will solve the solution. Of course this will be something that you or I can make.
    What's funny is the contradiction in documentation between JTable's and TableColumn's getCellRenderer() method. First, if we look at TableColumn's documentation it states:
    "Returns the TableCellRenderer used by the JTable to draw values for this column."
    Based on that first statement, the getCellRenderer() method in TableColumn is doing its job exactly. No lies, no contradictions in what it does.
    However, that method is called up inside of the JTable's getCellRenderer() method which says a completely different thing which is:
    "Returns an appropriate renderer for the cell specified by this row and column."
    Now we have a problem. For the cell specified. It appears that the rush to push this out blinded some developer who either:
    1) mis-interpreted what the JTable getCellRenderer() method was supposed to do and inadvertently added a feature or;
    2) was in a 2 a.m. blitz, wired on Pepsi and adrenalin and wrote the bug in.
    Either way, I'm really hoping that they'll fix this because it will take care of at least 2 bugs. Btw, anyone interested in posting a subclass to solve this problem (subclass of TableColumn) is more than welcome. I've spent much too much time on this and my project is already behind so I can't really afford any more time on this.
    later,
    a.

  • Horizontal align center in table-cell

    Hello,
    I'm having a problem getting to horizontally align a div (schilderij) in another div (schilderijholder).
    This schilderij div has a height and width of 480px and has display: table-cell. The content of this div is an image, with different sizes on every page (there are multiple pages, it is some sort of photogallery). The images are nicely centered, horizontally and vertically, inside this div.
    The containing div (schilderijholder), has a width of 100% of it's containing block, which has a variable size
    The problem is, I cant get the schilderij div horizontally centered in the schilderijholder div.
    Here's the simplified code. If you need the whole code, I can post that too.
        <div class="leftWrapper" style="clear: none; float: left; width: 68%; height: 100%;">
        <div class="content" style="margin: 40 10 50 30;">
          <div id="schilderijholder" style="text-align: center; width: 100%; height: 100%;">
              <div id="schilderij" style=" height: 480px; width: 480px; text-align: center; vertical-align: middle; display: table-cell;">
                <img src="../Assets/Schilderijen/normal/01.jpg" width="399" height="480" align="center" />
                </div>
              </div>
            <div id="pageControl">
            <span class="left">
              <a href="schilderijen2.html"></a> </span>
              <span class="right">
              <a href="02.html">Volgende</a>
                </span>
              </div>
          </div>
         </div>
    What I've tried:
         - "margin: 0 auto;" on the schilderij div
         - "position: relative;" on the schilderijholder div and "position: absolute; left: 50%; margin-left: -240px;" on the schilderij div
    But these both don't work.
    Does anybody know a solution for this, or maybe has something to put me on the right way?
    Thanks in advance!

    Let's fix your code first:
    <div class="leftWrapper" style="float: left; width: 68%; height: 100%;">
        <div class="content" style="margin: 40px 10px 50px 30px;">
          <div id="schilderijholder" style="text-align: center; width: 100%; height: 100%;">
              <div id="schilderij" style=" height: 480px; width: 480px; text-align: center; vertical-align: middle; display: table-cell;">
                <img src="../Assets/Schilderijen/normal/01.jpg" width="399" height="480" align="center" />
                </div>
              </div>
            <div id="pageControl">
            <span class="left">
              <a href="schilderijen2.html"></a> </span>
              <span class="right">
              <a href="02.html">Volgende</a>
                </span>
              </div>
          </div>
         </div>
    Why do you need the div#schilderij at all?  Seems unnecessary to me.
    Then you would need the display:table-cell on the parent to this div, not on the div#schilderij, which has basically the same dimensions as the image.  But I think this is all too complicated.  Why not just this?
    <div class="leftWrapper" style="float: left; width: 68%;">
        <div class="content" style="margin: 40px 10px 50px 30px;">
          <div id="schilderijholder" style="text-align: center;">
                <img src="../Assets/Schilderijen/normal/01.jpg" width="399" height="480" align="center" />
                </div>
              </div>
            <div id="pageControl">
            <span class="left">
              <a href="schilderijen2.html"></a> </span>
              <span class="right">
              <a href="02.html">Volgende</a>
                </span>
              </div>
          </div>
         </div>

  • Can table cell vertical alignment be defined via CSS?

    In a table cell (ie, "td") is there a way to define "valign" via CSS, instead of the table cell proper?
    In other words, instead of...
    <table>
    <tr>
    <td valign="top">
    ...is it possible to do :
    <table>
    <tr>
    <td class="top">
    ...and somehow let the stylesheet define the vertical alignment?
    I'm asking because none of the attribute presets in Dreamweaver CS4 seem to provide for vertical alignment. Everything else on God's green earth seems to be there, but table cell vertical alignment seems to be the ONLY thing CSS forgot about.

    How about giving the class "top": text-align:center. Or even the tag "td" in your stylesheet. Does that help?
    John

  • Horizontal alignment for Text of Header Region

    Hi,
    The content of Text property for a header Region appears left aligned by default.
    Is it possible to set horizontal Alignment = Middle(of the Page)For the Item Type, Header I do not see any property called Horizontal Alignment in the Property Inspector.
    Thanks,
    Gowtam.

    Header component does not expose any property to align the text.
    Can you check whether, the following layout helps.
    TableLayout (Horizontal Alignment - center)
    |
    -- RowLayout (Horizontal Alignment - center)
    |
    --- CellFormat (Horizontal Alignment - center)
    |
    ---- Header

  • Adaptive Layout - Portlet horizontal alignment

    Is it possible to create an Adaptive Layout with horizontal alignment of portlets in a column?
    Attempting to create a layout with column1 above column 2 and column3 along right side of page.

    I apologize for the late response.
    I was not able to switch the alignment. I moved on to another approach due to limited time.
    Adaptive layouts are a composite of the base portal css styles and adaptive layout styles. It is difficult without a tool that is able to pull all the components into a single view based upon references. (Now that would be a useful tool.... anyone listening). The most useful tool i have found so far is Dreamweaver, it allows you to create custom tag libraries for limited design help.
    I welcome any input on a tool that can handle the tag libraries.
    I will update this thread if I make any discoveries.

  • JTextArea horizontal alignment

    I want to control the alignment of text in a JTextArea control (alignment left, center or right). I assume that I need to make a custom renderer of some description to be able to draw the text in the appropriate alignment,
    but if this is the case, I cannot work out how to setup the components.
    I appreciate that the JTextPane provides for setting of paragraph alignment attributes, but in my situation I need to use the JTextArea (the user needs to be able to turn line wrap on and off at run time so I need to make use of the JTextArea lineWrap facility).
    Is there any way that I can get the JTextArea to support the horizontal alignment??
    Any assistance would be greatly appreciated,
    regards, Sean

    I just realised that using a JTextPane would be acceptable as long as I could allow the user to turn on and off the line wrapping behaviour of the JTextPane. Does anybody know how to achieve that?
    Thanks, Sean

  • Obi 10g, merge the table cells horizontally

    hi, experts,
    is it possible to merge the table cells horizontally?
    thank you very much!

    Forreging,
    Try removing left border of the cells using CSS/options in the coulmn properties.
    mark post promptly
    -bifacts
    http://www.obinotes.com
    J

  • How do you float and image or text so that it remains centered for a given browser window size (horizontally aligned).

    Is it possible to float images horizontally in muse (horizontally aligned) such that an image or text remains in the center of a browser window regardless of its dimensions. The pin feature is capable of accomplishing this but it has the unwanted effect of, well, pinning it. There must be a way other than manually changing the code outside of muse after each change.
    Thanks,

    Hmm, tried it and its not working as intended. I created a text box the width of the page, typed some text and center justified it. When I adjust the size of the browser window it of course remains centre justified but it doesn't stay in the center of the scree as the window width changes. Did I not understand the 100% width part correctly?
    To be clear, I understand how to do this is CSS but there must be some way to do it in muse so you don't have to manually go back and edit the html after each upload.

  • Button created among region items cannot be horizontally aligned

    If I create a button amongst region items, and say new line = NO and new field = YES, it creates the button in its own table cell. However there is no apparent interface to horizontally (or vertically for that matter) align the button within the cell.
    If I create any other region item, or a button in a region position, I can see the alignment options which work as expected.
    Am I missing something here?

    A workaround here is to add the item as post element text on the previous item in sequence. But then the item is "lost" when looking at the page edit screen, and common editing features are not available.
    I see no logical reason why a button created amongst region items should not have all the operations permitted on it as do the regular region items.

  • Af:panelgroup horizontal alignment

    Hello,
    I have two af:panelbox components in one af:paneolgroup (layout horizontal) container.
    The epxectation is both panelbox should display nearby each other. For e.g. one panelbox on the left and another panel box on the right. Think of them as an open book on the table.
    The issue is: the header for second panelbox(on the right) displays after leaving some margin at the top and starts diplaying in the center-right corner of af:panelgroup layout container. No matter what I do but, header for both panelbox simply will not display side by side.
    Below is the code snippet. Please help.
    <af:panelGroup layout="horizontal"
    inlineStyle="width:38.5%; text-align:left;" >
    <af:panelBox text="Insight"
    width="280px" background="light"
    inlineStyle="vertical-align:bottom; "
    binding="#{ShowApanel.panelBox1}" id="panelBox1">
    <af:panelGroup layout="vertical">
    <af:goLink styleClass="link" text="- Agents of Change" destination="C:\COEXSYS\home\Coexsys\public_html\Company_Information.html"
    inlineStyle="font-size:smaller;text-decoration:none;font-family:Arial;margin:2.0%"/>
    <af:objectSeparator> </af:objectSeparator>
    <af:goLink styleClass="link" text="- Enterprise Applications - A turning point" destination="C:\COEXSYS\home\Coexsys\public_html\Company_Information.html"
    inlineStyle="font-size:small;text-decoration:none;font-family:Arial;margin:2.0%"/>
    <af:objectSeparator> </af:objectSeparator>
    <af:goLink styleClass="link" text="- Outsourcing - A fundamental Shift" destination="C:\COEXSYS\home\Coexsys\public_html\Company_Information.html"
    inlineStyle="font-size:small;text-decoration:none;font-family:Arial;margin:2.0%"/>
    <af:objectSeparator> </af:objectSeparator>
    <af:goLink styleClass="link" text="- Enterprise Applications - A turning point" destination="C:\COEXSYS\home\Coexsys\public_html\Company_Information.html"
    inlineStyle="font-size:small;text-decoration:none;font-family:Arial;margin:2.0%"/>
    <af:objectSeparator> </af:objectSeparator>
    <af:goLink styleClass="link" text="- Rich Internet - Power of desktop on the web" destination="C:\COEXSYS\home\Coexsys\public_html\Company_Information.html"
    inlineStyle="font-size:small;text-decoration:none;font-family:Arial;margin:2.0%"/>
    <af:objectSeparator> </af:objectSeparator>
    <af:goLink styleClass="link" text="- Horizontal organizations - A lasting trend" destination="C:\COEXSYS\home\Coexsys\public_html\Company_Information.html"
    inlineStyle="font-size:small;text-decoration:none;font-family:Arial;margin:2.0%"/>
    <af:objectSeparator> </af:objectSeparator>
    <af:goLink styleClass="link" text="- The Chaos" destination="C:\COEXSYS\home\Coexsys\public_html\Company_Information.html"
    inlineStyle="font-size:small; text-decoration:none; font-family:Arial; margin:2.0%;"/>
    <af:objectSeparator> </af:objectSeparator>
    <af:goLink styleClass="link" text="More.." destination="C:\COEXSYS\home\Coexsys\public_html\Company_Information.html"
    inlineStyle="font-size:small; text-decoration:none; text-align:right;margin:10px;"/>
    </af:panelGroup>
    </af:panelBox>
    <af:panelBox id="tree" text="Industries" inlineStyle="width:216px;marign:-20px;">
    </af:panelBox>
    </af:panelGroup>
    </af:document>
    Thanks,
    Ruchir

    Hi!
    I don't know if this helps but I use
    afh:tableLayout
    afh:rowLayout
    afh:cellFormat
    afh:cellFormat
    for such purposes. This way you get some kind of HTML table with rows and cells in which you then put other components. In afh:cellFormat you have Halign and Valign properties which you set to suite your purpose. For Example try setting Valign to 'top'. You can also set margin and padding properties to 0.
    HTH
    BB

  • Cell figures alignment

    Hi,
    for those of you who don't know me, I'm new at ID.
    I'm tackling tables. And I have a problem. How do you align figures in columns where you have normal figures like 25,000 and below it you have minus figures like (25,000). What I want to do is align them, so the parenthesis hangs out (a bit to the right), and the 25,000s perfectly align. I'm doing tables in the cell style, properly.
    Thanks.

    P Spier wrote:
    Align on the decimal point.
    The tab is implied inside the cell unless you add another manually.
    I'm sorry, I don't understand this sentence. Do you mean ID thinks there's a tab in the cell? Because I still can't do it with a decimal point, nothing happens.
    OR
    Do I need to put a tab into every cell? With Insert special character?

  • JTable when scroll horiz column cells dont align with header

    Hi,
    I'm having a problem with my JTable. Everything was working correctly until i introduced checkboxes into a column on teh table. I have a table which has a horizontal scrollbar to scroll across all the columns. when i set one column to boolean values (instead of the strings 'true' and 'false' which were there before) when i scroll across the table the headers of each column no longer align with the data.
    Some columns resize when i scroll and the headings always stay the same width.
    I'm getting an error:
    java.lang.ClassCastException
         at javax.swing.JTable$BooleanRenderer.getTableCellRendererComponent(Unknown Source)The database stores int 0/1 for the boolean value so in the getValueAt method of my table model i return a boolean for this column.
    Any help would be greatly appreciated!
    Thanks,
    Saz

    Thanks for replying. Neither solution worked.
    The problem is definately with the boolean value because i'm getting a classcast exception: at javax.swing.JTable$BooleanRenderer.getTableCellRendererComponent(Unknown Source)
    I've a feeling this could be caused by some values being empty strings in the same column with booleans?
    Does anyone know what causes this error?
    Thanks,
    Sarah

  • Contact Form positioning, cells mis-aligned?

    I built a contact form and put it up at
    http://www.newood.com/catreq.htm
    For some reason, a couple of the cells that hold form fields
    are not aligned correctly, both in IE and in Firefox. Is there
    someone here that could check the code for me and might have a clue
    to why this is going on?
    Thanks!
    Sarah Woods

    Before worrying about any layout issues, it's a good idea to
    make sure that
    your page contains Valid HTML - yours fails that test in a
    number of very
    important ways. Please take a look here and fix these errors
    http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.newood.com%2Fcatreq.htm
    Then we'll take a look at your alignment issue....
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "kismetdesign" <[email protected]> wrote in
    message
    news:g4qsh3$lna$[email protected]..
    >I built a contact form and put it up at
    http://www.newood.com/catreq.htm
    >
    > For some reason, a couple of the cells that hold form
    fields are not
    > aligned
    > correctly, both in IE and in Firefox. Is there someone
    here that could
    > check
    > the code for me and might have a clue to why this is
    going on?
    >
    > Thanks!
    >
    > Sarah Woods
    >

Maybe you are looking for

  • How do I Take All my music from one computer to another

    I need to take all my music from my home computer and put it on my laptop. I think I have copies all the correct files to an external hard drive and now need to put them on my laptop so that they are in my library in iTunes on my laptop. How do I do

  • Using PL/SQL in a formula column in Oracle Reports Builder.

    Hi, I need to SUM two record from the result of an SQL interrogation. Here's what it looks like function CF_1Formula return Number is nTot1 NUMBER :=0; nTot2 NUMBER :=0; begin      select sum(:TOT1) into nTot1 from table(Q1) ;      select sum(:TOT2)

  • About LiveCycle Data Services ES2

    hi:   I set up a project the same as [LCDS install]/tomcat/testdrive_dataservice. occur errors:      Reference Error:Error #1069:            not found maxFrequency property in mx.data.DataManagementConsumer and default value                          

  • Calendar synch w/ Outlook failing - internal error #-725 (0x8004fd2b)

    just upgraded device and desktop s/w to latest and problem did not go away. Contacts and Notepad synch just fine. But Calendar fails: 1) reads all device entries 2) reads all Outlook entries 3) then pops up a message: "Error encountered. Error code -

  • HI SAN

    Hi San.hru man i'm asking sap r/3 types &bw types at user exit level let me explain plssss