Setting Text on a JLabel which has an Icon on it

I have a JLabel, on which I have set an Icon. I now want to place some text over this Icon. How do I go about achieving this??

use setText(String) in combination with setVerticalTextPosition(JLabel.TOP)

Similar Messages

  • Having problems setting text to a JLabel!!

    HI *.*,
    i'm having problems setting text to a JLabel.
    i have a JFrame with a JPanels and on the JPanel i have a JLabel.
    I have a text field wihich is used to input text.
    So, i'm using textField.getText() to read the text of the text field and setText() to write it to the Label.
    but setText() isn't displaying the text on the label.
    I'm using NetBeans as an ide
    Does anyone have any ideas??

    Here is some code
    public class AddClass extends JFrame implements ActionListener{
        public AddClass() {
            initComponents();
        }//end of 1st constructor with initComp
        //initComponents
        private void initComponents() {
            getContentPane().setLayout(new java.awt.GridLayout(3, 1));
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            prodPanel.setLayout(new java.awt.GridLayout(1, 3));
            prodPanel.setBackground(new java.awt.Color(255, 255, 255));
            prodPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Production", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12)));
            westPanel.setLayout(new java.awt.GridLayout(6, 0));
            westPanel.setBackground(new java.awt.Color(255, 255, 255));
            westPanel.add(westLab1);
            westLab2.setBackground(new java.awt.Color(255, 255, 255));
            westLab2.setFont(new java.awt.Font("Arial", 1, 36));
            westLab2.setForeground(new java.awt.Color(0, 204, 0));
            westLab2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            westLab2.setIcon(new javax.swing.ImageIcon("C:\\icontexto-webdev-bullet-048x048.png"));
            westLab2.setText("MQ 35");
            westLab2.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
            westLab2.setIconTextGap(10);
            westLab2.setInheritsPopupMenu(false);
            westPanel.add(westLab2);
            westPanel.add(westLab3);
            westPanel.add(westLab4);
            westPanel.add(westLab5);
            prodPanel.add(westPanel);
            setJMenuBar(menuBar);
            setTitle("Broker Monitor");
            this.setSize(700, 700);
            BrokerWindowCloser brkWindowCloser = new BrokerWindowCloser();
            this.addWindowListener(brkWindowCloser);
            pack();
            //       setVisible(true);
        }//end of initComponents
        public AddClass(String st) {
            initComponents();
            westLab6.setVisible(true);
    //        System.out.println("in broker  " + st); 
            westLab6.setText(st);
            System.out.println(st);
            westLab6.setBackground(new java.awt.Color(255, 255, 255));
            westLab6.setFont(new java.awt.Font("Arial", 1, 36));
            westLab6.setForeground(new java.awt.Color(0, 204, 0));
            westLab6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            westLab6.setIcon(new javax.swing.ImageIcon("C:\\PNG\\icontexto-webdev-bullet-048x048.png"));
            westLab6.setEnabled(true);
            westLab6.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
            westLab6.setIconTextGap(15);
            westLab6.setInheritsPopupMenu(false);
            westPanel.add(westLab6);
    //       this.validate();
            westPanel.repaint();
        public void actionPerformed(ActionEvent ae) {
            Object source = ae.getSource();
            if(source == exitMI) {
                System.exit(0);
            }//end of if exitMI
            if(source == addMI){
                new AddMQ_1_1();
            if(source == removeMI){
                new RemoveMQ_1();
        }//end of actionPerformed
        class BrokerWindowCloser extends WindowAdapter {
            public void windowClosing(WindowEvent we) {
        }//end of windowcloserclass
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new AddClass().setVisible(true);
        }//end of main
    }// End of variables declaration
       public void addButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
            Object source = evt.getSource();
            if(source == addButton){
                System.out.println("here");
                String st = mqNameJTF.getText();
                Broker1 br = new Broker1(st);
                AddClass adc = new AddClass(st);
                this.repaint();
    this.dispose();
            }//end of if addButton
        }//end addButtonActionPerformed

  • How to set IPaddress to a VM which has Linux OS using powershell remoting.

    I have downloaded the SetLinuxVM scripts for setting the ipaddress of virtual machine which has Linux as OS. I have 2 different Hyperv host machines for Eg: HostServer1 and HostServer2  and I have installed SetLinuxVM scripts on server HostServer1 but
    my LinuxVM is created in HostServer2 and is highly available.
    Now I have development server from where I connect to any of these HyperV servers remotely .
    I have created powershell remote session from my development server to HostServer1 where SetLinuxVM scripts are installed and excuting the script as given below.
    Set-LinuxVM -VMName "TestLinuxVM" -Manager "Hyper-V" -VMHost "HostServer2"
    -Username "root" -Password "Gen#123" -Hostname "TestLinuxSrv " -IPAddress "192.168.2.2" -SubnetMask "255.255.0.0" -GatewayAddress "192.168.2.1" -PrimaryDNSAddress "8.8.8.8" 
    Even though I am providing the -VMHost and even if the VM is in cluster its not executing the scripts and I am getting the error  WMI not available.
    Its working fine if the scripts are installed on HostServer2 where the LinuxVM is created but my question is that do we need to install the scripts on all HyperV hosts then whats the use of the above parameter -VMHost "HostServer2"  because if
    the hyperv host is remotely connected using powershell we need to provide the VMHost name in the above scripts.
    From the examples provided in the SetLinuxVM module my understanding is that if the SetLinuxVM module is installed in any of the Hyperv servers which  are in a cluster and even though the VM is created in any of the servers and is highly available by just
    providing the VMHost for that particular VM we can set the IPadress ,hostname etc by connecting remotely using powershell to the HostServer which has SetLinuxVM module by providing the VMHost name in the above script .
     Hoping that my problem will be resolved at your earliest convenience.
    Thanks in advance,
    Fayaz Syed.
    FayazSyed

    I am not familiar with these scripts, but in general any modules must exist on the target Hyper-V server.
    The commands do not appear to be suing SCVMM, in which case you would execute the PowerShell script at the VMM console machine.
    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.

  • How can i get the correct text from the url which has the mulitp-languages?

    hi, all
    i built a application and deployed it on sun application server 8.1. when i request a url which include some multi-languages (for example http://xxx.com/servlet?value=XXX. the 'XXX' may be simply chinese. ), i got the ??? instead of the correct text. how can i do it? in tomcat server, i can set the URIEncoding=GBK to get the correct code in server.xml. how can i do it in sun app server?
    thanks.

    Ok, it is unclear on what is happening here.
    Are you saying that when the webclient gets the data that it is not honoring the quote characters? Or the processing of the data buffer is causing issues?
    This is what I see the of your example text which is trying to be parse out:
    <a onmouseover="EnterContent('ToolTip','תווית על בגד: &rsquo;&rsquo;תן לאישה לכבס. זה תפקידה&rsquo;&rsquo;','<u><span style=color:#000099;>כתב: Spook בתאריך: 08.03.15 שעה: 22:11</span></u><br>מחאת טוויטר קמה בעקבות תוויות שוביניסטיות שהדפיסה חברת אופנה באינדונזיה לפיהן תפקיד הכביסה מוטל על האישה. החברה התנצלה אך כנראה רק עשתה רק יותר נזק לע...'); Activate();">";
    It appears to me that the  escapes `&rsquo;` does not have matching `&ldquo;` anywhere within the tooltip. So it appears that the page properly places left quotes in when processing the page, but the raw html has broken text.
    Hence a garbage in, garbage out situation.
    William Wegerson (www.OmegaCoder.Com)

  • Setting text of a JLabel in an array

    Hey everyone. Im making a spreadsheet type program, but i have hit a brickwall and for the life of me i can't figure out what is wrong. What i'm trying to do, is check if the input in a cell is in the form e.g "=A3". Then i want the program to goto A3, copy what is in that cell and put it in the active cell. I've done the first bit, which is checking the input is in the form of e.g "=A3" using regex, and that works fine, the actual method doesn't seem to work for me, even though i manage to get the position of A3.
    Here is my code:
                   String s = inputdata.getText();
              String regexp = "=[A-Z]{1,2}[1-9]{1}[0-9]*";
              if (s.matches(regexp)){
                   String temp =  s.substring(1,2);                    //extracts the letter from the regex
                   char letter = temp.charAt(0);                         //converts the extracted letter to char indirecting using charAt
                   String temp2 = s.substring(2);                         //extracts the number from the regex
                   int number = (int)temp2.charAt(0);                    //stores the number from the regex in a int variable this is the row number
                   System.out.println(temp);                              
                   System.out.println(temp2);
                   int ascii = (int)letter;                              //converts the char letter to its ASCII code
                   int i = ascii - 64;                                        //gets the number of the column
                   System.out.println(i);
                   String textHolder = cell[number].getText();     //gets the text in [row][column] typed in
                   System.out.println(textHolder);          
                   tempcell.setText(textHolder);                         //sets the text of the active cell to the contents of the cell reference entered.
              }I get an arrayindexoutofbounds error.
    i don't see why its an array index out of bounds. My array cells is size [51][31]. Tempcell is the current active cell determined by another method.
    Any ideas?
    Edited by: kev_x on Apr 30, 2008 6:28 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    When you get an index out of bounds error, it tells you what index it tried to access. Like:
    ArrayIndexOutOfBoundsException: -1That would mean that you tried to access index -1.
    So what does your error tell you?

  • Setting text to align right on a JLabel

    Hey,
    How do I set text on a JLabel to align to the right of that JLabel? I've tried setText("mytext", Align.Right); but that doesn't work.

    This is all in the javadocs. Please RTFM next time
    http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JLabel.html#setHorizontalAlignment(int)

  • Performing OCR text recognition in all pages of a PDF document which has blank pages

    The PDF pages in the file are scanned as an image, but there are blank pages also. So, page 1, 2 have images of scanned text, page 3 is blank, pages 4, 5,  have images of scanned text, page 6 is blank and so on.The series of blank pages is 3, 6, 9....
    I am using Adobe Acrobat Pro version 9 on Windows XP. I choose the Document option in menu, OCR Text recognition->Recognize text using OCR->All pages. But, the OCR stops after page 2.
    Then, I go to page 4 and find that it is still an image(and I cannot copy the text from it). So, then I have to choose the Document option in menu, OCR Text recognition->Recognize  text using OCR->All pages. But, the OCR stops after page 6.
    The document has some 200 pages and I don't want to manually do the choose the Document option in menu, OCR Text recognition->Recognize  text using OCR->All pages for all pages which have text.
    I also tried choose the Document option in menu, OCR Text recognition->Recognize  text using OCR->Page 1 to page 200, but that too does not work.
    I can manually go to each blank page, delete it, then do the OCR but that would be tedious.
    1. Am I missing something in doing the OCR of all pages?
    2. Can I set up a batch process to do the delete of blank page series or can I set up a batch process which does OCR of all pages(and does not stop at a blank page) as it is doing now?
    Any suggestions would be appreciated.

    Hm, you could convert every pdf-page to a image file (jpeg, etc.):
    -install the package imagemagick
    -use the command convert
    convert -trim -density 150 your.pdf your.jpg
    This will generate a jpg-file for every pdf-page; "-trim" removes the white margins, density specifies the resolution of the page (you could also try "-resize" instead of "-density") and 150 specifies amount of  dots per inch.
    This does not generate a new pdf-file, but maybe there is a way to convert the images back into a single pdf?

  • How to get value of a textfield which has been set as Renderd false.

    Hi all
    how to get value of a TEXTFIELD which has been set as Renderd false.
    i am getting the value of this textfield from an lov but dont want to show it to the user.
    getting error as:
    attribute xxxx required for view object yyyyy.
    pls help
    naveen

    You can create item inside your LOV region, set the item style to formValue. You can associate this to a View Object field. It can also act as mirror of any other text input field.
    FormValue can hold the value and will not be diaplyed to user. You can read value from it controller
    example
    OAFormValueBean orgValue = (OAFormValueBean)webBean.findChildRecursive("OrgIdFormVal");
    Or you can read it fro the VO associated with this form value.

  • Syntax for identifying Area Text which has overset text

    Is there a way to identify if the Area Text box has overset text using Applescript? if yes, can some one let me know the syntax please.
    Thanks in advance
    Jaim

    Hey Carlos,
    Thanks for pointing me to the right post which has given me some solution. Though there is no direct method, solution given in the post really helped me out.
    set testLength to length of lines of text frame 1 of document 1
    Above AS statement will only count characters that are visible, this does not include overflowed characters.
    Thanks to Ten A for the work around.
    Thanks to Carlos for pointing me to the right post
    Best Regards
    jaim

  • I have two iCloud accounts, my original one that I used for iTunes years ago which has all my content, apps etc and a mobile me one which I got when I set mobile me up which has all my settings etc, this is causing problems, can I merge them?

    As I said I have two iCloud accounts, both do different things, i.e. my original iTunes account has all my app's and music etc, and then also the account which was set up for me when I set up a 'mobile me' account has all my calendars, contacts, settings etc, how can I merge these or even easily set my settings etc to go to my older iTunes account, I have tried to set up family sharing and all I can share is my calendars not my apps because they are with another iTunes account.
    I am also a little concerned that my fire vault has just set its self up using the mobile me account, if I was to get rid of an account I imagine this would be the easiest one to ditch then what would happen to all my encrypted data?
    Many thanks for your help.
    NIK

    I am logged into the same things on both my iPhone and my MacBook Pro, except for mail. I use a gmail IMAP account and everything there already works on both machines. The iCloud account on my iPhone uses one Apple ID and the one on the Mac uses the second Apple ID.

  • I have two children each with an ipod which has FaceTime - I have the iphone 4s with FaceTime.  All of these devices are connected to itunes through the one account.  How do I set up the FaceTime on the two ipods so as it doesn't ring both of them?

    I have two children each with an ipod which has FaceTime - I have the iphone 4s with FaceTime.  All of these devices are connected to itunes through the one account.  How do I set up the FaceTime on the two ipods so as it doesn't ring both of them?

    I started to do that then it said that this will become their apple I.D or similar and then I thought that will disconnect them from the same iTunes?  I want them still on my iTunes as they are only young (8 and 10)?  Or have I got this all wrong and even if I do set them up with a different e-mail will they still be on my itunes?  For example if they want to purchase an App will it still go through my account even if they use their ipod?

  • How to set the view, which has to be shown at runtime?

    Hi,
    in my application i have more than one view, but at runtime only one of these views has to be shown. I want to decide this via a parameter that I get from the url.
    How can i set the right view to be showing at runtime?
    I tried it with a StartView which fires the right Outbound Plug in his wdDoInit-Method. This is working fine, but the problem is, that the method OnPlugDefault() of ComponentInterfaceViewController isn't called already at this time. So in the Init-Method of the StartView I don't have the given URL Parameter, so I can't decide which Plug I want to fire. The method OnPlugDefault() is called only after the init-method of the StartView.
    Is there any other possibilty to set the view, which has to be shown, at runtime?
    Thanks and Best Regards
    Katharina

    Hi,
    One way is you can pass the parameter in the URL , read the parameter and then fire the outbound plug depending upon that.
    You can read the parameters as follows
    HttpServletRequest request =Task.getCurrentTask()
         .getWebContextAdapter()
         .getHttpServletRequest();
    String[] param1 = request.getParameterValues("<<PARAMETRNAME");
    if(param1.equals("VALUE"))
      fire outbound plug1;
    Regards, Anilkumar

  • How to pull a list of materials which has obolete status set, from 2years.

    Hi All,
    I need to pull a list a of materials which has MM-PP status = 04(marc-mmsta) set on them for the past 2 years.
    i tried fetching this in MARC table but the problem here is, the users have not maintained any date in the Valid from date field(marc-mmstd) for any of the materials, so i cannot find out when exactly the status was set to 04.
    i tried my luck in the table CDHDR but here, i cant find the changes done, for a particular field.
    is there a table where in i can see the changes done to a particular field(say marc-mmsta) so that i can track when exactly the status was set to 04 in the material master and pull in the materials that has 04 status on them for the past 2 years?
    Thanks
    Mahendra

    all changes are stored in CDHDR and CDPOS.
    CDHDR has the header information, e.g. user who made the change and when he did it. The CDPOS has the info about the content of change.

  • How can I change the font in the "Add Text Comment" tool, which has Helvetica as default?

    How can I change the font in the "Add Text Comment" tool, which has Helvetica as default?

    Is this for the ADD TEXT COMMENT tool?  How do you change the default font for the ADD TEXT (EDIT TEXT) TOOL?

  • How do i set text in a object so that object expands with text and has even space on both sides of the object in illustrator cc?

    how do i set text in a object so that object expands with text and has even space on both sides of the object in illustrator cc?

    if you see all the different panel. I past the info in and have to manually expand the width of every panel. Is there a way of pasting the text in and the panel moves to the right with so that there is an even space on both sides of the blue panel?

Maybe you are looking for

  • Excise not captured in the MIGO & Tax calculation is not correct in the PO.

    Excise Settings completed.                    02.11.2007 a)     Configuration done as per J05 Building block.( Tax Procedure TAXINN) b)     Maintained J1ID, all steps. c)     Maintained tax code in FTXP. d)     FV11  Maintained for Material, vendor,

  • Multiple apple ID's stopped updating to pc

    I have multiple apple ID's for multiple devices.  I use icloud on my pc to sync the photostreams for all of them.  In the last 2 weeks they all stopped updating completely but one.  I have tried everything but 2 dont work and one still does. I have t

  • Is there a way to "see" what font you're using?

    Hi, I'm a bit new to PAGES. I thought when you turn "Show Invisibles" you would see things like what font you're using . . . if it's bold or underlined or italicized - things like that - you would see these characteristics in the body of the document

  • How to get camera from DVR Card?

    I want do a application record camera from DVR Card( Not Webcam). so can do? DVR Card http://www.dvrcards.com/cards.htm Thank you?

  • How to convert a string-xml placed  inside an xml tag to xml format.

    I have a invoke activity to invoke Web service(code snippet from bpel) .The text in bold is a string that gets formed based on some condition using concat inside while loop .Before calling the WS i need to convert this string into xml Any idea how ca