Components not appearing until clicked

Hi
I've made a pool game with textfields for chat with opponents, although the panel with the game in appears fine on the screen, but the panel with textfield, textarea, and scrollbar dont appear until you click on them.
Anybody got any ideas?

I'm not sure hopefully you can tell. I'm not too hot on AWT/swing so it could be anything
<code>
public class PoolTableGraphics extends JApplet implements MouseMotionListener,MouseListener,KeyListener
//variables
class myPanel extends JPanel{
     public void paintComponent(Graphics g){
class ImagePanel extends JPanel {
Image image;
public ImagePanel(Image image) {
this.image = image;
     public void update(Graphics g)
          paint(g);                                   }
     public void paint(Graphics g)
//add table & balls etc
g.drawImage(offscreen.getBuffer(),0,0,this);
public void init()
{image = getImage(getDocumentBase(), "pool_table.gif");
     imagePanel = new ImagePanel(image);
     Container contentPane = getContentPane();
     GridBagLayout gridbag = new GridBagLayout();
     GridBagConstraints c = new GridBagConstraints();
     contentPane.setLayout(gridbag);
     contentPane.setBackground(Color.blue);
     c.ipady = 289;
     c.ipadx = 540;
     c.weightx = 0.5;
     c.gridx = 0;
     c.gridy = 0;
     gridbag.setConstraints(imagePanel, c);
     contentPane.add(imagePanel);
     JPanel p=new JPanel(new BorderLayout());
     p.setBackground(new Color(0,0,0));
     text= new JTextField();
     text.setBackground(new Color(255,246,212));
     text.addKeyListener(this);
     text.setBorder(BorderFactory.createLoweredBevelBorder());
     textarea=new JTextArea(100,7);
     textarea.setBackground(new Color(255,246,212));
     textarea.setEditable(false);
        JScrollPane scroller=new JScrollPane(textarea);
     scroller.setPreferredSize(new Dimension(540, 100));
     scroller.setBorder(BorderFactory.createLoweredBevelBorder());
     JPanel label=new JPanel();
     label.setBackground(new Color(247,148,29));
     label.setMaximumSize(new Dimension(540,1));
     p.add(text,BorderLayout.NORTH);
               //p.add(label,BorderLayout.CENTER);
     p.add(scroller,BorderLayout.SOUTH);
     c.ipady = 90;
     c.gridx = 0;
     c.gridy = 1;
     gridbag.setConstraints(p, c);
     contentPane.add(p);
     setVisible(true);
    setSize(550,500);
     imagePanel.addMouseListener(this);
     addMouseListener(this);
     imagePanel.addMouseMotionListener(this);
     addMouseMotionListener(this);
     offscreen=new BufferedGraphics(this);
//initialise game variables
public void paint(Graphics g)
     imagePanel.repaint();//update game area
//rest of game code
</code>

Similar Messages

  • JTextField and JButtons not appearing until clicked.

    I'm writing a program to refresh my CS1 java skills. For some reason when I try to add a JTextField and two JButtons to my container they don't appear until Ive clicked them.
    Actually more specifically, this only happens after a 100ms wait after setting the frame visible. Any less and the components wind up visible, but scrunched up in the top middle of my frame.
    Ive found that if I add the components before and after the wait they are visible and in the correct place, but this makes a noticeable flicker.
    I'm running windows vista if that matters.
    If someone could help me I would appreciate it.
    snippet of code:
    public scrollText()
         drawingThread.start();
         mainFrame.setSize(640,160);
         mainFrame.setContentPane(draw);
         mainPane = mainFrame.getContentPane();
         mainPane.setBackground(Color.white);
         mainFrame.setResizable(false);
         mainFrame.setVisible(true);
         try
              Thread.sleep(100);
              addInterface();
         catch(InterruptedException e){}
    public void addInterface()
         textInput.setBounds(1,103,501,31);
         play.setBounds(502,103,65,30);
         play.addActionListener(this);
         stop.setBounds(568,103,65,30);
         stop.addActionListener(this);
         mainPane.add(textInput);
         mainPane.add(play);
         mainPane.add(stop);
    }

    Postings can't be moved between forums. Now you know for the next time.
    The general form for building a GUI is
    frame.getContentPane().add( yourComponentsHere );
    frame.pack();
    frame.setVisible( true );Then all the compnoent will show up according to the rules of the layout managers used.
    However is you add components to the GUI "after" the GUI is visible then the components are not automatically painted. You need to tell the GUI to invoke the layout manager again so your code would be:
    frame.getContentPane().add( componentsToVisibleGUI );
    frame.getContentPane().validate();

  • The keyboard sometimes not appearing until restarting, why?

    the keyboard sometimes not appearing until restarting, why?

    Do you use a BlueTooth keyboard? If you do and that keyboard is too close the the iPad the keyboard may not pop up. Turn off the keyboard or turn off Bluetooth if that is the case.

  • Since installing iOS 6, I have had problems receiving calls and messages. Calls go straight to answerphone and messages do not appear until I switch off and on again. I have also installed iOS 6.1.1

    Since installing iOS 6, I have had problems receiving calls and messages. Calls go straight to answerphone and messages do not appear until I switch off and on again. I have also installed iOS 6.1.1

    Try a reset. Press & hold the Power and Home buttons simultaneously, ignoring the red power off slider, until the Apple logo appears. Then release both buttons. This should not affect any content on the iPad, it is similar to rebooting your computer.

  • Photoshop CS6 Plug-ins not appearing when clicked under extension drop-down menu

    I noticed that for some reason, my default extensions that come with photoshop cs6 extended and also custom installed plug-ins won't appear when clicked on.  Usually you see a check mark by the plug-in if it is working and is visible on the photoshop layout as a panel.  I have tried uninstalling and reinstalling, which the Kuler extension worked, but only under the workspace that I opened it up for.  So for example, I opened it up on Essential workspace, but it wouldn't appear when changed to painting workspace.  When I close the panel from the workspace, it won't ever come back up again even when clicked on under the extension drop-down menu on any workspace.  This is occuring not just on my desktop, but also on my laptop.  Both are not Photoshop CC, but regular Photoshop CS6.
    I don't really mess around with the extensions much, but once I found out about the painterswheel plugin, I really wanted to try it out, hence now noticing this extension issue with my plug-in..
    All my plug-ins appear on the drop down menu for Windows > Extensions, so it shouldn't be a file placement problem.  I have also tried the Adobe troubleshoot for plugins by uninstalling my plug-ins to see if third party plug-ins were the problem, but still my default plug-ins won't even work.

    I'm a little confused with what you write. There is a difference between extensions and Plug-ins.  Plug-ins are installed using the plug-ins installer and extensions are installed by "Adobe Extension Manager (version)" where version is the Photoshop version and the extension package must be created for that particular Photoshop version.  A CS5 package will not work in CS6 etc.   Installed extensions will be listed in Photoshop under menu Windows>Extensions>List of them.  Plug-in may install in the Filters menu or a place like menu File>Automate>Names.  Installed Extensions that you installed should also show in the  "Adobe Extension Manager (version)" window. Adobe installed extensions like Kuler and Mini Bridge do not show in the "Adobe Extension Manager (version)" window.

  • Letter "A" is appearing on clips and clips not appearing until play pressed

    Hello All,
    Two challenges:
    1. I have the letter A appear on clips when placed in the browser window. This wasn't happening before. Any idea what it means?
    2. When I paste into the browser from the canvas, the clip doesn't appear until I move the head back, and press play. Any idea about this?
    Thanks.
    DG

    Jerry,
    Thanks for the advice. When you mention tutorials on FCP, I assume you mean someplace other than the software package. I say this because I was pretty surprised that it didn't come with some tutorials. Then again, this is for some pretty experienced people, and I'm holding down the other end of the range.
    If the aforementioned is true, could you point me in the direction of some meaningful tutorials at this stage of my experience? I came across a couple, but things like adding a vintage look to my footage is the least of my worries right now. So any links or 3rd party tutorials (Free or Purchase) would be appreciated.
    Cheers,
    DG

  • Child topics not appearing when clicked in parent project

    Hello,
    I have generated a Webhelp parent project containing two child projects in RoboHelp 9. The tables of contents appear for all projects correctly, but when I click some of the topics, they will not display, rather I get that message that my webpage cannot be found. Most of the topics work fine when clicked.
    If it helps, it seems that the topics that won't display are ones that are new or have recent edits.
    I've tried regenerating my projects and re-creating the TOCs, but I am not sure what else I can try. When I generate the child projects on their own, all topics work fine, it is only when merged as a child project in the main project that the topics won't show.
    Thanks,
    Maddy

    It looks like I was wrong, it isn't just new topics, it is a mix of old and new topics that aren't appearing.
    When I look into the folders of the generated merged topics, it looks like these topic files are not generating.
    For example:
    I generate parent project GP and its topics work fine.
    I generate parent project LR and its topics work fine.
    I generate project GP as a child project merged in parent project LR, several of child project GP's topic files have not generated.
    I tried to move the missing files from the main GP generated folders into LR's child version of GP where they should appear, but I get this message: "Cannot move file abcd: The filename, directory name, or volume syntax is incorrect".
    The topics that did generate properly, both new and old, do appear to open to the correct pages when clicked in the TOC.

  • Basic sites (google, youtube) will not load, and intermittently, images on forums will not appear without clicking refresh multiple times, what is wrong?

    Some sites and images will intermittently not load or make me click "try again" several times.
    For example, a forum with a picture thread will not load the pictures, even if they are from multiple reliable hosts.
    Also, I can attempt to visit youtube and must click try again several times to reach the site.

    Do a malware check with several malware scanning programs on the Windows computer.<br>
    Please scan with all programs because each program detects different malware.<br>
    All these programs have free versions.
    Make sure that you update each program to get the latest version of their databases before doing a scan.
    *Malwarebytes' Anti-Malware:<br>http://www.malwarebytes.org/mbam.php
    *AdwCleaner:<br>http://www.bleepingcomputer.com/download/adwcleaner/<br>http://www.softpedia.com/get/Antivirus/Removal-Tools/AdwCleaner.shtml
    *SuperAntispyware:<br>http://www.superantispyware.com/
    *Microsoft Safety Scanner:<br>http://www.microsoft.com/security/scanner/en-us/default.aspx
    *Windows Defender: Home Page:<br>http://www.microsoft.com/windows/products/winfamily/defender/default.mspx
    *Spybot Search & Destroy:<br>http://www.safer-networking.org/en/index.html
    *Kasperky Free Security Scan:<br>http://www.kaspersky.com/security-scan
    You can also do a check for a rootkit infection with TDSSKiller.
    *Anti-rootkit utility TDSSKiller:<br>http://support.kaspersky.com/5350?el=88446
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • Flex app doesnt not appear until mouse over?

    I have a flex app embeded into a web page. It seems to work right in FF and Chrome but all the IE users it is just blank, and stays blank until you move the mouse over the blank spot where it is supposed to be...then it appears instantly. Does anyone have any clue why or how to fix this?
    Thanks!!

    I found an answer here: http://forums.adobe.com/message/1979424#1979424
    I need to set focus on load like this:
    <body onload="document.getElementById('WeddingBandBuilder').focus()">
    However I am having trouble doing this because the <body> tag is locked my the template..is there a way I can do the equivalent with a script in the <head> tag?

  • My bookmarks folder appears in the Bookmarks menu, but bookmarks do not appear when clicking "Show All Bookmarks." Bookmark Manager appears, but shows no bookmarks at all.

    When opening the Bookmarks menu, I see my bookmarks folder in the dropdown and can access them from there. However, if I click "Show All Bookmarks" the manager launches, but shows no bookmarks of any kind. No defaults, folders, uncategorized links...nothing.
    As such, I can still use the bookmarks while surfing, but I can't organize, delete, or export them since they don't show up in the bookmark manager.

    This can be caused by a problem with the file places.sqlite that stores the bookmarks and the history.
    * http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox

  • XFCE: Audio CDs Not Mounted until Clicked in Thunar

    Hello!
    Audio CDs are visible in Thunar, but it seems they don't get mounted till clicked in the file manager - they show up then in Rhythmbox.
    Is there any way to mount the CD automatically once put in the drive?
    Thanks in advance!

    Audio CDs don't show up in media players like Rhythmbox unless 'initialized' by clicking on the audio CD device entry in Thunar.

  • My voice mail messages are not appearing as they are left. Often no voicemails show up until 4 weeks after they have been left

    I am having trouble with my voice mail on the iPhone. The voicemails are not appearing until 3 even 4 weeks after they are left by a caller. Last night 10 voice messages came through all at once, one left before Thanksgiving. Is this an iPhone issue or an issue with the carrier?

    I'm having the same issue. It began three or four days ago. I'd notice that I'd miss a call but the person wouldn't leave a message.
    Two days later, suddenly three or four new voicemails will pop up from the past couple of days. The time stamp on the messages is correct-- it will show that the caller left the vmail a day or two before.
    Also, in what has to be a related problem, some of the voicemails appear to be corrupted and cannot be played.
    I have a 4s and my software is up-to-date. I have made no material changes to my phone, other than automatic software updates to explain this.
    It's enormously frustrating and as a job seeker, I can't afford to miss voicemails. Does anyone know if this is the phone or the carrier (AT&T)?
    Any help and input will be enormously appreciated.

  • Stickies launch at login but no note appears

    Found many similar to this in discussions but not exactly:
    Put Stickies (the app) in my login items.
    App launches in dock successfully at startup (bounces, black arrow appears)
    BUT no note appears until I click on the dock icon. I want my note to appear at startup to act as a reminder ... so I don't have to remember to click the icon to see my note.
    I've deleted the .plist file, restarted, shown all notes, selected a note as default, don't have multiple monitors...
    Ideas?

    Travers, is it possible you accidently checked the "Hide" option next to Stickies in your Login Items?

  • Fonts not appearing in Chrome

    I published my site and uploaded it to the web and the places I used Droid Serif Bold the fonts do not appear until I refresh the page.
    It appears that some script is being loaded by MUSE which doesn't load prior to everything else and only on page refresh does it load the font!
    What can I do? Why include these fonts in MUSE if I can't use them on a live site.

    Hello Joe,
    I'm using Muse since release and did a little so far, as freelancer designer.
    Nowadays I'm looking for new works, don't know why but I'm trying to) fishing clients now.
    Down here some links what I've done.
    www.novigo.com.br
    www.sr3.com.br
    www.sr3.com.br/silurico
    www.sr3.com.br/boavista
    www.villavera.com.br
    http://www.villavera.com.br/cafeteria
    And about you? Tell me how you deal with Muse.

  • Condition is not appearing in Inquiry

    Dear Sir,
    I created an Inquiry where Price condition type are not  appearing but when i create the sales order with the help of same procedure and condition and  Price is appearing properly in sales order.
    Thanks

    Hi shibu2000000000
    --Go to T.Code VOV8 & select the inquiry document & check whether you have assign the document pricing procedure for inquiry.
    --Give the validity dates From & To & enter  the item in VA11 & double click on item & check in conditions tab .If pricing is not appearing then click on the condition analysis & check the reason why it is not revealing the condition type.
    Regards
    Pradeep
    Edited by: Pradeep Kumar.A on Dec 14, 2011 3:35 PM

Maybe you are looking for