How to align output

How do u align Text in the JOptionPane.showMessageDialog?????
like for example:
mr. Benjamin singapore
mr. christopher malaysia
how do we align everything?

Hi Christopher92,
You may find some inspiration from the following coding :
public static void main(String[] args) {
        JPanel pane = new JPanel();
        pane.setLayout(new GridLayout(2,1));
        JLabel[] labels = new JLabel[2];
        for (int i = 0; i < 2; i++) {
            labels[i] = new JLabel();
            labels.setBorder(BorderFactory.createLineBorder(Color.BLACK));
labels[i].setPreferredSize(new Dimension(100, 30));
labels[i].setHorizontalAlignment(JLabel.TRAILING);
pane.add(labels[i]);
labels[0].setText("mr. Benjamin");
labels[1].setText("mr. Christopher");
JOptionPane.showMessageDialog(null, pane);

Similar Messages

  • How to align output formatted and output text in the same line?

    Hi All,
    I want an output formatted label and a text on the same line,. I've surrounded these components wth a panel form layout and they automatically align one below the other. how do I kepe them in the same line?
    Thanks.

    Try as per the code snippet below:
    <af:document title="TestPage.jspx" id="d1">
    <af:messages id="m1" inline="true"/>
    <af:form id="f1">
    *<af:panelGroupLayout id="pgl1" layout="horizontal">*
    *<af:outputFormatted value="outputFormatted1" id="of1"/>*
    *<h:outputText value="outputText1" id="ot1"/>*
    *</af:panelGroupLayout>*
    </af:form>
    </af:document>
    Thanks,
    Navaneeth

  • Aligning output

    Hi, does anyone know any quick methods on how to align output in java programs. I wrote this program that inputs an item number, name and price and than prints those things in columns, but if someone enters a name too long than all the formatting gets mixed up. Here is the program:
    import javax.swing.JOptionPane;
    import java.text.NumberFormat;
    class Input extends Printout {
         public void Ask(){
              System.out.println("--------------------------------------------------------------------------------");
              System.out.println("                               Comedy Video House");
               System.out.println("                               1225 Programmers Road");
               System.out.println("                               Customer Invoice");
               System.out.println("--------------------------------------------------------------------------------");
               System.out.println("ITEM #\t\t\t\t ITEM NAME\t\t\t\t PRICE");
               System.out.println("--------------------------------------------------------------------------------");
              for (int i = 0; (nIN > 0); i++){
              ItemNumber = JOptionPane.showInputDialog("Input Item Number:");
              nIN = Integer.parseInt(ItemNumber);
              if (nIN <= 0){
                   break;//If item numbere is 0 or less than exit loop
              ItemName = JOptionPane.showInputDialog("Input Item Name:");
              ItemPrice = JOptionPane.showInputDialog("Input Item Price:");
              nIP = Double.parseDouble(ItemPrice);
              System.out.println(nIN + "\t\t\t\t" + ItemName + "\t\t\t\t" + nIP);
              Subtotal = Subtotal + nIP;
              PST = (Subtotal * 0.08);
              GST = (Subtotal * 0.07);
              Total = Subtotal + PST + GST;
              System.out.println(" ");
              System.out.println("\t\t\t\t" + "Subtotal: " + "\t\t\t\t" + formatter.format(Subtotal));
              System.out.println(" ");
              System.out.println("\t\t\t\t" + "PST: " + "\t\t\t\t" + formatter.format(PST));
              System.out.println("\t\t\t\t" + "GST: " + "\t\t\t\t" + formatter.format(GST));
              System.out.println(" ");
              System.out.println("\t\t\t\t" + "TOTAL: " + "\t\t\t\t" + formatter.format(Total));
    public class Printout {
         String ItemNumber;
         String ItemName;
         String ItemPrice;
         int nIN = 1;
         double nIP;
         double Subtotal;
         double PST, GST;
         double Total;
         //set currency format for costs
        NumberFormat formatter = NumberFormat.getCurrencyInstance();
        public static void main(String[] args) {
         Input aInput = new Input();
         aInput.Ask();
       }Thanks

    you could just only show a maximum of whatever number of characters you want to have. for example:
    String name = "Goolahee Butkiss";
    if(name.length()>12){
        name = name.substring(0,12);
    }Kind of a workaround but take it or leave it

  • How can i output the max average?

    How can i output the max of the average?
    i have this queries...
    <cfquery datasource="Intranet" name="GroupStars">
            SELECT execoffice_status, employeedept, COUNT(*) as 'totalstars'
            FROM CSEReduxResponses
            WHERE execoffice_status = 1
            GROUP BY execoffice_status, employeedept
        </cfquery>
        <cfquery dbtype="query" name="GetTotalStars">
            SELECT *
            FROM GroupStars, GetDepartments
            WHERE GroupStars.employeedept = GetDepartments.csedept_id
        </cfquery>
    <cfif GetTotalStars.RecordCount gt 0>
        <cfquery datasource="PhoneList" name="GetAllData">
            SELECT dept.csedept_id, COUNT(*) as 'totalcount'
            FROM employee, dept
            WHERE employee.dept_id = dept.dept_id
                AND employee.emp_status = 1
                AND dept.csedept_id is not null
            GROUP BY dept.csedept_id
        </cfquery>
        <cfquery dbtype="query" name="GetDepartmentTotalEmployeesCount">
            SELECT *
            FROM GetAllData, GetDepartments
            WHERE GetAllData.csedept_id = GetDepartments.csedept_id
        </cfquery>
    <cfquery name="joinQuery" dbtype="query" >
    SELECT *
    FROM GetTotalStars
    WHERE GetTotalStars.csedept_id = -1
    </cfquery>
    <cfset QueryAddRow(joinQuery)>
    <cfquery name="GetUnion" dbtype="query" >
    SELECT *
    FROM GetDepartmentTotalEmployeesCount, GetTotalStars
    WHERE GetDepartmentTotalEmployeesCount.csedept_id = GetTotalStars.csedept_id
    UNION
    SELECT GetDepartmentTotalEmployeesCount.*, joinQuery.*
    FROM GetDepartmentTotalEmployeesCount, joinQuery
    WHERE GetDepartmentTotalEmployeesCount.csedept_id NOT IN (#ValueList(GetTotalStars.csedept_id)#)
    </cfquery>
    <cfquery datasource="Intranet" name="GroupStarsGiven">
        SELECT execoffice_status, submitterdept, COUNT(*) as 'totalstarsgiven'
        FROM CSEReduxResponses
        WHERE execoffice_status = 1
        GROUP BY execoffice_status, submitterdept
    </cfquery>
    <cfquery dbtype="query" name="GetTotalStarsGiven">
        SELECT *
        FROM GroupStarsGiven, GetDepartments
        WHERE GroupStarsGiven.submitterdept = GetDepartments.csedept_id
    </cfquery>
    <cfquery name="joinQuery2" dbtype="query" >
    SELECT *
    FROM GetTotalStarsGiven
    WHERE GetTotalStarsGiven.csedept_id = -1
    </cfquery>
    <cfset QueryAddRow(joinQuery2)>
    <cfquery name="GetUnion2" dbtype="query" >
    SELECT *
    FROM GetUnion, GetTotalStarsGiven
    WHERE GetUnion.csedept_id = GetTotalStarsGiven.csedept_id
    UNION
    SELECT GetUnion.*, joinQuery2.*
    FROM GetUnion, joinQuery2
    WHERE GetUnion.csedept_id NOT IN (#ValueList(GetTotalStarsGiven.csedept_id)#)
    ORDER BY csedept_name ASC
    </cfquery>
    and this part is where i calculate the average, but i only get the average for each department, and from here i want to get the max of the average. how can i do that?
    <td><div align="right"><cfif totalstars eq ''>&ndash;<cfelse><cfset avgstars = totalstars / totalcount>#DecimalFormat(avgstars)#</cfif></div></td>
    thanks for your help

    1) What is it doing instead?
    2) Can you repost your code, but use code tags? If you repaste your formated code and place the tag &#91;code&#93; on top of your block of code and then paste &#91;/code&#93; on the bottom of your block, your posted code will retain its formating and be readable.
    Good luck

  • How to align the 2 rows into 1 row?

    Here is the SQL below:
    SELECT distinct QP.QIP_id,
            Max(decode( Upper(QP.Status_CD), Upper('Approved') , Effective_date, null ))  as Approved_date,
            Max( decode( Upper(QP.Status_CD), Upper('Submitted') , Effective_date, null ) ) as Submitted_date
             FROM  Llp_Sys.Project_Status QP
             WHERE Upper(Qp.Status_cd) in (Upper('Approved'),Upper('Submitted'))
                AND qp.qip_id = 79440
            GROUP by QP.QIP_ID,Qp.Status_CDThe output data is displayed as below:
    79440  NULL     01-FEB-10
    79440 04-FEB-10     NULLHow can I display only 1 row in the output instead of 2 rows.? I mean How to align the rows ?

    Hi,
    When you say
    GROUP by QP.QIP_ID,Qp.Status_CDthe output will contain one row for each distinct combination of values found for qid_id and status_cd. If you want one row for each distinct value of qui_id, including all status_cds, then say
    GROUP by QP.QIP_IDwithout mentioning qip_id, as Bigc suggested. There is nothing in the query that you posted that would cause an error if you did this. If you tried it and got an error message, then post the complete query that causes the error, and the complete error message, including the line number.
    (If all the columns in the GROUP BY clause are also in the SELECT clause, then you don't have to say SELECT DISTINCT , since the output has separate rows only for distinct values of the GROUP BY columns.)
    Whenever you have any problem, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data. You'll get better answers faster.

  • How can I output text in a browser window in JAVA?

    How can I output text in a browser window in JAVA?

    "response.getWriter().print()" is the most common method when using servlets

  • For SAPscript INCLUDE TEXT, how to align as Paragraph format

    Hi experts and 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?
    For example, I defined BG to have tabstop at the 2nd column (or equivalent to 1st tab position) where I need to print the text, and then declared it in SE71 like below:
    However the text prints at the leftmost instead of at the 2nd col position - (8th char tab defined in par. format BG).  Hence it is not aligned to its proper heading.  Line Number instead of Description - which is not okay for client view that needs these Thai texts. 
    The technical details I included below.  Kindly examine:
    1.)  Window >Main > Text Element > Include Text command
    /E   ITEM_TEXT
    BG   ,,&TTXIT-TDTEXT&
    /:   INCLUDE &T166P-TXNAM& OBJECT &T166P-TDOBJECT& ID &T166P-TDID&
    /:   NEW-PARAGRAPH BG
    Note:  I used command "NEW-PARAGRAPH" and had exactly the above code in se71.  Anything missed here?  Pls. help.  Thanks.
    #2.) Paragraph Format > Tab
    No. -
      Tab Position -
    Alignment
    1            8,00 CH            LEFT
    2            28,00 CH          CENTER
    etc.
    Note:   and then i put in  ",,&TTXIT-TDTEXT&" (see above) with the 2 comma's beforehand to say that its on the 1st tab or at the 8th character where it should be printed, but does not give intended result... pls help.
    #3.) Paragraph Formats > Standard Attributes
    Left Margin - 0 cm
    Alignment - Left
    no blank lines checkbox - ticked
    Note:  Is there any more attribute i can manipulate from here to force display at the right position?
    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

    Here's a thought, instead of using tabs, try writing a method that takes a string that is the starting string, a pad character, and a length and returns a string padded to that length with the specified character.
    public String padR(String src, String padChar, int len)
        // ... You get to fill in the rest suggestion try to do it without a loop
    }Have fun,
    PS.

  • How to repeat output billing documents

    Hi Guru;
    How to repeat output billing documents ; because after VF04 maintain billing due list,
    all intercompany billing doucments can not be printed throught our local printer. We are using Biling type as intercompany billing and output as print.
    Regards,
    Raj

    Hi Raj,
    Please use T-Code VF31,output from Billing
    under Message Data select the output type that you need,  enter the  transmission medium as print  and select processing mode as Repeat processing.
    And in   billing data mention the correct billing document for which you want repeat output.
    Hope Above will resolve your problem for Repeat output for Billing Documents.
    Regards,
    Sandeep

  • How to see output in GTS for Customs documents

    Hi experts,
    could you please let me know how to see outputs for customs documents like origin of certificate for US. (ex: like in SD to see order output VA02 then goto issue output)
    let me know the Path or Transaction code to see output on system.
    Regards
    Reddy

    Hi
    Follow the path:
    Customs Processing - Import/Export>Monitoring>Customs Import/Export Declaration>Display Available Customs Export/Import Declaration>Communication Tab
    Or try
    T-Code: /SAPSLL/CL_CUS_03
    Check for Certificate of Origin
    Regards
    Vivek

  • How can I output up to 7 tracks simultaneously?

    Hello esteemed GB community.
    I have to create a little effect for an upcoming party. For this I need to output the following:
    - at least 4 separate audio channels (stereo front and stereo rear)
    - one mono combination of these four tracks (to drive a Light organ gizmo - makes the light flicker with the audio)
    - and finally one separate track on which I will put pulses to trigger a relay for a fog machine.
    Setting up these tracks in GB should be fairly straigth forward (although my GB experience is very limited I've done a fair amount of audio mixing in FCP - which I imagine is similar) but my question is, how can I output all these tracks so I can feed them to their respective recipients? This means to two stereo setups for audio (or would it be easier to do 5.1 Dolby - $$$ ?) and then to the light organ and to the relay trigger for the fogger.
    I did a search for multitrack but most answers I found dealt mainly with input, not output. I imagine this will require some kinid of an external box, right?
    Budget for this box is very limited, hopefully less than $200. Quality does not have to be very high although a good bass response will be important for the effect.
    Thank you very much for any help.
    Bo

    Thanks for your help, HT. Would Logic be a better choice than ProTools LE for this? (I know next to nothing about them I must confess...)
    I was just thinking, in the worst case scenario, I could just create the 6 audio tracks in GB, then output three stereo mp3 files (stereo front, stereo rear, 2 control tracks), dump each on a separate cheap mp3 player and get a controller that can remote start all of them at the same time...
    Does anyone know of such a cheap mp3 player that can be remote started via a wire connection to a relay? Is there another forum that deals with this kind of issue?
    Thanks again.
    Bo

  • How to send output of smartform in pdf format as an attachment to email

    how to send output of smartform in pdf format as an attachment to email
    search before posting further and follow Forum rules
    Edited by: Vijay Babu Dudla on Jan 15, 2009 4:50 AM

    Did u check on sdn?
    i dont think so or else there are many posts on this topic and good wikis too.
    look at one of these code tutorial wiki
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/mail%2bsend%2bthrough%2boutput%2bcontrols
    So next time do use the search functionality.
    кu03B1ятu03B9к
    Edited by: kartik tarla on Jan 15, 2009 12:33 PM

  • How to store output of SQ01 into internal table.

    Hello Experts
    How to store output of SQ01 into internal table.
    Thanks,
    Umesh

    You can't store the sq01 output into internal table.
    Once you create the query it will generate the abap program, in that program you can see the contents.
    Regards
    Sasi

  • 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

  • How to Align test in Text Area?

    Someone please show me how to align text in text Areas...

    You can't (not without rewriting major portions of JTextArea)
    Here's a link which may help (use JTextPane instead)
    http://forum.java.sun.com/thread.jsp?forum=57&thread=342068
    http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20258546.html

  • 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 .

Maybe you are looking for

  • RESOLVED-pacman through work proxy

    i know this is discussed a lot on the forum and i have searched through all the posts on this topic, but can find an answer to my issue. i have setup the wgetrc file to use my work proxies, as such: ftp_proxy = ftp://username:[email protected]/ but w

  • Oracle RAC 10g - Application connect directly to database IP address

    Hi, I am a developer and does not have much knowledge about oracle admin. Sorry, if I don't use the term correctly. We have a vendor application using Oracle RAC on two node (node1/vip1,node2/vip2). Our application was configured to use JDBC connecti

  • Calculated item doesn't show values

    Hi! I have created a report in which I'm showing number of vacancies for two different months (depending uopn the values of months selected in the parameter). I have created a calculated item in Desktop that is supposed to give me difference between

  • Input data to variable type char

    Hello, i would like to know how to input data to Char import java.util.Scanner; Scanner sc = new Scanner(System.in); x = sc.nextInt(); but, its not working on Char

  • Maximum Characters Input Box

    What is the fattest letter? i.e. what should I use to test that content always fits within an input box regardless of what the user types? Is it the letter "M"? I know M is used as a standard in other design circles. Thanks