How to set MAXIMUM size of a formatted string?

Hello
Assume I have an Object foo with a
toString(){ return "a long name to print"; }and that I want to print it with minimum space of 40, I would say
System.out.printf("foo say: %1$40s", foo.toString() )But I need very often to set a maximum width, so that any strings or fields wider than this is truncated. Eg:
System.out.printf("foo say: %1$5s", foo.toString())gives i.e. "foo say: a l..". Is this possible, using the Formatter class (or similar) in Java? So far I have created my own class to enable this, but I want to use as much predefiend classes as possible.
Regards
Fluid

You need to use a precision argument:
String foo = "a long name to print";
System.out.printf("foo say: %.8s", foo); // 8 maxhttp://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#syntax

Similar Messages

  • JLabel: how to set maximum size in layout?

    I have a BorderLayout that i want to show a JLabel in NORTH. I use HTML in the label message text with one line being centered with <center>. If the overall text of the label is long/big enough, i.e. subsequent text results in line breaks, the cenetered line is cenetered correctly.
    however, if the subsequent text is just small, all lines are left justified/adjusted. i guess, the JLabel dimension is not maximized to the maximum available spave in the NORTH area of BorderLayout.
    I tried adding the JLabel directly or within a JPanel (also with BorderLayout, then with add(label, BorderLayout.CENTER)), also first set the size of the dialog, added all components and just added the text to the label at the last position. doesn't help.

    Tip: putting a border on a JComponent like JLabel helps you see how its parent container is sizing it. I don't know what HTML mark-up you are using, but is the centering necessary?
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class Ex {
        public static void main(String[] args) {
            JFrame f = new JFrame("Ex");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            Container cp = f.getContentPane();
            String text = "Example text";
            Border b = BorderFactory.createLineBorder(Color.BLUE);
            JLabel label0 = new JLabel(text, SwingConstants.CENTER);
            label0.setBorder(b);
            JLabel label1 = new JLabel(text);
            label1.setBorder(b);
            cp.add(label0, BorderLayout.NORTH);
            cp.add(label1, BorderLayout.SOUTH);
            f.setSize(400,100);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • Set maximum size in Text Form Field Options for a field in bi publisher RTF

    Hi All,
    How to set maximum size in Text Form Field Options for a field in bi publisher RTF.
    I have a RTF whch is having a field in that i need to add some validation condition but after adding certain condition in Add help text tab ,it is not accepting after certain length, how i can increase the length to unlimited,please help me on this
    Thnaks

    Form fields have some restrictions if your are using version lower than 11g.
    They can accommodate only 393 chars. You can add the text in both status bar and help key, which can in total consume 393 chars.
    If your code logic is more than that, it can be split into multiple form fields as Avinash suggested or you can use sub template logic and handle coding over there. Again in sub template code can be within/outside form fields.
    So there is no option for user to increase the size of form field.

  • IView Deployment - how to set maximum file size?

    Hello,
    we have a problem while deploying iViews and uploading files to enterprise portal . The maximum upload file size seems to be limited to 1 MB. I have to deploy an iView greater than 1 MB. While deploying with netweaver developer studio I get following error message
    in logfile of developer studio:
    [19.10.04 / 13:33] #ERROR LEVEL#
    com.sap.portal.developmentTools.ideSpecific.eclipse.wizards.sapmakepar.SAPMPWizard$1 > No Information
    java.io.IOException: Error writing to server
    The direct upload of *.par with EP Component Manager also does not work. After clicking upload-button I get a standard http error page "aktion abgebrochen".
    Also on upload of any other document, for example personal documents which are bigger than 1 MB, I get this error.
    If I reduce file size of portal archiv lower than 1MB I can deploy and upload the iView.
    How canI set maximum upload file size in Enterprise Portal?
    Our Version: 6.0.2.4.7.Enterprise_Portal_Service_Pack_2
    Thanks for helping me,
    Nicole

    You need to use a precision argument:
    String foo = "a long name to print";
    System.out.printf("foo say: %.8s", foo); // 8 maxhttp://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#syntax

  • How to modify the blob size, or how to set the size?

    i want to know how to modify the blob size, or how to set the size?
    what's the default size of blob?
    Thanks in advance.

    Blob datatype can contain binary data with a maximum size of 4 GB.
    when you enter 10kb file, the database will only use 10kb to store the file (depending on block size etc)
    if you want to modify the blob size, you may do like this:
    SQL> create materialized view t_mv refresh fast on commit
    2 as select id, dbms_lob.getlength(x) len from t;
    Materialized view created.
    SQL> alter table t_mv add constraint t_mv_chk check (len < 100);
    Table altered.

  • How to set maximum number of jobs in oracle

    Could pls tell explain me about how to set maximum number of jobs in oracle....
    Regd,
    Mahi

    I don't think there is any limit on number of jobs that can be submitted to Oracle. However, there is a limit on the number of processes that would execute those jobs (governed by JOB_QUEUE_PROCESSES).
    Message was edited by:
    Satish Kandi
    Typo corrected.

  • How to set custom size of Close Button e.g. 32x32  of Title Window in Flex 4

    How to set custom size of Close Button e.g. 32x32 of Title Window in Flex 4?

    Hi
    Here is the code of the Button in the skin class of spark title window.
    <s:Button id="closeButton" skinClass="spark.skins.spark.TitleWindowCloseButtonSkin"
                              width="15" height="15" right="7" top="7" />
    So first change the default height and width from 15 to 32. Then in the Button Skin class i.e. spark.skins.spark.TitleWindowCloseButtonSkin change paths to modify the cross symbol.
    Hope this helps
    Rush-me

  • How to set the size of a JTabbedane to the size of the frame

    I have a tabbed pane in a frame, I would like to know how to set the size of the tabbed pane, so that it occupies the whole of the frame which has been set to screen size.
    Thanks

    Is it not possible to use it with a GridBagLayout?Your question was "How do I get a tabbed pane to take all the space of the frame"?
    You where given the answer. Did you try it? Did it work? Then why are you questioning the suggestion?
    Its one line of code if you use a BorderLayout which by the way was specifically designed for this purpose.
    Yes you can do it with a GridBagLayout with about 5 lines of code.
    So the question is why would you want to write 5 lines of code when you can use one?
    If your question was "How do I waste my time forcing the GridBagLayout to size a component to take up all the space of the frame", then you would have received a different answer. (Although most people would have told you to use a BorderLayout anyway, since its easier).

  • How to set display size of a Region or Dynamic Region?

    Hi,experts,
    In jdev 11.1.2.3,
    I drag and drop a task-flow into a jsf page to create a Region,
    and set display size for the region, source code as:
    ===================
    <f:facet name="second">
    <af:decorativeBox theme="medium" id="db1">
    <f:facet name="center">
    <af:panelGroupLayout layout="scroll" id="pgl1"
    inlineStyle="width:1200px;height:700px;">
    <af:region value="#{bindings.trainflow11.regionModel}" id="r1"
    inlineStyle="width:1200px;height:700px;"/>
    </af:panelGroupLayout>
    </f:facet>
    </af:decorativeBox>
    </f:facet>
    =================
    But, the Region is only showed a small fraction area on the parent jsf page whenever during design or run time.
    How to set display size of a Region or Dynamic Region?
    Thanks!

    Hi,
    the decorative box is supposed to stretch components in the center facet, so at runtime the region should stretch. Can you try with a static region to see if this is an issue with dynamic regions?
    Frank

  • How to set percentage size for layout? for example : VBox,HBox,AnchorPane,.

    how to set percentage size for layout? for example : VBox,HBox,AnchorPane,......
    like HTML
    &lt;div width=&quot;640px&quot; height=&quot;480px&quot;&gt;
    &lt;div widht=&quot;50%&quot; height=&quot;60%&quot;/&gt;
    &lt;div widht=&quot;30%&quot; height=&quot;60%&quot;/&gt;
    &lt;div widht=&quot;20%&quot; height=&quot;60%&quot;/&gt;
    &lt;/div&gt;
    -----

    This is not supported. You can file a feature request at http://javafx-jira.kenai.com

  • How to set Queue size in JBoss?

    Hi all,
    I have defined a new queue in JBoss.
    I need to set the size of this queue.
    How to set the size of a queue in jboss?..... Which XML file should be modfied for this?
    Please help me

    Yes You changed session timeout for jmx-console but not your application. I assume You wanted for your app. go: jboss-4.0.2\server\default\deploy\jbossweb-tomcat55.sar\conf\web.xml

  • Maximum size of a Java String

    Hello
    Can anyone please tell me what would be the maximum size for a java string....
    Thanks
    Tapan

    You are asking the wrong questions. If you are going to have a really, really big string then the chances are you shouldn't be using strings.
    If you are trying to parse a file then you want to be reading it in chunks at a time.
    Tell us what you are trying to do and maybe we can suggest a better solution.
    See, I am a nice person. I just don't like people who are too lazy to writepublic static void main(String args[]) {
      System.out.println(Integer.MAX_VALUE);
    } That took me around 10 seconds.
    Ted.

  • C How to Set Isolation Level in the Connection String

    How to Set Isolation Level in the Connection String using the "Microsoft OLE DB Provider for DB2 Version 4.0"?
    We are trying to move from Crystal Reporting that run against a IBM DB2 database on a mainfram to SSRS reporting and we have downloaded the "Microsoft OLE DB Provider for DB2 Version 4.0" and then worked with the DB2 Administrator to create the
    Packages.  We only have access to use the "Read Uncommitted ("MSUR001") package.   We were able to connect and pull data before he removed access to the other packages, but after setting access the Connection keeps trying to use
    the 'Cursor Stability (MSCS001)" package.   How do we change the Default to the "Read Uncommitted ("MSUR001") package???   Since it is keeps defaulting to the the other package
    we can't connect to do it in the T-SQL query, it has to be set at the Connection String level.

    Hi Dannyboy1263,
    According to your description, you want to set the Transaction Isolation Level in Connection String. Right?
    In Reporting Services, the Connection String for OLE DB Connection can only contains Provider, Data Source and Initial Catalog. There's no property for setting Transaction Isolation Level in the Connection String. Based on my knowledge, we can
    only set the Transaction Isolation Level at Query level or set it by using code (C#, VB, Java...) to call the property of Connection. So unfortunately your requirement can't be achieved currently.
    Reference:
    OLE DB Connection Type (SSRS)
    Data Connections, Data Sources, and Connection Strings in Reporting Services
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Set Maximum size for a subpanel created with splitter bars in LV8

    Does anyone know how to set the Maximum size for a subpanel created with asplitter bar? If I show one cluster in the subpanel and use the scroll bar to scroll, I can see more (blank) area than I want. I just want the user to be able to scroll a cluster within a subpanel while the cluster is larger than the view area of the subpanel. I don't want to let the user scroll outside the cluster.
    Ravi Beniwal

    I apologize for the mixup in terminology. Please read Pane wherever the word Subpanel was used.
    Please see the attached VI for a description of my problem.
    I would really appreciate any help with this.
    Ravi Beniwal
    Attachments:
    Pane Scrolling Problem.vi ‏10 KB

  • How to set the size for height of iView tray?

    Hi,
    I have created a ABAP webdynpro component and integrated this comp with iView. Then i integrated iView into Page in portal. That is working fine.
    But the size of tray/window which is displayed in the page is very small.
    How to increase the height of that Tray/window/iView containing my component?

    Hi,
    By changing the maximum automatic height and Minimum automatic height property of the iview you can set the size for height of your iview.
    to do this follow the setps:
    goto content administrator -> portal content -> your folder where you created your iview or directly to your iview -> right click -> open -> object,
    and now in property category choose appearance-Size from the drop down menu and set the above properties to your required height.
    if you want the end user to modify this property set the property to read/write .
    *********please reward points if the information is helpful to you********************

Maybe you are looking for

  • Creative Cloud app gets stuck on spinning wheel on Windows 8.1

    Ok DL the cloud app it never gets to the log in. I used the information like From the same gear icon in Creative Cloud, choose to Quit Creative Cloud.  Rename the OPM.db file that is located in the OOBE folder located here: Mac: ~/Library/Application

  • TICKET Number (TICKETNR) not populated

    Hi, I am trying to create and actualize tickets using following function modules in given a sequence. 1) OIJB_TICKET_DEFAULTING 2) OIJ_EL_A_TICKETS_MAINTAIN_N 3) ENQUEUE_E_OIJTKT 4) OIJB_GENERATE_DOCUMENTS_N 5) ENQUEUE_E_OIJTKT Function modules are w

  • How well does 24" iMac drive a 1920x1200 external display?

    For various reasons that I shall not expound upon, I'm thinking about selling my Mac Pro and replacing it with a 24" iMac. The catch is that I'll need a second 24" display (1920x1200), and I want to be sure that the iMac can drive it without any prob

  • Google Map Missing; Error Message

    Hi! I just published some additional pages. When I went to website, my Google Map is not functioning. I get an Error Message: The Google Maps API server rejected your request. This could be because the API key used on this site was registered for a d

  • Duplicate archivelog sequence on standby database

    Hi, In our standby database when i check archivelog (below command), i see 2 duplicate sequence number. One is applied and another is not applied. Is there any problem with dataguard and how to solve it TQ SQL> sELECT THREAD#, SEQUENCE#, APPLIED FROM