Center the text in JOptionPane

Hi!
Is it possible to center the text in JOptionPane? I tried it with HTML but it's not working.
Greetings
Burricall

String msg = "<html><body>The aim of the game is to get the highest number from all three rounds.<br>"+
"A dice is lost at the end of each round.<br>"+
"You are able to roll the dices agian at the end of each round but only ones at the end of each round.<br>"+
"<center>Click on 'Ok' button to start the game.</center></body></html>";
JOptionPane.showMessageDialog(null,msg);
this must work
regards
tigerkumar
Edited by: tigerkumar on Oct 4, 2007 9:55 AM

Similar Messages

  • How to center the text displayed in a JList

    Hi,
    The width of the JList display area is wider than the text displayed. I tried to center the text displayed to make it look nicer. I had tried using "setAlignmentX(Component.CENTER_ALIGNMENT)" in my own ListCellRenderer class but did not work. Any idea how to center the text?
    Fai.

    Yes, I am using JLabels in my renderer and the following is the code:
    public class MyCellRenderer extends JLabel implements ListCellRenderer {
         private static final Color HIGHLIGHT_COLOR = new Color(0, 0, 128);
         public MyCellRenderer() {
              setOpaque(true);
              setIconTextGap(12);
         public Component getListCellRendererComponent(
              JList list,
              Object value,
              int index,
              boolean isSelected,
              boolean cellHasFocus)
              String entry = (String)value;
              setText(entry);
              setFont(new Font("Ariel", Font.BOLD, 18));
              setAlignmentX(Component.CENTER_ALIGNMENT);
              if(isSelected) {
                   setBackground(HIGHLIGHT_COLOR);
                   setForeground(Color.white);
              } else {
                   setBackground(Color.white);
                   setForeground(Color.black);
              return this;
    Can you point out where to implement the centering logic?
    Thanks,
    Fai.

  • How to center the text in JLabel without image?

    I need to center the text inside JLabel, how do i do it?
    Also I need some advise, what is the best way to mark a clicked card (I'm making a card game)?

    I found this method that controls that text alignment:you can try few more:
    label.setVerticalAlignment(JLabel.CENTER);    //these two would  center the label contents
    label.setHorizontalAlignment(JLabel.CENTER);
    label.setHorizontalTextPosition(JLabel.CENTER);Thanks!

  • Can I center the text in vertical direction in JTextArea

    for example , if the JTextArea is 50 pixels high, and the text 's height is 20 pixels,
    then how can I center the text in vertical direction in this JTextArea which means
    there is a extra space whose height is 15 pixels over and under the text?

    Exactly what are you trying to do?
    JTextAreas are usually in a scroll pane, you add multiple lines ie height can change
    are you going to make it uneditable etc
    if it is just for a display (uneditable), perhaps a 'tall' JTextField might give you the desired effect

  • How do i center the text of a JLabel?

    How do i center the text of a JLabel?

    http://java.sun.com/j2se/1.4/docs/api/javax/swing/JLabel.html#setHorizontalTextPosition(int)

  • How do I center the text in full width accordion panel?

    Hello!
    Is it possible to center the text to follow the full width accordion widget?
    When you expand to fill the screen, the text are fixed and doesn't follow the center headline...
    I created a page so you see what I'm talking about:  http://fullwidthissue.businesscatalyst.com/index.html
    Please respond if you know what to do or if it's impossible..
    Thanx

    This believe this can be fixed within the <head> of the document. I had the same problem and it took me a bit to figure this solution.
    Step 1
    Find the <div> ID that muse gives to the content portion of the accordion element. you can find this by using a web browser that lets you inspect the code.
    Step 2 once you have that code replace u6174. with your specific <div> then past this into your <Head> of the muse document. Almost forgot.....Get a general idea of the minimum size around your content this example it was a width of 750px. and change the width accordingly on this code.
    <style>
    #u6174{
    width: 750px;
    padding-left: 0px;
    padding-right: 0px;
    margin-right: auto;
    margin-left: auto;
    border-right-width: 0px;
    border-left-width: 0px; "}
    </style>
    you can see a sample of this here:
    Alain Hunkins
    At the bottom is this solution working.
    Let me know if that helps.

  • Center the text in the textfield

    Is there a way to center the text in the text field? Specially vertically.

    It seems that when a new text is set, the start position of the text is not recomputed, as the following example demonstrates. Initially all text fields are aligned correctly. But when you then hit the update button, all textfields are updated with a new, longer text which shows the problem. All texts seem to start at the same position which was computed for the previous text and not the recomputed new position for the new text. To temporarily work around this problem, you can reset the alignment of the text fields and then set it back to your desired value. This forces a recomputation of the text start position.
    package textfield.alignment;
    import javafx.application.Application;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.geometry.Pos;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.TextField;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    public class TextFieldAlignment extends Application {
         TextField lText;
         TextField cText;
         TextField rText;
         public static void main(String[] args) {
              launch(args);
         @Override
         public void start(Stage stage) {
              lText = new TextField("left");
              lText.setAlignment(Pos.BASELINE_LEFT);
              cText = new TextField("center");
              cText.setAlignment(Pos.BASELINE_CENTER);
              rText = new TextField("right");
              rText.setAlignment(Pos.BASELINE_RIGHT);
              Button btn = new Button("update");
              btn.setOnAction(new EventHandler<ActionEvent>() {
                   @Override
                   public void handle(ActionEvent t) {
                        lText.setText("updated left");
                        cText.setText("updated center");
                        rText.setText("updated right");
    //                    applyWorkaround();
              VBox root = new VBox();
              root.getChildren().addAll(lText, cText, rText, btn);
              stage.setScene(new Scene(root, 200, 300));
              stage.show();
         void applyWorkaround() {
              lText.setAlignment(Pos.CENTER);
              lText.setAlignment(Pos.BASELINE_LEFT);
              cText.setAlignment(Pos.CENTER);
              cText.setAlignment(Pos.BASELINE_CENTER);
              rText.setAlignment(Pos.CENTER);
              rText.setAlignment(Pos.BASELINE_RIGHT);          
    }

  • Still trying to center the text of the jTextP. What is wrong with the code?

    The Code:
    JTextPane jTextPane1 = new JTextPane();
    MutableAttributeSet mas;
    mas=new SimpleAttributeSet();
    StyleConstants.setAlignment (mas, StyleConstants.ALIGN_RIGHT);
    jTextPane1.setCharacterAttributes(mas,false);
    jTextPane1.setText("message");
    The code doesn't align the text.
    Please HELP MEEEEEE
    Thanks.

    I've found the solution!!!!!!!!!!!!!!!!!!!!!
    insted of:
    jTextPane1.setCharacterAttributes(mas,true);
    you have to use:
    jTextPane1.setParagraphAttributes(mas,true);
    yuhuuuuuuuuuuuuuuuuuuuuuu!!!!!!!

  • HT3384 How do you set the text layout in Pages on the vertical? How do you center the text?

    How do you align the text vertcially?

    Stru,
    You posted your question in the Pages (word processor) discussion area. Hope you can find your way back to Excel without any difficulty. The answer wouldn't have been much different had you posted in the Numbers discussion.
    Jerry

  • Is there a way to center the text on a message popup

    Looking for a way to center multiple lines of text on a Message Popup.

    sdrochek3 -
    The step type does not export any option to center text that it displays. If centering text is a requirement, you will need to create a custom dialog in your ADE of choice and display that instead.
    Scott Richardson
    National Instruments

  • Does anybody know how to center the text in a sortableheader?

    I am using UIX.

    Of course you shouldn't do so anyway...
    Terminal programs should coexist with all other terminal programs and not try to dominate the screen.
    They should never clear the screen as this would remove output from other programs running in the same terminal.

  • How to center a text in numbers

    I am having a little bit of a hard time trying to center a text between 3 or more columns.... how can I do that?

    Threre are a few options:
    1) select the three cells and merge them, then enter the text and open the cell formatter and center the text horizonatlly.  NOTE:  merging cells often causes unexpected problems
    2) create a text box and type the text, then format as horizontally centered.  Place the text box over the  cells, set the fill pattern to the same as the cells
    3) create another table to be the header :
    and set the cell width for one cell to be the same as three in the "other" table
    There are porbably more ways than this.  Hopefully one of these will work for you or you will suggest another that works.

  • Applescript - trying to horizontally align all the text in a text frame

    I've tried the following snippet along with several others:
    tell application "Adobe InDesign CS5.5"
              tell the active document
                        set Text_Frame to the text frame "PH"
                        tell Text_Frame
                                  set theLines to every line
                                  if (theTextPos = "B") then
                                            tell theLines to set justification to left align
                                  else
                                            tell theLines to set justification to center align
                                  end if
                        end tell
              end tell
    end tell
    Throws errors about setting classes.
    ie
    error "Can’t set «class paln» of {\"MISSOULA COMMUNITY PHYSICIANS
    \", \"CENTER NO. 2
    \", \"CONDOMINIUM ASSOCIATION
    \", \"2827 FORT MISSOULA ROAD
    \", \"MISSOULA, MT 59804
    \"} to «constant mAOHcent»." number -10006 from «class paln» of {"MISSOULA COMMUNITY PHYSICIANS
    ", "CENTER NO. 2
    ", "CONDOMINIUM ASSOCIATION
    ", "2827 FORT MISSOULA ROAD
    ", "MISSOULA, MT 59804
    All I'm trying to do is center the text in a text frame if a condition is met, else left align it if another condition is met.
    Any suggestions woudl be appreciated.

    Don't get the lines first:
                                  if (theTextPos = "B") then
                                            set justification of every line to left align
                                  else
                                            set justification of every line to center align
                                  end if

  • How to center this text in wordpress PHP file?

    Hi,
    I am trying to center the text on the bottom of my blog. 
    Site Admin
    Log out
    WP
    These three elements above are aligned left and looks really bad, looks like the problem is on my footer.php, a container called footermenu, but I can't figure out where I need to plug in the code to center it. Here is the code for the footer:
    <?php
    if ( is_active_sidebar( 'footer-widget-area' ) ) {
    ?>
    <div id="footer">
    <div id="footerspan" >
    <div class="container_12">
    <div class="grid_8" >
    <ul class="widget">
    <?php dynamic_sidebar('footer-widget-area');?>
    </ul>
    </div>
    <div class="grid_4" >
    <h3><?php _e('Meta', 'mt-white');?></h3>
    <ul>
    <?php wp_register();?>
    <li>
    <?php wp_loginout();?>
    </li>
    <li>
    <a href="<?php echo esc_url(__('http://wordpress.org/', 'mt-white'));?>" title="<?php _e('Powered by WordPress, state-of-the-art semantic personal publishing platform.', 'mt-white');?>"><abbr title="WordPress">WP</abbr></a>
    </li>
    </div>
    <div style="clear:both"></div>
    </div>
    </div>
    </div>
    <?php } else {?>
    <ul id="footermenu">
    <?php wp_register();?>
    <li>
    <?php wp_loginout();?>
    </li>
    <li>
    <a href="<?php echo esc_url(__('http://wordpress.org/', 'mt-white'));?>" title="<?php _e('Powered by WordPress, state-of-the-art semantic personal publishing platform.', 'mt-white');?>"><abbr title="WordPress">WP</abbr></a>
    </li>
    <?php wp_meta();?>
    </ul>
    <?php }?>
    <?php wp_footer();?>
    </body>
    </html>
    Thank you for your help.

    Hi,
    I am trying to center the text on the bottom of my blog. 
    Site Admin
    Log out
    WP
    These three elements above are aligned left and looks really bad, looks like the problem is on my footer.php, a container called footermenu, but I can't figure out where I need to plug in the code to center it. Here is the code for the footer:
    <?php
    if ( is_active_sidebar( 'footer-widget-area' ) ) {
    ?>
    <div id="footer">
    <div id="footerspan" >
    <div class="container_12">
    <div class="grid_8" >
    <ul class="widget">
    <?php dynamic_sidebar('footer-widget-area');?>
    </ul>
    </div>
    <div class="grid_4" >
    <h3><?php _e('Meta', 'mt-white');?></h3>
    <ul>
    <?php wp_register();?>
    <li>
    <?php wp_loginout();?>
    </li>
    <li>
    <a href="<?php echo esc_url(__('http://wordpress.org/', 'mt-white'));?>" title="<?php _e('Powered by WordPress, state-of-the-art semantic personal publishing platform.', 'mt-white');?>"><abbr title="WordPress">WP</abbr></a>
    </li>
    </div>
    <div style="clear:both"></div>
    </div>
    </div>
    </div>
    <?php } else {?>
    <ul id="footermenu">
    <?php wp_register();?>
    <li>
    <?php wp_loginout();?>
    </li>
    <li>
    <a href="<?php echo esc_url(__('http://wordpress.org/', 'mt-white'));?>" title="<?php _e('Powered by WordPress, state-of-the-art semantic personal publishing platform.', 'mt-white');?>"><abbr title="WordPress">WP</abbr></a>
    </li>
    <?php wp_meta();?>
    </ul>
    <?php }?>
    <?php wp_footer();?>
    </body>
    </html>
    Thank you for your help.

  • JTable How to align the Text in a Cell to Centre

    Hi Plese Help regarding JTable.
    I want to align the Text in the Table Cell to Centre how to align it. Im using Abstract Data Model TAble an what is the meaning of renderer and its use.. Help me out

    Here are a couple of links you should read for information on tables and renderers:
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editrender
    http://www-106.ibm.com/developerworks/java/library/j-jtable/index.html?dwzone=java
    Here is an example of a simple renderer that will:
    a) center the text
    b) highlight the background when the cell gets focus
    This renderer is only used in two of the columns of the table.
    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TableRenderer extends JFrame
         public TableRenderer()
              String[] columnNames = {"Date", "String", "Integer1", "Integer2", "Boolean"};
              Object[][] data =
                   {new Date(), "A", new Integer(1), new Integer(5), new Boolean(true)},
                   {new Date(), "B", new Integer(2), new Integer(6), new Boolean(false)},
                   {new Date(), "C", new Integer(3), new Integer(7), new Boolean(true)},
                   {new Date(), "D", new Integer(4), new Integer(8), new Boolean(false)}
              DefaultTableModel model = new DefaultTableModel(data, columnNames);
              JTable table = new JTable( model )
                   //  Returning the Class of each column will allow different
                   //  renderers to be used based on Class
                   public Class getColumnClass(int column)
                        return getValueAt(0, column).getClass();
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );
              //  Create cell renderer
              TableCellRenderer centerRenderer = new CenterRenderer();
              //  Use renderer on a specific column
              TableColumn column = table.getColumnModel().getColumn(3);
              column.setCellRenderer( centerRenderer );
              //  Use renderer on a specific Class
              table.setDefaultRenderer(String.class, centerRenderer);
         public static void main(String[] args)
              TableRenderer frame = new TableRenderer();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
         **  Center the text and highlight the focused cell
         class CenterRenderer extends DefaultTableCellRenderer
              public CenterRenderer()
                   setHorizontalAlignment( CENTER );
              public Component getTableCellRendererComponent(
                   JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
                   super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                   if (hasFocus)
                        setBackground( Color.cyan );
                   else if (isSelected)
                        setBackground( table.getSelectionBackground() );
                   else
                        setBackground( table.getBackground() );
                   return this;

Maybe you are looking for

  • How can I get my hp eprint email address from a remote location?

    I am currently away from home and need to print something for my wife.  I have tested out eprint before but never tried it from a remote location.  I cannot recall the email address for my printer.  Is there any way to retrieve this without being at

  • Not Getting Video Signal

    I just purchased an 80 GB Black iPod Classic today and I was told by the Apple salesman to also purchase the "iPod A/V Cable" so I can also view videos. It cost about $19.99 and so I purchased it. After syncing everything into my iPod, I get ready to

  • Hi its urgent...help on selection screen parameters

    Hi all, I need help on selection screen parameters. requirement is that, i am having input fields for material, plant ,start date and end date and a check box and an input field for getting the txt file. when i select the checkbox, it should ignore t

  • TRACE files path

    Hi, I have traced one program using st12 Tcode. I need to down load that trace file to my local syste. can anyone give the Trace files path. My SAP is working on AIX. Advace thanks Kishore

  • How to re-install all mail files in Mountain Lion

    Hi, Can someone tell me to delete ALL mail user files so I can set up new accounts again?