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!

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.

  • 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 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 to export the text edit data to excel file without splitting the data in excel file?

    how to export the text edit data to excel file without splitting the data in excel file?
    I have a requirement in SAP HR where in the appraiser can add comments in the area given and can export that to excel file. Currently the file is getting exported but the comments getting split into deifferent rows.
    I want the entire comment to be fit in one row.
    Please help.
    Thank you

    Hi,
    if your text edit value is stored in 'lv_string' variable.
    then before exporting the value to excel you have to remove CL_ABAP_CHAR_UTILITIES=>NEWLINE
    that is '#' from the variable lv_string.
    for that use code some thing like this.
    REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>NEWLINE in lv_string WITH space.
    I think this will do the trick.

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

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

  • How to pull the text for InfoObject in APD

    Hi All,
    I have a requirement where in I have to combine the data from 2 InfoObjects using an APD based on some conditions.
    I need to bring in the text for these infoObjects and there attributes too.
    The proposed solution from my side for pulling the text is
    u2022     Getting the text from the text table u2013 this is working fine but the performance is not good.
    u2022     Making a query above the object and taking the output as the APD input. Now, in the query , I have selected the display option u2018key and textu2019 but when I am using this query as input for the APD, I am not getting the text.
    Please let me know how to get the text using the query output and/ or are there any other approach to get the text of an infoObject.
    Thanks & Regards
    Abhi

    Hi,
    It is possible to read the text tables of the infobject, for eg  In material you can use table /BI0/TMATERIAL
    You have to select a Datasource as the 'Database table  and use /BI0/TMATERIAL  as one of the underlying tables and then choose another datasource with /BI0/MMATERIAL as the underlying table.
    Now that you have all the data that is needed you can use the join to connect the above two datasources .Select the join condition (material in this case) and the fields that you would like to be have to the next level from the individual tables that you have selected earlier.
    I guess if you work in this way you might get the results that you are looking forward quite easily without writting code.
    Let me know if it helps.
    Regards
    Ankit

  • How to enlarge the text or characters on web pages permanently

    I need to know how to enlarge the text or characters permanently. I have difficulty reading the characters of each new page. Every time I zoom in to enlarge characters, the new page automatically returns to small characters. Please help.
    Cheng Lin
    [email protected]

    Try one of these extensions:
    *Default FullZoom Level: https://addons.mozilla.org/en-US/firefox/addon/6965
    *NoSquint: https://addons.mozilla.org/en-US/firefox/addon/2592/
    **More NoSquint info: http://urandom.ca/nosquint/
    <br />
    '''Other issues needing your attention'''
    The information submitted with your question indicates that you have out of date plugins with known security and stability issues that should be updated. To see the plugins submitted with your question, click "More system details..." to the right of your original question post.
    *Adobe PDF Plug-In For Firefox and Netscape
    **New Adobe Reader X (version 10) with Protected Mode just released 2010-11-19
    **See: http://www.securityweek.com/adobe-releases-acrobat-reader-x-protected-mode
    *Shockwave Flash 10.0 r42
    *Next Generation Java Plug-in 1.6.0_22 for Mozilla browsers
    **No security issues corrected in version 1.6.0_23, but, according to Oracle/Java, some stability issues resolved.
    #'''Check your plugin versions''': http://www.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #'''Update Adobe Reader (PDF plugin):'''
    #*From within your existing Adobe Reader ('''<u>if you have it already installed</u>'''):
    #**Open the Adobe Reader program from your Programs list
    #**Click Help > Check for Updates
    #**Follow the prompts for updating
    #**If this method works for you, skip the "Download complete installer" section below and proceed to "After the installation" below
    #*Download complete installer ('''if you do <u>NOT</u> have Adobe Reader installed'''):
    #**Use the links below to avoid getting the troublesome "getplus" Adobe Download Manager and other "extras" you may not want
    #**Use Firefox to download and SAVE the installer to your hard drive from the appropriate link below
    #**Click "Save to File"; save to your Desktop (so you can find it)
    #**After download completes, close Firefox
    #**Click the installer you just downloaded and allow the install to continue
    #***Note: Vista and Win7 users may need to right-click the installer and choose "Run as Administrator"
    #**'''<u>Download link</u>''': ftp://ftp.adobe.com/pub/adobe/reader/
    #***Choose your OS
    #***Choose the latest #.x version (example 9.x, for version 9)
    #***Choose the highest number version listed
    #****NOTE: 10.x is the new Adobe Reader X (Windows and Mac only as of this posting)
    #***Choose your language
    #***Download the file
    #***Windows: choose the .exe file; Mac: choose the .dmg file
    #*Using either of the links below will force you to install the "getPlus" Adobe Download Manager. Also be sure to uncheck the McAfee Scanner if you do not want the link forcibly installed on your desktop
    #**''<u>Also see Download link</u>''': http://get.adobe.com/reader/otherversions/
    #**Also see: https://support.mozilla.com/en-US/kb/Using+the+Adobe+Reader+plugin+with+Firefox (do not use the link on this page for downloading; you may get the troublesome "getplus" Adobe Download Manager (Adobe DLM) and other "extras")
    #*After the installation, start Firefox and check your version again.
    #'''Update the [[Managing the Flash plugin|Flash]] plugin''' to the latest version.
    #*Download and SAVE to your Desktop so you can find the installer later
    #*If you do not have the current version, click on the "Player Download Center" link on the "'''Download and information'''" or "'''Download Manual installers'''" below
    #*After download is complete, exit Firefox
    #*Click on the installer you just downloaded and install
    #**Windows 7 and Vista: may need to right-click the installer and choose "Run as Administrator"
    #*Start Firefox and check your version again or test the installation by going back to the download link below
    #*'''Download and information''': http://www.adobe.com/software/flash/about/
    #**Use Firefox to go to the above site to update the Firefox plugin (will also install plugin for most other browsers; except IE)
    #**Use IE to go to the above site to update the IE ActiveX
    #*'''Download Manual installers'''. Note separate links for:
    #**Plugin for Firefox and most other browsers
    #**ActiveX for IE
    #'''Update the [[Java]] plugin''' to the latest version.
    #*Download site: http://java.sun.com/javase/downloads/index.jsp (Java Platform: Download JRE)
    #*Also see "Manual Update" in this article: http://support.mozilla.com/en-US/kb/Using+the+Java+plugin+with+Firefox#Updates
    #* Removing old versions (if needed): http://www.java.com/en/download/faq/remove_olderversions.xml
    #* Remove multiple Java Console extensions (if needed): http://kb.mozillazine.org
    #*Java Test: http://www.java.com/en/download/help/testvm.xml

  • How to aling the text in a JTable???

    I use this code to make a vertical header like in excel. The thing is that i want to aling the text in that column but i couldn´t. I try to set the render, but i loose the header render in the column. Anyone know how to aling the text in that column with out loosing the header effect????
    i post a code that i use as model for my project.
    package com.chuidiang.ejemplos;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.WindowConstants;
    import javax.swing.table.DefaultTableModel;
    * Ejemplo de cómo hacer una "cabecera" lateral en un JTable. Idea original de
    * Leunamal en
    * http://foro.chuidiang.com/java-j2se/tabla-de-referencias-cruzadas-en-java/
    * Básicamente consiste en hacer que la primera columna: - No sea editable. - No
    * sea seleccionable. - Tenga el mismo render que el JTableHeader superior.
    * @author chuidiang
    public class CabeceraLateral {
          * Crea y visualiza una ventana con un JTable que tiene cabecera en la parte
          * superior y en la columna izquierda
          * @param args
         public static void main(String[] args) {
              // Un modelo de datos que hace la primera columna (la de
              // la cabecera lateral) no editable.
              DefaultTableModel tm = new DefaultTableModel(10, 5) {
                   @Override
                   public boolean isCellEditable(int row, int column) {
                        if (0 == column)
                             return false;
                        return super.isCellEditable(row, column);
              // Titulos para la cabecera superior. El primero es vacio,
              // puesto que corresponde
              tm.setColumnIdentifiers(new String[] { "", "A", "B", "C", "D" });
              // Valores para la primera columna, que es la cabecera lateral.
              for (int i = 0; i < 10; i++)
                   tm.setValueAt(i + 1, i, 0);
              // JTable al que se le pasa el modelo recien creado y se
              // sobreescribe el metodo changeSelection para que no permita
              // seleccionar la primera columna.
              JTable t = new JTable(tm) {
                   @Override
                   public void changeSelection(int rowIndex, int columnIndex,
                             boolean toggle, boolean extend) {
                        if (columnIndex == 0)
                             super.changeSelection(rowIndex, columnIndex + 1, toggle,
                                       extend);
                        else
                             super.changeSelection(rowIndex, columnIndex, toggle,
                                                 extend);
              // Se pone a la primera columna el render del JTableHeader
              // superior.
              t.getColumnModel().getColumn(0).setCellRenderer(t.getTableHeader().getDefaultRenderer()); //here i set the render for the column. But when i try to aling the text, this column loose the effect.
              // Creación y visualización de la ventana completa.
              JFrame v = new JFrame("Cabecera lateral");
              JScrollPane sp = new JScrollPane(t);
              v.getContentPane().add(sp);
              v.pack();
              v.setVisible(true);
              v.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    The word is "align" not aling.
    To right-align the first column, you can do this in a prepareRenderer override.    JTable t = new JTable(tm) {
          @Override
          public void changeSelection(int rowIndex, int columnIndex,
                  boolean toggle, boolean extend) {
            if (columnIndex == 0) {
              super.changeSelection(rowIndex, columnIndex + 1, toggle,
                      extend);
            } else {
              super.changeSelection(rowIndex, columnIndex, toggle,
                      extend);
          @Override
          public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
            Component c = super.prepareRenderer(renderer, row, column);
            if (column == 0) {
              ((JLabel) c).setHorizontalAlignment(JLabel.RIGHT);
            return c;
        };You can find other alternatives to your approach by searching the net for "[JTable row header|http://www.google.com/search?q=JTable+row+header]"
    db

  • 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

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

  • Can anyone tell me how to increase the text size in my menu bar and drop down menus?

    Just bought a new 27" screen iMac.  The menu bar and drop down menu text is much to small for me to see without leaning close to the screen.  Does anyone know how to customize the text to a larger size.  This is an issue for any program I open.

    Once upon a time Apple displays packed in 72 dots to an inch (making their resolution 72 DPI). That meant that what we saw on screen at 100% scale was exactly what was printed on a printer - not to mention quite comfortable to read. However that advantage was eclipsed by the fact that photopgraphs and video were pixelated and the only solution to that was to increase the resolution - to pack in more dots per inch - which has the side effect of shrinking the size of text. Where I once used Word at 100% scale I now find it most comfortable at 150% scale.
    There are several solutions. One, as Lex gave you, was to reduce the resolution of the LCD display. But unlike CRT displays, an LCD is tuned to a specific resolution and when you change it the results tend to be blurry. Another is to keep the resolution as it is and to adjust each program (if the program allows it). This makes Word usable and your browser can be set to use no font smaller than a size you set (which has some unpleasant side affects at some Web sites), but some programs and some parts of programs cannot be changed. The menubar and menus are among them. The third solution is one that Apple promised several years ago but has not yet provided - a resolution independant GUI. We can only hope that comes soon. And there's another partial solution - look in System Preferences under Accessibility.

  • How to print the text in points wise in sap script

    hi friends,
    how to print the text in points wise in sap script.
    ex: if suppose paragraph consists of 15 lines. then according to one sentence or one fullstop (.) it should give point 1. like that...
    1. hai how ru.
    2. what r  u doing.
    3.where r u.
    like this i want numbering.. waiting for ur replys.
    thanks,
    kiran

    declare a counter
    data : cnt type char 4.
    print :
    cnt = cnt + 1.
    &cnt& &text&
    cnt = cnt + 1. and so on.
    or.
    if the data is in an internal table
    loop at internal_table.
    cnt = cnt + 1.
    write form.
    in script -&cnt& &text&
    endloop.
    Edited by: NIKHILKUMAR POOJARI on Nov 17, 2008 11:18 AM

  • How to print the text in only last but one page in sapscripts

    hiiiiiiiiiii,
             explian how to print the text in only last but one page in sapscripts? wher to write the code? plz if possible explain in detail with an example?

    Hello,
    The total no pages is given by &SAPSCRIPT-FORMPAGES& command.
    So u can handle the situation in ur form like this
    /: if &PAGE&  = &SAPSCRIPT-FORMPAGES&
    p1 TEXT
    /: endif
    Try in this way it may help u.
    Regards

Maybe you are looking for

  • MacBook Pro Quicktime and HDV

    I have my new 2.0ghz MacBook Pro. When I try to open HDV 1080 60i video in quicktime, I get is a white screen and a prompt to download third party plug ins. The audio plays back fine. On my G4 I can open and play the 1080i video fine. Also there is n

  • TNS-12546: TNS:permission denied in Oracle 10g  windows XP

    Hi I have windows xp installed in my pc. After installing 1og, th.e TNS listener service is not starting automatically. While starting the service manually from command prompt I am getting the following error. LSNRCTL for 32-bit Windows: Version 10.2

  • 4:3 footage being automatically cropped when played on 4:3 TV's.  Converting to 16:9 no help either.

    Hi! I recorded some footage on my DV Camera in 4.3 aspect ratio.  I uploaded into a Premiere Pro CS4 project set up for 4.3, not 16.9.  Everything that's in the frame on the camera's display is there on the screen in Premiere.  The problem arises whe

  • Service contract list for plant

    Hi How to query from a table for the Service contracts created for a particular plant. I tried EKKO table , but could not get for a particular plant. Can anyone guide me how to get the list. Thanks in advance Gururaj

  • My website has stopped displaying in IE but displays okay in Mozilla

    I added Google Analytics to the web site and the web site cannot be displayed by IE in preview mode or in the live mode. The web site displays okay in Mozilla. I have removed the analytics code but the problem persists. Thanks.