How to align text(left, right or center) on a button?

I can not figure out how to align text on a button,
could someone help me out?
Thanks in advance

JButton btn=new JButton("hi");
btn.setHorizontalAlignment(int i)
i=0 center
i=2 left
i=4 right

Similar Messages

  • Left, Right or center justified. Need some help

    Hi,
    I have to do an assignment in which i am asked to read a file containing text of strings. I have to set some properties for my implementation class so that i will get the output in desired format i.e
    left, right or center justified.
    Can anybody tell me the documents or the classes to go through. i am new to java. Please reply me.
    Thanks
    Rita

    ya, i know how to read the file and probably print them to the console Good!
    but i dont know how to print the output in right- justified manner.
    The output is by default left-justified, but i dont know how to do right-justified.Okay, you need to do some padding (justification). Check out the stuff in StringBuffer (and StringBuilder, in 1.5) and String. Questions about padding/justification come up on the forum all the time (did you try searching?). Basically, you have to decide the full length you want (e.g., 100 characters), and then prepend/append the proper number of spaces to the original String.

  • How to Align Text in the TextArea

    How to Align text in the TextArea. My purpose is that I want to post the records after retrieving from database. All the records in each fields should keep aligned like Oracle WorkSheet.
    I want this way
    Code Name Place City
    a01 nilopher swiss street japan
    a02 rozina lovely street aus
    a03 benazir king's camp pitsburg
    and the out put should not look like this :-
    Code Name Place City
    a01 nilopher swiss street japan
    a02 rozina lovely street aus
    a03 benazir king's camp pitsburg
    here place and city records are getting disturbed accordingly the length of name.

    Well, first off (if it's not default, that is) you must set a monospaced font on the TextArea, unless you want to count pixelwidth of each and every string and then do an estimate on how many fill blanks you want...
    If you have the each string as a line, you use a StringTokenizer on it, extract each token, put all the tokens for that line into an array of strings.
    When every line is done, you compare the length of the nth String of each array and save the highest numbers.
    Then you reassemble each line from the arrays and pad in spaces where the tokens are too short.
    HTH,
    Fredrik

  • My mouse can not click to anything left, right or the middle mouse button does not work

    I am using a 24 inch imac and the problem is suddenly my mouse can not click to anything left, right or the middle mouse button does not work i can see cursor moving and i can use the features of the keyboard but my mouse dies. I tried to plug in another mouse magic trackpad and my tablet but each has the same problem. I can not click to anything but cursor is moving and computer is not frozen. I have to shut it off from the power button when this happens. Do you have any idea what can cause this and how can i fix this?

    Reset the SMC 2-3 times. Click Intel iMac SMC and PRAM resets for instructions.

  • How to align text {center/left/right} in  the column of ALV grid

    Hai all,
    I am displaying one check box in the ALV grid, but default it is coming left align in the column,
    how can i assign it to the center of the column.
    Thanks,
    SREEVATHSAVA.G
    Edited by: SREE on Aug 14, 2009 7:53 AM

    Hi,
    DATA:
      lr_model type ref to cl_salv_wd_config_table,
      lr_col type ref to cl_salv_wd_column.
    lr_col = lr_model->if_salv_wd_column_settings->get_column( 'EMPID' ).
    lr_col->SET_H_ALIGN(value = CL_WD_TABLE_COLUMN=>E_H_ALIGN- CENTER).
          AUTO TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '00', " TableColumnHAlign.auto
          CENTER TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '01', " TableColumnHAlign.center
          FORCED_LEFT TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '04', " TableColumnHAlign.forcedLeft
          END_OF_LINE TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '05', " TableColumnHAlign.endOfLine
          FORCED_RIGHT TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '06', " TableColumnHAlign.forcedRight
          BEGIN_OF_LINE TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '07', " TableColumnHAlign.beginOfLine
    Regards,
    Lekha.

  • How to align text in drawstring method

    hai,
    i'm using drawString method in my application. i'm using it to draw certain data in a editorpane. in that i have to align the text content but i don't know how to align the text in it such as right alignment,left alignment and center alignment...

    JEditorPanes render text on their own, there shouldn't be any reason to call Graphics.drawString() on your own, unless perhaps you are creating custom Views.
    In any case, we cannot help you unless you post an SSCCE .

  • How to align text within an EditText?

    Hello,
    using this simple one as an example:
    var w = new Window('dialog');
    w.preferredSize = [200,100];
    w.et = w.add('edittext', void 0, "Some text");
    w.et.preferredSize.height = 40;
    w.show();
    The "Some text" is placed top-left in the EditText - is it possible to control its alignment, i.e. ['center', 'middle']?
    (just to be clear, I'm not interested in the EditText position within the Window, but just the text within the EditText itself).
    Thank you!
    Davide Barranca
    www.davidebarranca.com

    Davide, use the below example with either left, center, or right.  You have to have the justify line right after the line that creates the edittext box:
    #target photoshop
    var dlg = new Window('dialog','test')
    dlg.txt = dlg.add('edittext',undefined,'this it the text');
    dlg.txt.justify = 'center'
    dlg.txt.size = [200,60]
    dlg.show()

  • How to align text in margin with text in document

    I am using InDesign CS3 and am trying to figure out how to add text to the left of my document where there are figures and tables (so I can later create a table of figures and table of tables). I cannot get the text "Figure 1", "Figure 2", etc. to line up horizontally in the left margin with the figure I placed in the center of the document. What am I doing wrong?

    > What am I doing wrong?
    It's hard to say what you're doing wrong without first knowing what
    you're doing. How are you trying to line up text with figures? In what
    way does it not work?
    Kenneth Benson
    Pegasus Type, Inc.
    www.pegtype.com

  • How to align the JLabel to the center

    Hi,
    I made a JFrame and a JLabel, I want to put the JLabel to the center of the North position. But it doesn't work, it's just placed in the upper left corner. I tried to use html code, such as:
    JLabel l = new JLabel("<html><h1><center>Hello</h1></html>");
    And then put it in the JFrame's north position, but it doesn't work either. What should I do?
    Thx
    Adrian

    Oh, sorry,
    I just found out the function on how to align it to the center, it's
    JLable.setHorizontalAlignment(JLabel.CENTER);
    Please forget about this question.

  • How to align text at the top and bottom of a cell?

    I'm making a periodic table and need help with aligning text at the top and bottom of a cell. I'll have a picture in the middle of the cell with text above and below the pic. Thank you in advance for any kind of suggestions you can give me.

    It sounds as though you want to have 3 separate items inside of a single cell; text at the top of the cell, text at the bottom of the cell, and then a picture in the middle of the cell.  I am no expert, but to my knowledge that is not possible (someone please correct me if I am wrong.)  I also cannot figure out how to put a picture inside of a cell itself.
    I do have a way to accomplish the end result so long as what you need is the final look and not a useable table in numbers.
    Create 2-3 cells for each element.  (The middle cell, unless you can put pictures in a cell and I don't know, would just be there for peace of mind, but would hold the picture if you can, I would just do two if the pictures are to be in front of the cell anyway.)  The top cell align text to top on the Text tab of the inspector.  The bottom cell, align text to bottom on the same tab.  Then place the picture in the middle.  Now, you have what you want except there is one or two lines dividing the cells.  To get rid of this, either click the middle cell if you have one, or the top or bottom cell.  Click on the Cell tab of the inspector.  Select the bottom border and/or top border button and select "No Border" under border styles.  To make this fast, select a full row at a time, or use command click to select all of the same type of rows (middle, top, or bottom) and change all cells at once.
    I hope this helps.  Best of luck!
    ~Bret

  • How to align text to another text box

    I am very new to Indesign and I am signed up to Lynda.com so watching few a lot of tutorials, that said I need help with aligning text.
    I have a text box that is 100mm across. It has text centered. "£5"
    then above this I have in a smaller font saying "from"
    from
    £5
    I need to get the "f" of from to line up with the beginning of the £ sign? So that If I change the price to £500 the from sticks to the "£" Sign.
    To explain again the from needs to align to the left of the centred text.?
    Hope that make sense?
    Matt

    This can be done by putting the "from" text into a custom positioned anchored object just before the £ sign. You'll need to set the X coordinate relative to the anchor, and adjust the offset on both x and y to get the positioning where you want it.
    I'm sure there are lessons on Anchored Objects on Lynda.com.

  • Does anyone know how to select text in Appleworks, click on the font button and then be able to scroll thru all the font so that one can see the text change as you scroll down the list, at present  I have to do it one font style at a time and then repeat

    does anyone know how to view text in Appleworks, to be able to click on the font button and then be able to scroll thru all the font so that one can see it change as you scroll down the list, at present  I have to do it one font style at a time and then repeat? Thanks jl

    Welcome to the Apple forums
    Your question really belongs in the AppleWorks community/forum.
    You can turn on fonts in actual type in the AppleWorks preferences.

  • How to align text to left of tabbedpane

    I am trying to align my text in a tabbedpane and it only centers, is there a way to make the text within the tab left aligned?
    Here is my code:
    ================
    tabbedPane.addTab("Step 1/Campaign",null, new CampaignPanel(),"General Campaign Information");
    tabbedPane.addTab("Step 2/MOP", null, new MOPPanel(),"Method of Payment Entry");
    tabbedPane.addTab("Step 3/Shipping", null, new ShipPanel(),"Shipping Information Entry");
    I have tried to use HTML in the text by <P align="left">some text</P>, but that didn't do it.
    thanks
    Dean
    tabbedPane.addTab("Step 4/Leads", null, new LeadsPanel(),"Load and test Campaign Leads");

    If you want to change the layout of the text inside a tab, one solution is to override the layoutLabel method the BasicTabbedPaneUI... it's kinda complicated so I'm hoping someone out there has a better solution.
    Anyway, the line to look at in layoutLabel is:
    SwingUtilities.layoutCompoundLabel(
    (JComponent) tabPane,
    metrics,
    title,
    icon,
    SwingUtilities.CENTER,
    SwingUtilities.CENTER,
    SwingUtilities.CENTER,
    //SwingUtilities.TRAILING,
    SwingUtilities.CENTER,
    tabRect,
    iconRect,
    textRect,
    textIconGap);
    Here you can specify where things go in the tab. Arguments 5-8 deal with the text position and text position in relation to the image.

  • How to align text in Panel Box to the center

    Hi,
    I would like to align the text in the Panel Box to the center. Here is my code snipplet:
    +<af:panelBox text="22" id="pb8"+
    titleHalign="center" ramp="highlight"
    background="dark"
    icon="/images/warningind_active.gif"
    showDisclosure="false"
    contentStyle="height: 50px; width: 100%; horizontal-align:center;">
    +<f:facet name="toolbar"/>+
    +<af:outputText value="Update RFC with Approval Info"+
    id="ot8"
    inlineStyle="font-size:medium; font-weight:bold;"/>
    +</af:panelBox>+
    But it didn't work. The text "Update RFC with Approval Info" is still align to the left by default.
    Any ideas?
    Thanks.
    -Mina

    You can't do it without panelGroupLayout. Try this way...
            <af:panelBox text="PanelBox1" id="pb1" titleHalign="center" ramp="highlight"
                background="dark">
                <f:facet name="toolbar"/>
               <af:panelGroupLayout id="pgl1" layout="horizontal" halign="center" valign="top">
                <af:outputText value="***centered***" id="ot1"/>
               </af:panelGroupLayout>
            </af:panelBox>

  • Why is InDesign6 rendereing left-aligned text as right-aligned?

    I have a Word Document and we're feeding it to InDesign 5.5 and InDesign 6. The text are left-aligned and were rendered as such by 5.5. InDesign 6 renders it as right-aligned. I'm not sure why this is happening!
    Microsoft Word
    Indesign 5.5
    InDesign 6

    ^ I don't think so. I'm on a trial version that I downloaded from the english site.

Maybe you are looking for

  • How can I install Windows on my new Mac?

    This question sounds simple, but I am going nuts. I got this MacBook Pro recently, and I need Windows (to run ArcGIS 10). I know it can be done, and in fact is very common. However, I'm stuck. Here are the problems: - Only Windows 8.1 is currently av

  • Custom tab order Acrobat Pro 8.0

    I just switched from Acrobat Pro 7.0 to 8.0 and I'm already lost. I have forms that have a hundred form fields on each page, and I need to set them to tab in a specific order. When I used Pro 7.0 it was a simple matter to skip any form field which di

  • Totem Movie Player not playing files online

    well Hello. I have one problem, when i try to play Video online, like this site: http://www.lrt.lt/ltv-LT-high.asx (it's for Lithuanian users) tv online, to watch olimpiad, i get nothing, it just auto cancel playing. Well then i tryed to add that Lin

  • Syntax check for PL/SQL code??

    is there any tool with which we can check the syntax for code written in Pl/ SQL??? Please help...

  • .xhtml file in ADF stack

    Hi Experts, can we have "*.xhtml*" file in ViewControler project instead of .jspx file ? thnks