Fixed field for numbers?

Hello
My program is to read numbers from file, and present these according to my specifications. I have succsessfully forced the output using DecimalFormatSymbols and pattern, with one exception: they do not have a fixed outputfield. I want this to be able to align the numbers at their decimal point, despite how large the numbers are.
I know I can make a method that inserts blanks in front of the number to fill out the space. In the case the number is too large, I can adopt a FORTRAN style: ******** instead of the number. However, I would like to be consistent, and find a solution using i18n methods. And frankly, I find it hard to believe that the DecimalFormat do not support decimal-aligned formats. So, what am I missing? Can you help me?
Regards
JT

The NumberFormat api mentions two ways to align output.
import java.awt.*;
import java.awt.font.*;
import java.text.*;
import javax.swing.*;
public class Alignment
    public static void main(String[] args)
        double[] numbers = {
            100.95, 1.1234567, 21.19, 888295.16, 99.1525, 8, 16.75, 12.2
        AlignmentPanel alignmentPanel = new AlignmentPanel(numbers);
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(alignmentPanel);
        f.setSize(400,400);
        f.setLocation(200,200);
        f.setVisible(true);
class AlignmentPanel extends JPanel
    Font font;
    NumberFormat nf;
    String[] text;
    final int
        top           =  50,
        decimalOffset = 100;    // from decimal to right edge of page
    public AlignmentPanel(double[] numbers)
        setBackground(Color.white);
        font = new Font("lucida typewriter regular", Font.PLAIN, 24);
        nf = new DecimalFormat("#.####");
        formatInput(numbers);
    protected void paintComponent(Graphics g)
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setFont(font);
        int w = getWidth();
        int h = getHeight();
        FontRenderContext frc = g2.getFontRenderContext();
        float yPos = top;
        for(int j = 0; j < text.length; j++)
           String toDot = text[j];
           // get substring up to decimal point - integer portion
           if(text[j].indexOf(".") != -1)
               toDot = text[j].substring(0, text[j].indexOf("."));
           // get width and height of integer portion
           float width = (float)font.getStringBounds(toDot, frc).getWidth();
           LineMetrics lm = font.getLineMetrics(toDot, frc);
           float height = lm.getHeight();
           float x = (w - width - decimalOffset);
           float y = yPos + height;
           g2.drawString(text[j], x, y);
           yPos += height;
    private void formatInput(double[] n)
        text = new String[n.length];
        int maxFractionLength = 0;
        for(int j = 0; j < n.length; j++)
            text[j] = nf.format(n[j]);
}

Similar Messages

  • How do I create a form with fixed fields for clients to complete?

    I want to create a form in pages that I can then save as a pdf to load on my website so my clients can download and fill in the fields without messing with the overall formate of the sheet.

    Sorry, not sure I am clear. I want a form w/ name, address, etc.  I want to be able to send it as an email to people to fill out and also load it to my website for people to download, fill out, and email back to me.
    My concern is I there are fields that they can write sentences and I want to control how much they write so it doesn't mess up the formatting when I go to print.
    thanks

  • How to set fixed size for inputfile text field

    Hi all,
    I am using inputfile component to test file uploading so I created a simple upload page. When I finished upload the file, the input text field will "shrink" its size and change the size to adjust the file name. Is there any way to set a fix size for input text field?
    Here is some part of the code:
    <af:form id="f1" usesUpload="true">
    <af:panelHeader text="File Uploader" id="ph1">
    <af:inputFile label="File to upload" id="if1" autoSubmit="true" valueChangeListener="#{fileBean.fileUpdate}"
    value="#{fileBean.file}" partialTriggers="if1"
    columns="50"/>
    </af:panelHeader>
    <af:commandButton text="Save" id="cb1"/>
    FileBean:
    public void fileUpdate(ValueChangeEvent valueChangeEvent) {
    RichInputFile inputFileComponent = (RichInputFile)valueChangeEvent.getComponent();
    UploadedFile newFile = (UploadedFile)valueChangeEvent.getNewValue();
    UploadedFile oldFile = (UploadedFile)valueChangeEvent.getOldValue();
    Thanks,
    Jerry

    you can set columns attribute in af:inputfile. Please see highlighted area i have inserted to you code
    <af:form id="f1" usesUpload="true">
    <af:panelHeader text="File Uploader" id="ph1" columns = "34" >
    <af:inputFile label="File to upload" id="if1" autoSubmit="true" valueChangeListener="#{fileBean.fileUpdate}"
    value="#{fileBean.file}" partialTriggers="if1"
    columns="50"/>
    </af:panelHeader>
    <af:commandButton text="Save" id="cb1"/>

  • How to validate an text field item using javascript for numbers only.

    hi,
    how to validate an text field item using javascript for numbers only.please help me on this urgent
    please mail me solun if posible on [email protected]

    Hi,
    Page HTML header
    <script>
    function onlyNum(evt) {
      // Usage: onKeyPress="return onlyNum(event)"
      evt = (evt) ? evt : window.event;
      var charCode = (evt.which) ? evt.which : evt.keyCode;
      if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        var status = 'This field accepts numbers only!';
        alert(status);
        return false;
      var status = '';
      return true;
    </script>Item HTML Form Element Attributes
    onKeyPress="return onlyNum(event)"Br,Jari

  • Is there a way to create entry form/fields in Numbers.

    Can anyone let me know if there's a way to create an entry form/field in Numbers. The idea would be to have already created a list of contacts, then at an event on an iPad, people can check off if that person is there and also enter new contact info. Thanks in advance.

    Isnt this just a table? A list of people, with a check box field in the second column, followed by a few columns for contact info to be entered in?
    Jason

  • Field business area is a required field for G/L account BP01"

    Hi SD experts,
    While doing MIGO transaction, I get this error message : "Field business area is a required field for G/L account BP01", eventhough the document is OK when I click on check.
    What does this mean and how can I fix this problem ?
    Thank you,
    Bahia.

    Dear Bahia,
    T. Code: FS00
    Key-in G/L A/c No. & Company Code "BP01" and go to -
    Tab: Create/Bank/Interest --> Feild: Field Status Group.
    Note down it. Now,
    Go to, T. Code: OBC4
    Select line for FStV: BP01, and click: Field Status Group (from left)
    On to next page, search for the Field Status Group, which you have noted down in T. Code: FS00.
    Double-click on to Field Status Group.
    On to next page, under Tab: Select groups, double-click on to "Additional account assignments".
    Now, for "Business Area" maintain field entry as either "Optional" or "Suppress", as reqd.
    Best Regards,
    Amit.
    Note: A reference:
    [Reference|Field Bus. Area is a required field for G/L account 1000 30400011]

  • Field Segment is a required field for G/L account

    Hi Friends,
    Could some one help me out in solving the below issue.
    I am getting the below error message while running the depreciation run.
    "Field Segment is a required field for G/L account EM01 480000
    Message no. F5808
    Diagnosis
    The value for field "Segment" in the interface to Financial Accounting is an initial value but you are required to make an entry in the field selection for G/L account "480000" in company code "EM01" linked to the field selection for posting key "40".
    System Response
    Error
    Procedure
    It might be an error in the configuration of the G/L account field selection. The initial application, used to call up the interface must otherwise define a value for field "Segment". If this is the case, contact the consultant responsible for the application used to call up the interface or get in contact with SAP directly.
    Please let me know,how can i fix this.
    Thanks,
    Diwakar
    Moderator: Please, search SDN

    Please check the field status group assigned to your GL account 480000 (Transaction FS00 > Interest/ Bank Details tab.) and then check the field status in transaction OBC4 for this field status group for the field Segment.
    Also check the field status  of your posting key in OB41.
    Regards,
    SDNer

  • Determine Fields for Business Card on Area Page -  does not show on portal

    Hi,
    I'm trying to add new fields on the overview page of service personal data IT0002
    I found "Determine Fields for Business Card on Area Page" in customizing and added new field, but it doesn't show in ESS portal service.
    Does anyone have any advice what I need to do to make it work?
    Settings
    Infotype 0002
    Infotype Vers. 09
    Structure name: HCMT_BSP_PA_DK_R0002 / HCMT_BSP_PA_XX_R0002
    Field name   Long field label   Position
    FAMST        Marital status      4
    Br. Olof

    Bizcards is only customizable via IMG as of EHP3
    Lower releases might require additonal steps/modifications
    For EHP3 you need to ensure you are using EHP3 software components and have EHP3 business
    function switched on (be careful though switching on this function is only reversal via restore to point in time
    before switching it on) - also check note 1159911 if you  have switched this one and/or see no fields
    Worth also trying the following
    Check V_T7XSSPERBIZFLD for existing fields and positions
    Add supplementary fields and position numbers to V_T7XSSPERBIZFLD
    OR
    Check V_T7XSSPERBIZFLD for existing fields and positions
    Overwrite required positions and fields in V_T7XSSPERBIZFLC
    Best wishes
    Stuart

  • Work Around For Numbers Crashing

    Work Around For Numbers Users:
    For those of us who have numbers and have had problems with it crashing when scrolling across sheets that have checkboxes try this:  Double select a cell, and use the expanding group to navigate the sheet.  It seems to be stable when doing this.
    3 weeks after the os8 release and still no fix for this?  Pathetic.

    If anyone has been having trouble with upgrading the domain file and iWeb crashes, here is the fix that worked for me:
    http://discussions.apple.com/message.jspa?messageID=5100025#5100025
    *MAKE SURE YOU BACKUP YOUR DOMAIN FILES FIRST!*

  • Solved - Group Fields for Vendor Master Records in IMG

    This was the solution.
    The new field's data element I added to LFB1 did not have the "change document" field checked.  I made that change and now that field shows up in IMG.
    Hello all,
    I added an append structure to the table LFB1.  This structure has 1 field.  I then created a "Modification-Free Enhancement of Vendor Master Record" to add the new LFB1 field to the vendor master screen, edit and display screens.  This is the 3rd time I have done this.  So far so good.
    Now our functional analyst went into IMG to add this new LFB1 field to a "Group Fields for Vendor Master Records" which we have done 2 other times.
    The new LFB1 field does not show up in the list of possible Table-fields.  
    There must be some other step I am missing.
    Does any of this ring a bell?  We are on version 4.7.
    Thanks
    Bruce
    p.s.
    This is the IMG path for adding 'Field Groups' to vendor master fields.
    Financial Accounting/
    Accounts Receivable and Accounts Payable/
    Vendor Accounts/
    Master Data/
    Preparations for Creating Vendor Master Data/
    Group Fields for Vendor Master Records
    Edited by: Bruce Tjosvold on Nov 21, 2008 1:18 PM

    Hi Vandana,
      There are several tables that are contain Vendor Master related data which can be used for extraction to BW. Some of the tables which can be useful for you are:
    LFA1 :  Vendor Master (General Section)
    LFM1 :  Vendor master record purchasing organization data
    LFBW : Vendor master record (withholding tax types) X
    WYT3 :  Partner Functions
    LFBK : Vendor Master (Bank Details)
    LFB1:  Vendor Master (Company Code)
    ADRC: Addresses (Business Address Services)
    ADR3: Fax Numbers (Business Address Services)
    ADR6: SMTP Numbers (Business Address Services)
    ADRT: Communication Data Text (Business Address Services)
    You may use the Data sources mentioned in the previous update from Venky above namely :
    0VENDOR_ATTR --- for master data attributes
    0VENDOR_TEXTS -- For texts
    Since the fields that you are using are from different tables so its better if you go for a Generic Data source where you can use the fields as per your requirement.
    Thanks
    Pawan
    Edited by: pawan190187 on Aug 19, 2011 12:40 PM

  • Additional Fields for Report FBL1

    Dear All
    I need to add User Name field (USNAM) and few other fields to the layout for report FBL1(Vendor open line items).
    I have added the field USNAM under "Define Additional Fields for Line Item Display". But the field is still not showing up for selection in the report FBL1.
    Pls advice.
    Rgds
    Nitika

    Hi Nikita,
    Once you have added special filed you have to run the below mentioned program to extend the new filed in FBLxN report.
    Run below program from SE38:
    RFPOSXEXTEND
    BALVBUFDEL
    The correct way to fix this is mentioned in SAP note 984305. Running report BALVBUFDEL resets the buffer.
    The special field is now available in the layout selection.
    Hope this helps.
    Pls assign points as way to say thanks

  • Hi, Finding fixed vendor for material

    Hi,
    my  requirement is to  copy the fixed vendor address to text object( available in the text tab of the VA01 transaction).
    I am entering the article numbers in the va01 transaction with some 5 item numbers.
    i am getting the Purchase requisition number(BANFN) and BNFPO( purchase req item number) from the VBEP table .
    after getting the BANFN & BNFPO i have to pick the fixed vendor for the corresponding item number from EBAN.
    EBAN is holding the values for only the last item number .
    can u please tell me the internal table associated EBAN.
    I am using the USEREXIT_SAVE_DOCUMENT from the include MV45AFZZ.
    Is there any other way so that i can pick fixed vendor for an given article.?
    Advance thanks
    regards
    paveee....

    Hi
    try this
    1) In sorce list fixed your vendor for material and plant combination ME01
    2) for another source create info record for second vendor and material ,combination in ME11
    Regards
    Kailas ugale

  • FIXED FIELD LENGTH is not constant

    Hello Guru's,
        This is the question asked in IBM .
    What will you do if field length of a field in flat file is not constant or not equal to the FIXED FILED LENGTH ?.
    i.e. f1 is of length is 10 and in one row its length is only 9 what will happen and what will you do to overcome this situation.( consider its a FILE TO FILE SCENARIO )
    can anyone help me in this regard.
    Thanks in advance.

    >     This is the question asked in IBM .
    > What will you do if field length of a field in flat file is not constant or not equal to the FIXED FILED LENGTH ?.
    > i.e. f1 is of length is 10 and in one row its length is only 9 what will happen and what will you do to overcome this situation.( consider its a FILE TO FILE SCENARIO )
    The ans for this question is very simple.
    Since your FIXED FIELD LENGTH is 10 correct. now if any value comes of length 9 or less, then there will be no problem at all. It will work perfectly without doing anything. BUT if your length goes beyond 10 then it will throw an error message which you can see in RWB.
    Shorter length is never a problem in case of FIXED FIELD LENGTH.
    I hope now you got the ans, but good way to learn is, to create a simple scenario and test it. )
    Regards,
    Sarvesh

  • Fields for Selection on selection screen - Data Dictionary

    Hi,
    I have an issue while selecting the required fields for selection on the Standard table.
    VBAK --> Settings > Fields for Selection> Select required fields and save it as a variant.
    It looks good for that day but it again changes to the standard selection fields on the selection screen.
    Is there any way that i can keep the Fields for selection on the selection screen ?
    Any suggestion will be appreciated!
    Regards,
    Kittu

    Hi Kittu,
    The SE16 tool generates Selection Screens automatically for the Table and chosen fields therein the user selects. Unfortunately the tool is User Independent, thus other users can change the fields for selection thus rendering any Variants created useless. This is because of internal numbering identifiers for fields instead of field names making up the variant. SE16 has always being regarded as a development tool hence its limited functionality.
    I however may suggest that you could utilise ABAP Queries instead by way of transaction SQ01/SQ02 or SQVi. These may offer you a better solution.
    Best of luck,
    Derrick Hurley
    ABAP Development Workbench
    SAP
    Edited by: Derrick Hurley on Mar 31, 2011 4:01 PM
    Edited by: Derrick Hurley on Mar 31, 2011 4:01 PM

  • Databse of 1888 Byte Per Record with 259 Fixed Fields Stumped CR?!?

    My Database of  15 million records/rows at 1888 Byte Per Record with 259 Fixed Fields STUMPED CR?!
    Executive Summary :
    I have lots of data. There are 15 million of records in some of my database files. But I need to drill into the data and get counts for each field.
    I need to know how many times each data field (row) is populated in a database file. For example,  how many of my records have last name? how many have first name? date of birth? etc.  I need a simple report made using SAP "Crystal Reports 2011" Workstation type edition that SUMS each data  row into a single column output like csv.
    My database sizes can range from 1,000 to 18 million records that are in fixed field asci format with 1888 bytes and 256 rows per record!  The report  needs to SUM each data field or, in the case of a data field with a minimum of twelve tables, SUM each value of a table.
    My contracted CR programmer is an expert although she was new to data files this humongous. Can anyone here help us get CR to work on my data? Here was her conclusion, Crystal Reports Fail:
    My file is 14.1 gb  as well. However, when run through Crystal Reports, it
    only returns 2,274,876 records. Therefore, I am going to assume that there
    is a Record Limit for Text files of this. I searched through all the
    registry settings and there is nothing that appears to be limiting it. I
    went online for a while to see if there was any information on it, and just
    like when I used to work there, there was nothing concrete. Business Objects
    does not physically test this large of data retrieval, therefore they don't
    know the exact record limits.
    I'm not sure what to suggest, but I don't think Crystal Reports is going to
    work for you and I wouldn't have known that from the beginning without
    testing your data. I'm 99% sure there is a refund policy on the software, so
    you shouldn't have any issues returning it.
    Since I only specialize in Crystal Reports, I'm not sure what other software
    can handle this amount of data. Possibly Cognos, but you may want to find
    out from them or do some research.
    If your data were in a database that can run stored procedures (like SQL
    Server or Oracle) then you could write SQL to only return the counts. Then
    when Crystal connected to the stored procedure, it should work, but I can't
    say for sure without testing it. And I don't have SQL Server or Oracle
    installed on my machine. I believe MYSQL (the free version) has a limit to
    the number of records it can hold and I'm sure 8 million would be over the
    limit. Also, I'm not sure if it supports stored procedures. I have used it
    once before and found it extremely cumbersome and limited. I think SQL
    Server and Oracle are quite pricey, so I don't think that this will even be
    an option for you.

    Hi Shawn,
    I actually contacted the same person you did also. Summer was a Report Designer Resource here and knows her stuff and the Report Designer as much as our Developer who wrote it do.
    As I suggested in my first reply is to get all that data into a real database, one that can run Stored Procedures to do all the crunching unfortunately is the only way I can see this ever working.
    Windows 7 and 8 CPU's doesn't help, 64 bit may but the problem is CR Designer is a 32 bit application so it can't take advantage of the 64 bit memory addressing space.
    What you could so is post your question to the forum:
    [Business Decision Making with BI|Marketing Library;
    This is a forum for managers or anyone who wants to have a non-technical discussion about making informed decisions with analytics tools. Ask questions and share your experiences on how to effectively utilize data to address real business problems. Experts from inside and outside SAP will be monitoring these conversations and offering their knowledge along with the broader community.
    Someone in there may have another SAP product that might be able to load your flat file into a data tool that CR can report off of.
    I still think a copy of MS SQL 2008 Express is your best and likely cheapest solution and then you can simply import the data into it which it has an Import Wizard that makes it relatively easy to do... Although you may have to break your file into pieces for it to be able to process also.
    You need to be flexible on that data source, I doubt you'll find anything that can report off of that huge of text file.
    Good luck
    Don

Maybe you are looking for