Fixed tab position in Java

Hi.
I wonder if it is possible to make a fixed tab (tabulator) in Java in order to print text in straight columns.
In the example below I sometimes need to use one Java-tab and sometimes two in order to make two straight columns. But if a new animal is added, I don't know what number of tabs I need to add!
System.out.println("Ape" + "\t\t" + "Brown")
System.out.println("Pig" + "\t\t" + "Pink")
System.out.println("Hippopotamous" + "\t" + "Grey")
System.out.println("Hummingbird" + "\t" + "Unknown color")Edited by: suladna on Oct 28, 2008 11:27 AM

There's no such thing as a "Java tab." A tab character is just a tab character. How it gets displayed depends on the program, terminal, etc. that's rendering it. In terminal windows it generally means something like, "advance to the next column that is an even multiple of 8", so it might advance anywhere from 0 to 8 positions. It does NOT mean (in any terminal I'm aware of) anything like Word's fixed tabs.
If you want columns to line up, you should use formatting.
[http://java.sun.com/javase/6/docs/api/java/io/PrintStream.html#printf(java.lang.String, java.lang.Object...)]
[http://java.sun.com/javase/6/docs/api/java/lang/String.html#format(java.lang.String, java.lang.Object...)]
[http://java.sun.com/javase/6/docs/api/java/util/Formatter.html#syntax]
[http://www.google.com/search?q=java+string+format+tutorial&btnG=Search]

Similar Messages

  • How to fix the position of JInternal frames added in JFrame

    Hay Frnds, I am having a problem. I have a JFrame ,in which i have added five JInternalFrames. My problem is that i want to fix the position of thaose Internal frames so that user cant move them from one place to other. Is there any way to fix there position. Plz reply as soon as possible. Its very urgent.
    Thanks.

    In Jframe I added one rootPanelI don't know what a rootPanel is or why you think you need to add one.
    The general code should probably be something like:
    frame.add(userPanel, BorderLayout.CENTER);
    frame.add(buttonPanel, BorderLayout.SOUTH);
    frame.pack();Read the section from the Swing tutorial on [Using Layout Managers|http://java.sun.com/docs/books/tutorial/uiswing/TOC.html] for more information and working examples.
    For more help create a [SSCCE (Short, Self Contained, Compilable and Executable, Example Program)|http://sscce.org], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • Indent here with left indent changes tab position

    I have a sheet set up with a left indent and then a bunch of tabs.
    e.g.: Course #, Course description, then a set of eight tabs with dates
    The course descriptions are twice as long this year and so I was using indent-to-here (because there are rules below, and shift-return pushes the rule below under the second line only). But the tabs don't line up. They are "looking" at the left indent and making an adjustment - if I increase the left indent then the tabs associated with the indent-to-here line move left (the bigger the left indent the further left they are from the tab position)
    Why?
    Why would anyone want that to be the default behavior?
    I can fix it with a second para style, but it breaks the association between the two lines of the description and now requires manual updating in the future, instead of a simple indent-to-here substitution.
    I'm just wondering why this happens, seems completely counter intuitive - tabs should always align!

    Will: As you can see by the screenshot it's easily "solved" with a second style, my reason for writing is why is this happening? - is this a bug that needs to be reported to Adobe? I don't understand why an Indent Here (given a left Indent), would change the primary attributes of tabs (i.e. lining-up!)
    Peter: Prefs trashed; happens on any/all docs; CS6 (8.0.2). [You are setting a left indent, and then using the Indent Here (Cmd\)??]
    Anyone else able to recreate?
    Appreciate the replies.
    Em

  • Missing triangle on Fix tab

    Running Premier Elements 10 version (20110914.m.17521) on Windows XP SP3
    In Organizer, to get to 'Edit Video' all instructions say to click on the down triangle on the Fix tab. Problem is my Fix tab has no down triangle See screenshot (click it to enlarge). Anyone else have this problem? Or know what to do about it?

    You should have the diamond, but clearly not.
    Some questions:
    Have you customised font size or dots per inch in Windows settings?
    If so revert them back
    Have you the latest QuickTime installed?
    If not, if not install it.
    Have you customised performance settings?
         If so reset them
    Control Panel (classic view)
    System
    Advanced Tab
    Performance Settings
    Let Windows choose ...
    Apply
    Cheers,
    Neale
    Insanity is hereditary, you get it from your children

  • How do you fix the position of an object vertically only ("static" position horizontally)?

    I want to fix a "title" bar of a table vertically, but allow it to scroll with the rest of the page content horizontally. At the moment it's position is "fixed" which fixes the position vertically but horizontally too. I would like to have the coloured cells move horizontally with the rest of the table in the case that the browser window is not wide enough.
    Can this be done? If so, how?
    (this picture shows that the horizontal positions are different - would like them to remain in line with each other)
    Sorry if this is a silly question, I've only started using Dreamweaver yesterday... Thank you in advance for any help and advice.

    If you want to align your item horizontally center, left or right (along with other website content), you can put that item within a fixed position container, then align the item within the container however you see fit.
    <html>
    <head>
    <title></title>
    </head>
    <body>
    <div id="container" style="position:fixed; top:0px; height:100px; width:100%; border:1px solid orange;">
         <div id="item" style="width:300px; margin:auto; border:1px solid black">Some Content</div>
    </div>
    </body>
    </html>
    In the simplified example above, the container div is fixed to the top of the page, the item div is also then fixed at the top, however using css, it is  centered to the browser window. The border properties are there for illustrative purposes

  • How to fix the position of JInternalFrames added in JFrame.

    Hay Frnds, I am having a problem. I have a JFrame ,in which i have added five JInternalFrames. My problem is that i want to fix the position of thaose Internal frames so that user cant move them from one place to other. Is there any way to fix there position. Plz reply as soon as possible. Its very urgent.
    Thanks.

    import javax.swing.plaf.basic.*;
            BasicInternalFrameUI internalframeUI = (BasicInternalFrameUI)frame1.getUI();
            internalframeUI.getNorthPane().addMouseListener(new MouseAdapter() {
                public void mouseReleased(MouseEvent evt) {
                    frame1.setBounds(0, 0, frame1.getWidth(), frame1.getHeight());
            });

  • Indent /tab position for text from INCLUDE texts in SAPscript

    Hi, ABAP colleagues!
    Need your help on this sapscript problem:  How to align texts taken from "INCLUDE TEXT" in SAPscript, according to tab defined in Paragraph Format?
    Or, how to control tab positions for texts which were extracted from “INCLUDE text” commands in SAPscript?
    I defined a paragraph format with tab stop at 8 CH so that with 2 commas (,,) my text will be displayed there.  However it always appears to the left (e.g. 1st column) and not indented at the proper column for description/text (e.g. which is in second column). 
    Pls help, bec a different heading and information is not acceptable to client for the Thailand characters. 
    Above is the description of the problem.  Below are some technical details.
    For specific example, I am editing Zversion of standard sap MM form MEDRUCK Window Main -  Text Element Item Text.
    BG ,,&TTXIT-TDTEXT&
    /: INCLUDE &T166P-TXNAM& OBJECT &T166P-TDOBJECT& ID &T166P-TDID&
    /: NEW-PARAGRAPH BG
    So far, tried these approaches:
    PARAGRAPH
    NEW-PARAGRAPH
    LANGUAGE '2'
    THANGSAN font
    Any ideas?
    Thank you so much in advance for all your help. Our project team will really appreciate it. May the Lord bless you as we go through our SAP work!
    Sincerely,     
    Celeste

    Hello Caleste,
    Please let me know what settings you have done to solve this issue.
    Help me with steps for Spool Request/Print settings.
    Regards!!
    Surya

  • Script Paragraph Format-TAB position Problem....

    In Script- Medruck , There is a line:
    IM   ,,,,,,Qty. ,,Unit   ,,Deliv. date ,,,,&ETUHRTXT&
    where IM is a paragraph format with TAB positions at:2,3,23,24,34,40,51,57.
    what is the meaning of ,,,,,,Qty ????
    what is the difference in writing :
    IM ,,Qty,,Unit,,Deliv. date,,&ETUHRTXT&                                 AND
    IM   ,,,,,,Qty. ,,Unit   ,,Deliv. date ,,,,&ETUHRTXT&
    How would the Display look like??

    Hi Srikar again,
    If you are putting one tab position after every field, in this case count tab position from the starting i.e. from first variable and go on countin till end . This will take you adding position one after other and it will not overlap.
    e.g. Mat,,qty,,price
    and tab position as 1 : 5  2: 10 3: 15 4:20
    then mat will start at 1 to 5 and qty will from 10 onward.
    Regards,
    Vijay

  • Tab position change at runtine of tab canvas

    Dear gurus,
    Is it possible to change tab position of tab canvas at runtine in 10g forms?
    George.

    Gerd: Thank you very much for your advice.
    I will explain my situation. I have a form : INV. This has got three tabs : Header, Detail and Expenses. Some users prefer to see Header as the first tab while others want to see Details and still others like to see Expenses.They have their logic - what is important to that particular user he wants to see as the first tab.
    These preferences can be set in a different table(by an admin user) and can be applied once when the form opens and not during the runtime.
    Since tab order change facility is not available in forms, I need to apply the logic in a different way - activate the tab that each user prefers to see as the form opens regardless of the tab order.
    Hope you understand my case.
    George.

  • Fixing the position of TitleWindow component.

    Hello,
    I am trying to create an application which has different pages using Flex. Each page is a Flex Title window.
    When I click on an icon in the main application window, another page should open (which is actually a title window).
    I am trying to fix the position of title window from moving. I should not be able to drag title window in the browser.
    I am trying to find a way but was failing each time
    Can you please help me in resolving this problem?
    Thank you for your cooperation.
    Cheers,
    KK

    Try using a Panel component instead of TitleWindow.
    HTH,
    Kenny Yates

  • SAPscript - Tab Position need more info

    Greetings.
    Could some one help me to explain the purpose of the tab position and what is  SIGN mean for Alignment attributes.
    In the tab position we can declare many TAB position, if we declare Number -1 Tab Position -17.00 CM Alignment - SIGN
    is it mean when we put , is it the position of the characters will be at 17cm from the left?
    Thank you.

    Hi,
    If you give the First tab position as 14 & 2nd Tab position as 17 c.m., it mean the first printing text starts at 14 C.M. and 2nd text starts from 3C.M.(17-14) next to 1st Tab Position (14c.m), i.e., the difference betn 1st Tab & 2nd Tab will 3 c.m.
    NOTE: Always any tab position starts from Origin not from the previous tab position.
    U dont need to give 2 couple of comma's for 2nd tab position.
    Eg:
    If you want the Text2 at 2nd tab position, u have to print like below:
      P1 ,,text1,,text2
    If you want the Text1 at 2nd tab position, print like below:
      P1 ,,,,text1
    Hope its clear!!
    Rgds,
    Pavan

  • Tab positions in sapscripts

    I am trying to change a paragraph format such that the tabs contain positions and so the text is displayed starting at a specific position in the document. But adding the tab positions is not moving the actual text. What could I be doing wrong?

    CP is the paragraph format
    CP        Contact Person                  LEFT           0,10  CM    0,00  CM
    15.00  CM          LEFT
    This is how I am using it
    CP           &acc-sydt&,,&acc-contact&,,&PAGE& / &sapscript-formpages(2)&
    This is the window it is been used in
    DATE       Date, Your contact and page    9,70 CM   2,00 CM  10,00 CM   1,00 CM
    Now I would expect the contact text to start from 15.00 cm. But it does not, it starts right after the date

  • Find Tab position

    Hi All,
    I need to find the tab position and alignment, and change the following:
    1. Change the first tab in the paragraph (Left align tab into Center align tab)
    2. Change the second tab in the paragraph (Left align tab into Right align tab)
    Before script:
    After Script:

    Hi Chinnadk,
    Excellent Stuff!!!!!
    But there is a small confusion, what I explain in the above thread.
    Please refer the below screenshots:
    After using the below script:
    var paras = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements();
    for(var i=0;i<paras.length;i++)
        var tabstops = paras[i].tabStops;
        if(tabstops.length>1){
            tabstops[0].alignment = TabStopAlignment.CENTER_ALIGN;
            tabstops[1].alignment = TabStopAlignment.RIGHT_ALIGN;
    Output looks likes:
    But the Final Requirement is,
    1. Extend upto the end of textframe
    2. Equal space between the three entry
    I need a script for the following things only
    Once again Great thankful, If you help for this request.
    Could anyone help for this complex task?
    Thanks for All
    Siraj

  • Script TAB position issue

    Hi,
    I have an issue in creating Tab position under Paragraph section.  I have to display a column like which 10 character length and it is numeric value and also it needs to right justified. 
    if i make the tab right justified .. will system start printing it from right to left or left to right? this is my question.

    Hi,
    if it's right justified it will work as below,
    say you have a tab format
    P1 5CM Right justified,
    in this case it leaves 5CM from the left side of your window & then starts printing from RIGHT TO LEFT.
    say if it's left justified output is,
    >--5CM---->TEST
    right justified output will be,
    >----
    >TEST.
    >--5CM>
    hope this helps.
    Regards,
    Raghavendra

  • Just upgrade to 33.1.1, terrible! new tab position not configurable, no response for clicking a link, how can I have the old version? Thanks!

    Just upgrade to 33.1.1, terrible! new tab position not configurable, no response for clicking a link, not going to the website by click "enter", "space" keyboard can not be the page down anymore, always die....
    how can I have the old version?
    Thanks!

    Just to clarify, let's say you have tab 1 Google results and tab 2 something else. When you Ctrl+click a link in tab 1, it opens between tab 1 and tab 2 instead of at the end? Here's how you switch that:
    (1) In a new tab, type or paste '''about:config''' in the address bar and press Enter. Click the button promising to be careful.
    (2) In the search box above the list, type or paste '''tabs''' and pause while the list is filtered
    (3) Double-click the '''browser.tabs.insertRelatedAfterCurrent''' preference to switch it from true to false.
    You can switch back to an earlier tab and test. Success?

Maybe you are looking for

  • Transaction code for mass cancelation of delievry document and sales docume

    Dear All, Is there any transaction for mass cancellation of delievry document and sales docume. any suggestion Thanks with Regards Subrat Edited by: subu sd on Jul 15, 2009 7:49 AM

  • Someone please tell me how to get this stupid album artwork on my iPod!!!

    okay, i know several people have posted question after question about this problem and no one has yet to answer it fully. i have collected album artwork to the songs on my iTunes, checked that stupid show album artwork under "get info", and now i don

  • Load-balancing with transactions

    I have a question about how transactions are handled in EJBs running in           a cluster. Consider the following scenario where a client starts a           transaction and then calls multiple methods on a stateless session           bean. Since th

  • Keyboard doesn't show to type id apple password!!

    Whenever I need to type my password from id apple (to update or buy app on app store) the keyboard doesn't appear. I can't submit my password and update my apps on ipad1. Any ideas?

  • Permission denied after changing short name

    i have tried searching for answers but still no luck. im kinda scared mdealing with the terminal but have tried a few but to no avail. i hope somebody helps me with step by step solution as im not really well versed with mac yet. thank you.