Can't see my Label or TextField.

This is a very simple code but when I run the code I can't see my JLAbel or JtextField. The only way to see my Text Field is to hover over it and it highlights. But I want to be able to see both the Label and TextField once I run it. Any ideas? Thanx.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
public class Whore extends JApplet implements ActionListener{
     private int value=0;
     JLabel one;
     JTextField two;
     public void init(){
          Container c=getContentPane();
          c.setLayout(new FlowLayout());
          one=new JLabel("Enter a number");
          two=new JTextField(10);
          two.addActionListener(this);
          c.add(one);
          c.add(two);
     public void actionPerformed(ActionEvent event){
          if(event.getSource()==two){
          value=1;
          repaint();
     public void paint(Graphics g){
          if(value==1)
          g.drawString("dammit",20,20);
}

Swing questions should always be posted in the Swing forum. You are overriding the paint() method without calling the super class's paint() method.
public void paint(Graphics g)
   super.paint(g);
   //do whatever
}

Similar Messages

  • What's Wrong with this JFrame???  I can't see the label.

    I was making a simple JFrame window and I was previewing my work but I couldn't see the label I put in it. It shows a window but no text from the label or red background.
    Thanks.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class FirstClass extends JFrame{
         final static long serialVersionUID = 0;
         public FirstClass(){
              this.setSize(new Dimension(600,300));
              this.setVisible(true);
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              Dimension frameSize = this.getSize();
              int x = (screenSize.width/2) - (frameSize.width/2);
              int y = (screenSize.height/2) - (frameSize.height/2);
              this.setLocation(x,y);
              this.addWindowListener( new WindowAdapter(){
                   public void windowClosing(WindowEvent e){
                        System.exit(0);
              JPanel p = new JPanel();
              p.setBackground(Color.RED);
              p.setLayout(new BorderLayout());
              getContentPane().add(p);
              Label l = new Label();
              l.setText("Hello World");
              p.add(l);
         public static void main(String[] args) {
              FirstClass fc = new FirstClass();
              fc.setTitle("Test");
    }

    your sequence for setVisible() is incorrect.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class FirstClass extends JFrame{
         final static long serialVersionUID = 0;
         public FirstClass(){
              this.setSize(new Dimension(600,300));
              //this.setVisible(true); //remark this line
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              Dimension frameSize = this.getSize();
              int x = (screenSize.width/2) - (frameSize.width/2);
              int y = (screenSize.height/2) - (frameSize.height/2);
              this.setLocation(x,y);
              this.addWindowListener( new WindowAdapter(){
                   public void windowClosing(WindowEvent e){
                        System.exit(0);
              JPanel p = new JPanel();
              p.setBackground(Color.RED);
              p.setLayout(new BorderLayout());
              getContentPane().add(p);
              Label l = new Label();
              l.setText("Hello World");
              p.add(l);
              this.setVisible(true); //add this line
         public static void main(String[] args) {
              FirstClass fc = new FirstClass();
              fc.setTitle("Test");
    }

  • Installed Lion and now can't see or print shipping labels from ebay anymore

    I am a ebay seller and I print several shipping labels every day from the ebay website, everything was ok until I installed Lion OS, now I buy the label but I can't see it nor print it. I spent 2 hours with apple and ebay on the phone and they couldn't solve the problem, I tried firefox and same problem. Please help!!!

    You cannot revert back to iCloud after enabling iCloud Drive on your MacBook Air.  If you want to be able to access your documents on all your Macs you'll have to upgrade the others to Yosemite and enable iCloud Drive on them too.

  • How can I see the border of a label

    I'm wondering how can I see the border of a label.
    I'm trying using the following command but is giving me an error that cannot resolve symbol setBorder. There is another way to do this?
    label_01.setBorder(BorderFactory.createLineBorder(Color.black));

    the awt Label class doesn't have a setBorder method, you need to use a JLabel
    asjf

  • Can't see old backups on Time Machine

    Originally, I noticed the issue when I went to do a backup and it failed because there was not enough space on the disk. Then I went to see if I could delete old backups.  In Time Machine it shows today and one other backup, 6 days ago.  It should be doing backups regularly.  I have had the iMac and my external drive for years.  I did update to Mavericks OS several months ago.  That is the only change I can think of.  I have seen older backups and used them before now.  Not sure why I can't see them anymore and why it says my disk is full.  Why isn't it deleting the old backups if it's full?
    So I guess I have three main questions:
    1 Why can't I see the old backups?
    2 Why aren't the old files being deleted if it's full?
    3 How can it be full if there is only one backup?
    Thanks

    These instructions must be carried out as an administrator. If you have only one user account, you are the administrator.
    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    The title of the Console window should be All Messages. If it isn't, select
              SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
              View ▹ Show Log List
    from the menu bar at the top of the screen.
    In the top right corner of the Console window, there's a search box labeled Filter. Initially the words "String Matching" are shown in that box. Enter the word "Starting" (without the quotes.) You should now see log messages with the words "Starting * backup," where * represents any of the words "automatic," "manual," or "standard."
    Each message in the log begins with the date and time when it was entered. Note the timestamp of the last "Starting" message that corresponds to the beginning of an an abnormal backup. Now
    CLEAR THE WORD "Starting" FROM THE TEXT FIELD
    so that all messages are showing, and scroll back in the log to the time you noted. Select the messages timestamped from then until the end of the backup, or the end of the log if that's not clear. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    ☞ If all you see are messages that contain the word "Starting," you didn't clear the text field.
    If there are runs of repeated messages, post only one example of each. Don't post many repetitions of the same message.
    ☞ The log contains a vast amount of information, almost all of which is irrelevant to solving any particular problem. When posting a log extract, be selective. Don't post more than is requested.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    ☞ Some private information, such as your name, may appear in the log. Anonymize before posting.

  • Can not see wave form in arrange window  logic 9 Please help

    I have been using Logic for 3 months now...mostly just importing old wave files from past protools sessions.  Everything was working fine until I created a new session to record audio.  I record the audio at a nice level...I hit playback...I can hear it fine but I can't see the wave forms.  I can see it in the sample editor.  I've searched around and found the same problem in the past on some forums......they say to trash preferences...  I went to my mac drive...library...preferences  and nothing  I have no files labeled  com.apple.logic.pro  now I'm lost....the funny thing is... when I zoom in horizontal ...the wave form shows but it makes the track way too large.  Any help would be great.  Thanks

    In Logic:  Preferences/Audio
    What is the "Recording Delay" parameter set to?
    It should be zero, default is zero. If it's set to a positive or negative Logic will often not show the wavforms. If that's it, it's one of the long standing bugs in Logic.

  • Label Printing Using Address Book - How can I Print multiple labels of the same name?

    Label Printing Using Address Book - How can I Print multiple labels of the same name?

    I used to be able to print multiple copies of the same picture on one page using iphoto. There was a customise button when you went through to print and it was there somewhere. I can't see it anymore - maybe since an upgrade.
    It's gone. But as a work-around, duplicate your photo (⌘D) to create as many versions as you want copies and select all at once. Then use the "Custom" print layout and set the photo size you want.
    After printing, trash the added versions.

  • How can I see ALL TRACKS by a particular artist?

    When I do a search in iTunes for a band that has a large catalogue (e.g. Pearl Jam or U2) I only get about 150 results. Now, for Pearl Jam I know there are more songs. How can I see a bands' ENTIRE catalogue of songs without having to click on each album individually? Also, if they have a song on a compilation, why isn't that listed in the bands' "All Albums" area? Thanks!

    Not all songs for a group may be for sale in the iTMS. They may hold out some songs/albums due to legal issues. Some groups have switched labels and not all labels are listing in the iTMS. AeroSmith is another example.
    MJ

  • How can I see what is on my cloud?

    How can I see what is on my cloud? Also, I keep getting asked to manage storage when I am watching videos that I have bought through the store. I have bought lots of cloud space only half of which is used. Is my device too full of pictures or videos and how do I know if they are on the cloud or stored on the I tunes store where I bought them from?

    Managing (iCloud Data) on Your iPad
    http://www.peachpit.com/articles/article.aspx?p=1899113
    How much space is used by your Other? You may be able to reduce.
    How Do I Get Rid Of The “Other” Data Stored On My iPad Or iPhone?
    http://tinyurl.com/85w6xwn
    With an iOS device, the “Other” space in iTunes is used to store things like documents, settings, caches, and a few other important items. If you sync lots of documents to apps like GoodReader, DropCopy, or anything else that reads external files, your storage use can skyrocket. With iOS 5/6/7, you can see exactly which applications are taking up the most space. Just head to Settings > General > Usage, and tap the button labeled Show All Apps. The storage section will show you the app and how much storage space it is taking up. Tap on the app name to get a description of the additional storage space being used by the app’s documents and data. You can remove the storage-hogging application and all of its data directly from this screen, or manually remove the data by opening the app. Some applications, especially those designed by Apple, will allow you to remove stored data by swiping from left to right on the item to reveal a Delete button.
     Cheers, Tom

  • I need my product key to enable to activate windows vista home premium and i can't see iton certific

    I need my product key to enable to activate windows vista home premium and i can't see it on Certificate of Authenticity label

    Once the label is worn, you cannot get another key for free. You are better to order a recovery disc set from HP, then you dont need a key
    You can order HP recovery media below, or call HP on the phone to order 1-800-474-6836
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=bph07143&cc=us&lc=en&dlc=en#N76
    If HP no longer has Recovery Media for your model, order them here
    http://www.computersurgeons.com/Default.aspx

  • I want to transfer an audiobook and a movie from my MacBook Pro to my iPhone 4S, and can't figure out how.  I went to "Help" and it said after connecting the two devices I should "Click Apps," but I can't find anything labeled "Apps" to click.  Help?!!

    I want to transfer an audiobook and a movie from my MacBook Pro to my iPhone 4S, and can't figure out how.  I went to "Help" and it said after connecting the two devices I should "Click Apps," but I can't find anything labeled "Apps" to click.  Help?!!

    If you have iTunes 11 on your Mac then you can enable the left-hand sidebar via option-command-S, that might make it easier to navigate.
    Connect the phone to your Mac and select it on that left-hand sidebar, and on the right-hand side of the screen there should be a series of tabs which you can use to select what to sync to the phone. If it's an audiobook then it should appear on the Books tab for selecting/syncing, and films will be on the Movies tab. When you've got the audiobook on your phone you should get an Audiobooks option in the Music app (you might need to tap the '...' tab at the bottom of the Music app to see it).

  • Can't see forms anymore in adobe reader for iPad.

    Until the update I was able to read this form. Can anyone see why I can't any more? uwo.ca/fhs/kin/ug/programs/guides/honors_bsc.pdf

    Nevermind I solved my own problem.  I can see there has already been alot of people viewing this question.  So I'm going to post what I already posted as a discussion as a reply here.
    I'm not a computer wize and very new to Adobe and creating forms with LiveCycle. So apologize to anyone that reads this and says "duh", but hopefully it will be helpful to someone out there who is struggling like I was.
    First off - the IPad will will definitely be able to view your livecycle forms regardless of what anyone else says! These were my steps;
    1. Create form in LiveCycle Designer.
    2. When you save, select "save as"
    3. When the dialogue box opens, and you are creating the name of what you are going to call your file, below you will see a drop down box labeled "Save As Type". Make sure you switch the file type to "Adobe Static PDF Form (*.pdf)"
    And that's it!
    Here is another tip for a user like me:)
    I need to create a form to post to a website, where people fill it in and save it to their computers. I found that when I just saved the form straight from LiveCycle Designer and then posted, some of the free adobe versions (for PC's) wouldn't let the user fill it in. So this is what I did,
    1. Follow the first 3 steps I listed above.
    2. Next open Adobe (the full version) not the reader. I have Adobe X.
    3. Got to "Save As". It will give you a bunch of options. Select "Reader Extended PDF" and then "Enable Additional Features"
    Add that should be it!
    One more tip for the average to low level user. We had some feedback that when someone open my form in the iPad app. they were not able to fill it in. They could, but what they didn't realize was they needed to select the icon at the top that is a little picture of a speech bubble and pencile.

  • Can't see Video titles in ipod

    Hello,
    I put some home videos on new ipod. I named them, but when i use the ipod the videos play, but i can't see the titles. How do I need to name the files?
    Thanks!

    Unfortunately, only TV Shows bought directly from the iTunes Music Store will show up as TV Shows on your iPod (by default). You'll have to leave your videos labeled as Movies, if you want them to show up on your iPod. Sorry.

  • How can I edit address labels from my address book to add spouse name?

    Address book supports Spouse/partner/friend name but the label printing function of address book does not seem to and I can't see how to save a version that I can edit to manually add the missing partners. It only seems to allow me to print it as it is. What can I do? I also just bought Pages in the hopes of helping print christmas letter address labels but haven't figured it out yet

    Warren: looking at other threads out there it doesn't appear that you can print the spouse/partner/friend field. One poster suggested using Avery DesignPro for Mac, which merges with your AddressBook, and allows you to select which fields to include.  The only caveat is that it doesn't show it working with Lion (os 10.7).  You can download it here:
    http://www.avery.com/avery/en_us/Templates-%26-Software/Avery-DesignPro-for-Mac. htm?N=0&refchannel=c042fd03ab30a110VgnVCM1000002118140aRCRD
    Hope this helps.
    -McCArch
    (also posted this in the other thread where you asked a similar question)

  • Can't see the wood for the trees!

    I can't seem to get this gridlayout of textfields to work for me! I have:
    void jbInit() throws Exception {
    panel1.setLayout(gridLayout1);
    panel1.setMinimumSize(new Dimension(400, 400));
    panel1.setPreferredSize(new Dimension(400, 400));
    getContentPane().add(panel1);
    for (int i=0;i<SIZE;++i)
    field[i] = new TextField();
    field.setEditable(true);
    this.getContentPane().add(field[i]);
    and I have the array declared as a property of the Frame class:
    Textfield [] field = new TextField[6];
    I only seem to get one textfield though! Can anyone see what's going on?
    Thank you for any reply.
    Regards
    Yad.

    (Code tags are nice when posting code)
    Thanks...so i now have:
    >       panel1.add(field);>
    but now get 10 textfields! I would have thought that I
    would only get 6?!
    Hmm. Are you sure you haven't set 'field' to have ten items in it? What's that SIZE variable you use in your for loop?

Maybe you are looking for