GUI JLabel Problem

Hello, I am a noob and i will admit it. I have been at it for a few hours now trying to figure out how to....
1.) Add JLabels to a GUI with a Background painted on it using the paint(); method without it being retarded
2.) Update the gui with paint(); and have it not flash (I've tried using update with double buffer)
Can someone lead me in the right direction?
Here's my code..
import java.util.*;
import java.net.*;
import javax.swing.*;
import java.io.*;
import javax.swing.JOptionPane;
import java.awt.*;
import java.awt.event.*;
public class PingPongGUI extends JFrame implements KeyListener
     private Image dbImage;
     private Graphics dbg;
     double p1score=0;
     double p2score=0;
     String p1scoreStr="";
     String p2scoreStr="";
     ImageIcon backImage = new ImageIcon("ping-pong-medium.jpg");
     JLabel Player1L = new JLabel("Test Label");
    public PingPongGUI() throws Exception
          this.setFocusable(true);
         this.addKeyListener(this);
        setTitle("Ping Pong Leagues (Beta Version 1.0) : Developed by ME. || ANDREW IS A BOCE!");
        setSize(800, 600);
        setResizable(false);
        Container pane = getContentPane();
        pane.setLayout(null);
          //Adding stuff to the GUI
          //pane.add(Player1L);
          //GUI Preferences
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    public static void main(String[] args) throws Exception,AWTException,IOException
        PingPongGUI PPGUI = new PingPongGUI();
    public void paint(Graphics g)
          super.paint(g);
          //Drawing the scores on the window
          g.drawImage(backImage.getImage(), 0, 0, 800, 600, null);
          java.awt.Font font = new java.awt.Font("Arial Narrow",1,20);
          //Set Labels Overtop of background image
          Player1L.setFont(font);
          Player1L.setForeground(Color.blue);
          Player1L.setSize(40, 40);
          Player1L.setLocation(30, 50);
          //Player1L.setOpaque(true);
          Player1L.setVisible(true);
     public void update(Graphics g)
               //Double Buffering to insure no flash when movment occurs
               // initialize buffer
               if (dbImage == null)
                    dbImage = createImage (this.getSize().width, this.getSize().height);
                    dbg = dbImage.getGraphics ();
               // clear screen in background
               dbg.setColor (getBackground ());
               dbg.fillRect (0, 0, this.getSize().width, this.getSize().height);
               // draw elements in background
               dbg.setColor (getForeground());
               paint (dbg);
               // draw image on the screen
               g.drawImage (dbImage, 0, 0, this);
}Edited by: JavaOwnsFace on Mar 6, 2009 8:28 PM

You will benefit greatly by going through the Sun graphics tutorials. There you will learn not to paint directly to a JFrame (similar for JApplet) but instead to a JComponent or JPanel. Also, you appear to be using your paint method to do program logic and this is definitely a very bad thing to do as you cannot control when a paint method will be called. Again, the tutorials should help you with this too.

Similar Messages

  • GUI related problem in solaris 8 02/04

    Hello all,
    I am facing GUI related problem in the software running on solaris when I upgraded from solaris 8 02/02 to 8 02/04.
    The GUI which was working fine on 02/02 was giving some menu selection problem in 02/04. In GUI applications i was unable to select items after double clicking it in solaris 8 02/04 while it was working fine in solaris 8 02/02.
    Are there any O.S. related problem?
    Thanks and regards,
    Ankit

    Wolfgang073 wrote:
    Hi guys and ladys!
    I added the LD_LIBRARY_PATH, Why are you doing that. It's probably a bad idea.
    but the Openwindows not run OK (e.g. start cmdtool window without csh % prompt etc.).That's very possible. Don't make global changes to LD_LIBRARY_PATH (by putting in your login files for example). Instead if you need it to run a particular program, make a wrapper that sets the variable and then calls the program. That will limit the scope of those changes.
    vi .login
    # Erasing LD_LIBRARY_PATH
    setenv LD_LIBRARY_PATH
    # Important Paths set
    setenv LD_LIBRARY_PATH     /usr/ucblib:$LD_LIBRARY_PATHDon't do that.
    Darren

  • JDeveloper 10g (10.1.3.3.0) GUI Buldier problems

    Hi there,
    I am running JDeveloper on several platforms (Windows XP Pro SP 2, Ubuntu Linux, Mac OS 10 Leopard), but all of them manifest this problem.
    I am designing a Swing Application.
    When I load the source code for a given class I click the Design tab to bring up the graphical representation of my component (in this case, a JPanel).
    In some cases this works fine. The component comes up in the main window, and I can graphically edit it.
    In other cases, it comes up with a blank screen which says: "No GUI Selected. Double click on an item in the Structure Window to see its GUI here.". I double click the item as instructed, but nothing changes in the main window.
    Can someone tell me exactly what JDeveloper is doing behind the scenes to facilitate this graphical GUI builder?
    Does it just instantiate the object using the default constructor?
    Does it save the layout somewhere?
    Does it parse the layout from the java file?
    Does it compile a separate version to render, or does it use the generated .class files?
    This is really frustrating. I had a lucky spell where 10 out of 10 JPanels I was designing would render correctly, but now some of them have this problem.
    What changes am I making to my source code to break the graphical visual editor?
    Thanks,
    Allen

    I have the same problem and I noticed some things in previous approaches, because the problem occured more than once.
    Last year I noticed that the problem occured, because I changed to JDK 1.6 (project java version, not the one running JDeveloper itself). The solution was that I had to clean all .class files (with an ant-Task) and all worked fine, but Inner Class-GUI-Objects. These are ASFAIK not supported.
    Now more than 6 months later I noticed that somehow old source code is working and displaying fine, but whenever I make an update to a newer revision the visual editor behavious like you said. (I am using subversion).
    This thing is strange, but anyway I managed to find out, that JDeveloper uses the method jbInit() to initialize the GUI and that other methods like doSomeMoreInit() will not be executed. So one approach was also do create postJbInit() methods, but somehow I am stuck now.
    Maybe this can help you with your problem, but I have to research a little bit.

  • AppleScript GUI scripting problem.

    Hi All,
    I've created a script that will automatically open new document in Indesign CS2. But when i run the script i'm getting system events error as "NSReceiverEvaluationScriptError: 4". I tried following the instruction given in forums but still couldn't figure out. Below is the script i wrote. Can any one tell where and what i'm missing.
    tell application "Adobe InDesign CS2" to activate
    tell application "System Events"
    tell process "Adobe InDesign CS2"
    tell menu bar 1
    tell menu bar item "File"
    tell menu "File"
    tell menu item "New"
    tell menu "New"
    click menu item "Document"
    end tell
    end tell
    end tell
    end tell
    end tell
    click button "Ok" of window 1
    end tell
    end tell
    This is the submenu of menu New. This might be the problem cos the below script works for for which i'm clicking the menu not sub menu
    tell application "Adobe InDesign CS2" to activate
    tell application "System Events"
    tell application process "Adobe InDesign CS2"
    tell menu bar 1
    tell menu bar item "Help"
    tell menu "Help"
    click menu item "Welcome Screen..."
    end tell
    end tell
    end tell
    end tell
    end tell
    My Mac version 10.4.10
    Any help would be appreciated.
    -Jacintha

    Using GUI scripting is the road to madness; it's for emergency use only.<br />Try:<br /><br />tell application "Adobe InDesign CS2"<br />make document<br />end tell<br /><br />-- <br />Shane Stanley <[email protected]>

  • GUI size problem

    When I run this code the GUI doesn't provide enough space for my buttons. It provides enough room for my JLabels and TextFields, but cut's off the buttons.
    public class ReceivingOrganizer extends JPanel
         private JFrame frame;
         private JPanel jpMain, jpLine1, jpLine2, jpCheckBoxPanel;
         private JLabel jlContainer, jlSeal, jlTopInstruct;
         private JButton find, print;
         private JFormattedTextField ftfContainer, ftfSeal;
         public static void main(String[] args)
              ReceivingOrganizer object = new ReceivingOrganizer();
              object.createGUI();
         public ReceivingOrganizer()
              super(new GridBagLayout());
              GridBagConstraints c = new GridBagConstraints();
              jpMain = new JPanel(new GridBagLayout());
              jpMain.setBorder(BorderFactory.createEmptyBorder(30,30,30,30));
              jlTopInstruct = new JLabel("Enter container number or seal number: ");
              c.gridwidth=GridBagConstraints.REMAINDER;
              jpMain.add(jlTopInstruct, c);
              c.gridwidth= GridBagConstraints.RELATIVE;
              jlContainer = new JLabel("Container: ");
              jpMain.add(jlContainer, c);
              c.gridwidth= GridBagConstraints.RELATIVE;
              ftfContainer = new JFormattedTextField();
              ftfContainer.setColumns(15);
              jpMain.add(ftfContainer, c);
              //ftfContainer.addKeyListener(this);
              c.gridwidth= GridBagConstraints.REMAINDER;
              c.fill=GridBagConstraints.BOTH;
              find = new JButton("Find");
              jpMain.add(find, c);
              //find.setActionCommand("find");
              //find.addActionListener(this);
              c.gridwidth= GridBagConstraints.RELATIVE;
              jlSeal = new JLabel("Seal: ");
              jpMain.add(jlSeal, c);
              ftfSeal = new JFormattedTextField();
              ftfSeal.setColumns(15);
              jpMain.add(ftfSeal, c);
              //ftfSeal.addKeyListener(this);
              c.gridwidth= GridBagConstraints.REMAINDER;
              print = new JButton("Print");
              print.setEnabled(false);
              jpMain.add(print, c);
              //print.setActionCommand("print");
              //print.addActionListener(this);
              jpMain.setMinimumSize(jpMain.getSize());
              add(jpMain, c);
         public void createGUI()
              frame = new JFrame("Receiving Organizer");
              frame.setResizable(true);
              frame.setLocationByPlatform(true);
              frame.setMinimumSize(frame.getSize());
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.add(new ReceivingOrganizer());
              //Display the window.
              frame.pack();
              frame.setVisible(true);
    }

    Don't use GridBagConstraints.RELATIVE for more than one component in the same row, and then only for the second-last component in the row. Read the API:
    Use RELATIVE to specify that the component's display area will be from gridx to the next to the last one in its row.
    Additionally, before a panel is validated or made visible, its size is zero, so you're effectively setting the minmum size to [0,0] -- not, I'm usre, what you intended to do. Ditto for the JFrame. I've added a couple of sysouts for you to see this for yourself.import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import javax.swing.*;
    public class ReceivingOrganizer extends JPanel {
      private JFrame frame;
      private JPanel jpMain;
      private JLabel jlContainer,  jlSeal,  jlTopInstruct;
      private JButton find,  print;
      private JFormattedTextField ftfContainer,  ftfSeal;
      public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            new ReceivingOrganizer().createGUI();
      public ReceivingOrganizer() {
        super(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();
        jpMain = new JPanel(new GridBagLayout());
        jpMain.setBorder(BorderFactory.createEmptyBorder(30, 30, 30, 30));
        jlTopInstruct = new JLabel("Enter container number or seal number: ");
        c.gridwidth = GridBagConstraints.REMAINDER;
        jpMain.add(jlTopInstruct, c);
        c.gridwidth = 1;//GridBagConstraints.RELATIVE;
        jlContainer = new JLabel("Container: ");
        jpMain.add(jlContainer, c);
        c.gridwidth = GridBagConstraints.RELATIVE;
        ftfContainer = new JFormattedTextField();
        ftfContainer.setColumns(15);
        jpMain.add(ftfContainer, c);
        c.gridwidth = GridBagConstraints.REMAINDER;
        //c.fill = GridBagConstraints.BOTH;
        find = new JButton("Find");
        jpMain.add(find, c);
        c.gridwidth = 1;//GridBagConstraints.RELATIVE;
        jlSeal = new JLabel("Seal: ");
        jpMain.add(jlSeal, c);
        c.gridwidth = GridBagConstraints.RELATIVE;
        ftfSeal = new JFormattedTextField();
        ftfSeal.setColumns(15);
        jpMain.add(ftfSeal, c);
        c.gridwidth = GridBagConstraints.REMAINDER;
        print = new JButton("Print");
        print.setEnabled(false);
        jpMain.add(print, c);
        System.out.println("jpMain: " + jpMain.getSize());
        //jpMain.setMinimumSize(jpMain.getSize());
        add(jpMain, c);
        revalidate();
      public void createGUI() {
        frame = new JFrame("Receiving Organizer");
        frame.setResizable(true);
        frame.setLocationByPlatform(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(this);
        System.out.println("Before pack: " + frame.getSize());
        //Display the window.
        frame.pack();
        System.out.println("After pack: " + frame.getSize());
        frame.setMinimumSize(frame.getSize());
        frame.setMinimumSize(frame.getSize());
        frame.setVisible(true);
    }db
    edit And you had two instances of ReceivingOrganizer, one instantiated in main(...) and the other in createGUI(). You don't need this, just add the present instance to the frame.
    Edited by: DarrylBurke

  • ACE Web GUI Interesting Problem

    I have a very strange issue with the ACE web GUI interface. I have 2 ACE's that are in Active/Standby setup with a floating management IP address for each context. Now when I try to login to the Web interface with the Floating Mgmt. IP address for one of my contexts it always takes me to the Admin context and not the one I am trying to hit. I did some testing and I found it does this with every context when you try to login to the Web interface using the floating IP address. If I use one of the real IP's of an individual ACE I am able to get logged into the correct context. Has anybody else run into this? Is there something I can do to fix it? Also I noticed that when you login to the web interface using that same floating IP address it always passes RADIUS requests as the Admin context IP address as well.

    I don't see this problem with version A3(2.x)
    This was fixed with CSCso98451
    G.

  • Studio Management GUI Rendering Problem - Windows 8.1

    I've got a problem that I can't seem to find the solution to anywhere.  I recently purchased a new computer with Windows 8.1 and am having trouble with SQL Express 2012.  The GUI rendering within the Server Management Studio seems to be really
    messed up.  Any help would be much appreciated.  I've updated everything I can think of (Windows, SQL Express, video drivers, etc) to no avail.  
    Biggest problem initially is that when I go through the "Restore Database" process windows are not showing correctly.  Such as the dialog box where I go find my database backup file - there are no files listed - it is just a blank dialog box.
    Any help or ideas would be greatly appreciated.  Thanks in advance.
    (I would post some screenshots but I'm waiting for my account to be verified)

    Hi JaredBaszler,
    According to your description, when you install SQL Server 2012 Express on Windows 8, the SQL Server Management studio dialogs could not displayed clearly. We need to verify if there is the third party software or antivirus software in your Server.
     In addition, if your Windows Server works in high-DPI displays. There is detail about
    living a High-DPI desktop
    As you post, we recommend you install SQL Server 2012 on a clean machine, and check if the same error exists, if yes, the installation media 
    may be encountered some changes. And you can download the media again in Microsoft websites and reinstall again. If it display 
    normally in your new machine, reinstall again on your original computer.
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Cisco 881W - ap gui interface problem

    We have a new Cisco 881W wireless router;
    used the CP Express gui interface to perform initial setup;
    router assigned 10.10.10.3 as wireless ap gui interface;
    when entering ap gui the entire screen is blank expect for an "enter" button near bottom;
    clicking on this button does nothing; "error on page" is indicated on IE8 status;
    assigned SSID is not broadcasting

    Hi !!
    im the same problem , but i fix it
    first you must change the IOS version to ap801-k9w7-tar.124-10b.JDA3 ( you can dowload for the cisco web )
    after download the image file you putt this command in the ap exec mode:
    ap#archive download-sw /overwrite /force-reload tftp://x.x.x.x/ap801-k9w7-tar.124-10b.JDA3.tar
    after the files are copied to flash memmory , the routyer boots with the new image ang bug fixed
    its is my configuration working: 
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Current configuration : 3267 bytes
    version 12.4
    no service pad
    service timestamps debug datetime msec
    service timestamps log datetime msec
    service password-encryption
    hostname ap
    enable secret 5 $1$T0Qk$/wKGmrwqo0WcBbvTapaNb.
    no aaa new-model
    dot11 ssid CASIO
       vlan 1
       authentication open
       authentication key-management wpa
       guest-mode
       wpa-psk ascii 7 121A04041B04010132222727
    crypto pki trustpoint TP-self-signed-4051168682
    enrollment selfsigned
    subject-name cn=IOS-Self-Signed-Certificate-4051168682
    revocation-check none
    rsakeypair TP-self-signed-4051168682
    crypto pki certificate chain TP-self-signed-4051168682
    certificate self-signed 01
      3082023A 308201A3 A0030201 02020101 300D0609 2A864886 F70D0101 04050030
      31312F30 2D060355 04031326 494F532D 53656C66 2D536967 6E65642D 43657274
      69666963 6174652D 34303531 31363836 3832301E 170D3131 30383139 31303037
      33385A17 0D323030 31303130 30303030 305A3031 312F302D 06035504 03132649
      4F532D53 656C662D 5369676E 65642D43 65727469 66696361 74652D34 30353131
      36383638 3230819F 300D0609 2A864886 F70D0101 01050003 818D0030 81890281
      8100B090 26BE5E77 FCB338C0 F54949DB 43EF95C1 61A9C3FA 38AC8BDC 18931195
      B1B1A503 65A71B68 8940639A FB6A6D9B 0F327B09 F5C48ECD 89C1B279 9DC6DC98
      11E5D014 914200BB 7F29CFD1 1CC5FDF0 F3AFE547 4954E2CA 37FC1CEC 60641871
      D9949391 35C958B3 FBA6FBF7 116612FD DFAB9467 478A6E07 0F7B2616 F1204158
      EC510203 010001A3 62306030 0F060355 1D130101 FF040530 030101FF 300D0603
      551D1104 06300482 02617030 1F060355 1D230418 30168014 1120DB6C BE01CDEE
      64A2DB14 FA240B27 D3573B9B 301D0603 551D0E04 16041411 20DB6CBE 01CDEE64
      A2DB14FA 240B27D3 573B9B30 0D06092A 864886F7 0D010104 05000381 81003B69
      8FC11090 E61D3BC1 D04FBDC5 622E8BC6 EB63B9FA C795BB15 BB05F417 CFC51F09
      A8A1971E 7E523203 5A40654D B71623CB A48B193A 101FD1AD 868128E9 91940B71
      5CFDDDD4 856B8170 7700C656 A75443DF DBB60F06 67E37A70 69175B84 24AB0380
      221AAA1D 3EB80465 FD1C1F49 B75B0F1D BC4A82B2 EB2176F2 27F54894 5E94
      quit
    username Cisco password 7 106D000A0618
    username ivan privilege 15 secret 5 $1$eEHQ$Dc.dDfXJz2fBbPIGhH.zg1
    bridge irb
    interface Dot11Radio0
    no ip address
    no ip route-cache
    encryption vlan 1 mode ciphers tkip
    ssid CASIO
    speed  basic-11.0 basic-12.0 basic-18.0 basic-24.0 basic-36.0 basic-48.0 basic-54.0
    station-role root
    interface Dot11Radio0.1
    encapsulation dot1Q 1 native
    no ip route-cache
    bridge-group 1
    bridge-group 1 subscriber-loop-control
    bridge-group 1 block-unknown-source
    no bridge-group 1 source-learning
    no bridge-group 1 unicast-flooding
    bridge-group 1 spanning-disabled
    interface GigabitEthernet0
    description  the embedded AP GigabitEthernet 0 is an internal interface connecting AP with the host router
    no ip address
    no ip route-cache
    interface GigabitEthernet0.1
    encapsulation dot1Q 1 native
    no ip route-cache
    bridge-group 1
    no bridge-group 1 source-learning
    bridge-group 1 spanning-disabled
    interface BVI1
    ip address 192.168.10.5 255.255.255.0
    no ip route-cache
    ip http server
    ip http authentication local
    ip http secure-server
    ip http help-path http://www.cisco.com/warp/public/779/smbiz/prodconfig/help/eag
    bridge 1 route ip
    line con 0
    no activation-character
    line vty 0 4
    login local
    end
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    now you cant acces to ap web gui 
    thanks !!!

  • Display in gui-base problem ??

    I am going to put those elemets that i construct on the top of my gui base-panel .how come it can`t display what i want ?
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Login extends JFrame
    private Container contents;
    private JLabel  NameOfTheTeaml, NameOfTheTeam2, message;
    private JTextField Team1, Team2;
    private JPasswordField password;
    private JTextArea legal;
    // Constructor
    public Login( )
      super( "Login Screen" );
      contents = getContentPane( );
      //contents.setLayout( new GridLayout(1,2));
      JPanel top = new JPanel(new GridLayout(1,2));
      top.setBackground(Color.WHITE);
      NameOfTheTeaml = new JLabel( "Team1 :" ); // label for Team1
      Team1 = new JTextField(6);      // instantiate Team1 text field
      top.add( NameOfTheTeaml );
      top.add( Team1 );
      NameOfTheTeam2 = new JLabel( "Team2 : " ); //label for Team2
      Team2 = new JTextField(6); // instantiate Team1 text field
      top.add( NameOfTheTeam2 );
      top.add( Team2 );
      message = new JLabel( "World Cup" );  // label to hold messages
      top.add( message );
      TextFieldHandler tfh = new TextFieldHandler( );
      // add event handler as listener for ID and password fields
      Team1.addActionListener( tfh );
      Team2.addActionListener( tfh );
      setSize( 550, 300 );
      setVisible( true );
    // private inner class event handler
    private class TextFieldHandler implements ActionListener
      public void actionPerformed( ActionEvent e )
       if ( Team1.getText( ).equals( "" )  || ( ( Team2.getText( ) ) ).equals( "" ) )     
          message.setForeground( Color.RED );
          message.setText( "Sorry!! Please enter two teams" );
       else
             message.setForeground( Color.BLACK );
          message.setText( Team1.getText() + "VS" + Team2.getText());
    public static void main( String [] args )
      Login login = new Login( );
      login.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    }

    I am going to put those elemets that i construct on
    the top of my gui base-panel .how come it can`t
    display what i want ? How am I supposed to know what you want? You need to tell us what it does and what you want it to do instead.

  • GUI standard problem...

    i have a Jframe containing nested jsplitpane's divided as follows:
    | | |
    | |____|
    | | |
    |__|____|
    the left JSplit pane consists of the a JTree inside a JScrollPane and the right JPlitPane. The right JSplitPane consists of a JList in a JScrollPane in the top and a JTextPane in a JScrollPane in the bottom. On clicking an element in the JTree the JList alters and on clicking an element in the JList the JTextPane alters. the problem i have that when altering the JTextPane with the following code:
    textPane = new JTextPane("SOME TEXT");
    bottomRightScrollPane = new JScrollPane(textPane);
    the JTextPane does not update. I have gone through the root of re-adding all of the 3 components to the JFrame and then calling setVisible(true) which works, but it makes the GUI blink and i am sure there is a clearer, better, easier way of doing this. I have also tried the random adding of repaint() to every component i could find but again to no avail, Any help would be greatly appreciated as to how i can get the bottom right JScrollPane to show the update JTextPane. Thanks in advance.

    thanks again, the setDocument method does work, but unforutnatley i have mouseListeners and hyperlink listeners in the pane that i am overwrtiing the old pane with. Is there anyway to transfer these as well?
    I tried using the revalidate method on the JScrollPane the text pane is in, the textpane itself, the splitpane the scroll pane is in and the split pane the splitpane is in. i also tried doing all of these at the same time but this didn't seem to do anything. Thanks again, if there is no easy solution do not worry since i can use the setVisible() method i have been using as it does the job, if in a somewhat ugly fashion.

  • GUI Multithreading problems

    I'm making a chat client and I'm having problems with the threading around the GUI. It works when I don't use the GUI (and ActionListeners aren't at fault). I basically have two threads, a send thread and a receive thread, which are both subclasses that extend Thread. When I start them through the GUI, on an ActionListener, they don't work... but when I start them in a program that is GUI-less, they do work. Just for clarification, it's not the ActionListeners at fault, I tried doing a System.out on the same ActionListener and it worked.
    A peculiarity is that when I make a new instance of the same frame [another frame.setVisible(true)] in my Receive thread, it starts receiving on the new window. I get the messages from the server, but I can't send stuff. I used to view this as a half-success, but now I think I'm going about it all wrong.
    So, here's my questions:
    1.Do I need to make more threads? I thought that everything outside the Receive and Send threads were naturally in a thread themselves, but it seems that they are not. Should I put the TextArea in my GUI that receives messages in a different Thread?
    2.Or is the problem that I have to somehow refresh the frame without causing it to make new frames?

    It's hard to tell what's going on without seeing your code. What do you mean when you say "When I start them through the GUI, on an ActionListener, they don't work"? Does that mean the threads don't start, or you don't see anything happening in GUI, or everything freezes, or... etc, etc.? Please post code or describe the sequence of events in detail so we can help.
    As a guess, it sounds like you're starting your threads when you press send, which doesn't sound right. In a chat, both threads should be running from the beginning, and when you have stuff to send you put it in a queue, then let the send thread pick it up. The receive thread just receives and puts messagese in the GUI. - see http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html

  • GUI freeze problem

    Hi everyone, im having a new problem with my sockets, i want to implement a button to stop server but because its client/server architecture it is freezed, how can i separate interface, please help :S

    Like you say hiwa maybe the problems is the client, i posted in other post, but is not problem to post it again, thanks!!!
    import java.net.*;
    import java.io.*;
    public class RecivirArchivoEncriptado2{
      String fileCharSet;
      String separator;
      Socket clientsocket;
      BufferedReader socketInput;
      String s;
      public RecivirArchivoEncriptado2(){
        fileCharSet = "UTF-8";
        separator = "##$##$##";
        try {
          clientsocket = new Socket("127.0.0.1", 12349);
          socketInput = new BufferedReader
           (new InputStreamReader(clientsocket.getInputStream(), fileCharSet));
        catch (Exception e){
          e.printStackTrace();
       public void doFileGet(){
        try{
          PrintWriter fileOutput
           = new PrintWriter(new FileOutputStream("archivoEncriptado.txt"), true);
          while ((s = socketInput.readLine()) != null){
            if (s.equals(separator)){
              break;
            fileOutput.println(s);
          fileOutput.close();
          fileOutput.flush();
          System.out.println("archivo encriptado recivido");
          fileOutput
           = new PrintWriter(new FileOutputStream("archivoPlano.txt"), true);
          while ((s = socketInput.readLine()) != null){
            fileOutput.println(s);
          fileOutput.flush();
          fileOutput.close();
          System.out.println("archivo plano recivido");
          socketInput.close();
          clientsocket.close();
        catch(IOException e) {
          System.out.println("conection refused port 12345");
      }}

  • GUI update problem: button take time to be disabled

    I have a Stop button. In the actionPerformed() method for the button, I disable the button and also some other buttons (using setEnabled(false)) then there are some other codes that include Thread.sleep() method. Then again I enable some other buttons. Problem is the Stop button take time to be disabled. The time exactly equals sec provided in the sleep() method. I tried by puting the button disabling buttons' code in another thread that is called from SwingUtilies.invokeLater() method just before the sleep() method. It is very important to disable some buttons before Thread.sleep() is called. And only after the sleep() method I can enable some other buttons.
    Please help me.

    Hello Experts! I can't hear you. 1) Swing related questions should be posted in the Swing forum
    2) Quit bumping your question, you only posted it 30 minutes ago. People will answer when they have the time.
    Your code in the actionListener needs to be executed in a separate Thread, so that when you invoke the "sleep" method the separate Thread sleeps, not the Event Thread.

  • WLC 2112 GUI Connection problem

    I am not able to connect to the GUI on the Cisco Wireless Controller 2112.  I noticed from the interface summary that the "GU" (GUI?) are all "No" on both the management and ap-manager interfaces.  How to set them to "Yes" from the console (CLI)?
    Thanks.
    <<<<System Info>>>>
    (Cisco Controller) >show interface summary
    Interface Name         Port Vlan Id  IP Address       Type     Ap Mgr Gu
    est
    ap-manager         1     untagged 10.1.4.62  Static  Yes     No
    management         1     untagged 10.1.4.61  Static  No      No
    virtual        N/A  N/A       1.1.1.1      Static  No      No
    (Cisco Controller) > show network summary
    RF-Network Name............................. RFGroup
    Web Mode.................................... Enable
    Secure Web Mode............................. Enable
    Secure Web Mode Cipher-Option High.......... Disable
    Secure Web Mode Cipher-Option SSLv2......... Enable
    Secure Shell (ssh).......................... Enable
    Telnet...................................... Enable
    Ethernet Multicast Mode..................... Disable
    Ethernet Broadcast Mode..................... Disable
    AP Multicast Mode........................... Multicast   Address : 0.0.0.0
    IGMP snooping............................... Disabled
    IGMP timeout................................ 60 seconds
    User Idle Timeout........................... 300 seconds
    ARP Idle Timeout............................ 300 seconds
    Cisco AP Default Master..................... Disable
    AP Join Priority............................ Disable
    Mgmt Via Wireless Interface................. Disable
    Mgmt Via Dynamic Interface.................. Enable
    Bridge MAC filter Config.................... Enable
    Bridge Security Mode........................ EAP
    Mesh Full Sector DFS........................ Enable
    --More-- or (q)uit
    Over The Air Provisioning of AP's........... Disable
    AP Fallback ................................ Enable
    Web Auth Redirect Ports .................... 80
    Fast SSID Change ........................... Disabled
    (Cisco Controller) > show run-config
    Interface Configuration
    Interface Name................................... ap-manager
    MAC Address...................................... 70:81:05:af:1d:20
    IP Address....................................... 10.1.4.62
    IP Netmask....................................... 255.255.252.0
    IP Gateway....................................... 10.1.2.1
    VLAN............................................. untagged 
    Physical Port.................................... 1
    Primary DHCP Server.............................. 10.1.2.1
    Secondary DHCP Server............................ Unconfigured
    DHCP Option 82................................... Disabled
    ACL.............................................. Unconfigured
    AP Manager....................................... Yes
    Guest Interface.................................. No
    Interface Name................................... management
    MAC Address...................................... 70:81:05:af:1d:20
    IP Address....................................... 10.1.4.61
    IP Netmask....................................... 255.255.252.0
    IP Gateway....................................... 10.1.2.1
    VLAN............................................. untagged 
    Quarantine-vlan.................................. 0
    Physical Port.................................... 1
    Primary DHCP Server.............................. 10.1.2.1
    Secondary DHCP Server............................ Unconfigured
    DHCP Option 82................................... Disabled
    ACL.............................................. Unconfigured
    AP Manager....................................... No
    Guest Interface.................................. No
    Interface Name................................... virtual
    MAC Address...................................... 70:81:05:af:1d:20
    IP Address....................................... 1.1.1.1
    DHCP Option 82................................... Disabled
    Virtual DNS Host Name............................ Disabled
    AP Manager....................................... No
    Guest Interface.................................. No

    Port 30 detail Info:
    GigabitEthernet0/30 is up, line protocol is up (connected)
      Hardware is Gigabit Ethernet, address is 0c85.25d4.a91e (bia 0c85.25d4.a91e)
      MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,
         reliability 255/255, txload 1/255, rxload 1/255
      Encapsulation ARPA, loopback not set
      Keepalive set (10 sec)
      Full-duplex, 100Mb/s, media type is 10/100/1000BaseTX
      input flow-control is off, output flow-control is unsupported
      ARP type: ARPA, ARP Timeout 04:00:00
      Last input 00:00:31, output 00:00:00, output hang never
      Last clearing of "show interface" counters never
      Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
      Queueing strategy: fifo
      Output queue: 0/0 (size/max)
      5 minute input rate 0 bits/sec, 0 packets/sec
      5 minute output rate 0 bits/sec, 0 packets/sec
         6841 packets input, 2789942 bytes, 0 no buffer
         Received 3461 broadcasts (3042 multicasts)
         18549 runts, 0 giants, 0 throttles
         18549 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
         0 watchdog, 3042 multicast, 0 pause input
         0 input packets with dribble condition detected
         383015 packets output, 66928405 bytes, 0 underruns
         0 output errors, 0 collisions, 5 interface resets
         0 babbles, 0 late collision, 0 deferred
         0 lost carrier, 0 no carrier, 0 PAUSE output
         0 output buffer failures, 0 output buffers swapped out
    Interface summary
    *: interface is up
    IHQ: pkts in input hold queue     IQD: pkts dropped from input queue
    OHQ: pkts in output hold queue    OQD: pkts dropped from output queue
    RXBS: rx rate (bits/sec)          RXPS: rx rate (pkts/sec)
    TXBS: tx rate (bits/sec)          TXPS: tx rate (pkts/sec)
    TRTL: throttle count
      Interface               IHQ   IQD  OHQ   OQD  RXBS RXPS  TXBS TXPS TRTL
    * Vlan1                    0 12861    0     0     0    0     0    0    0
      GigabitEthernet0/1       0     0    0     0     0    0     0    0    0
    * GigabitEthernet0/2       0     0    0     0     0    0  2000    1    0
      GigabitEthernet0/3       0     0    0     0     0    0     0    0    0
      GigabitEthernet0/4       0     0    0     0     0    0     0    0    0
      GigabitEthernet0/5       0     0    0     0     0    0     0    0    0
      GigabitEthernet0/6       0     0    0     0     0    0     0    0    0
      GigabitEthernet0/7       0     0    0     0     0    0     0    0    0
      GigabitEthernet0/8       0     0    0     0     0    0     0    0    0
      GigabitEthernet0/9       0     0    0     0     0    0     0    0    0
      GigabitEthernet0/10      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/11      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/12      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/13      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/14      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/15      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/16      0     0    0 7219768     0    0     0    0    0
      GigabitEthernet0/17      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/18      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/19      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/20      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/21      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/22      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/23      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/24      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/25      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/26      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/27      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/28      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/29      0     0    0     0     0    0     0    0    0
    * GigabitEthernet0/30      0     0    0     0     0    0  2000    2    0
      GigabitEthernet0/31      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/32      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/33      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/34      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/35      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/36      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/37      0     0    0 4997649     0    0     0    0    0
      GigabitEthernet0/38      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/39      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/40      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/41      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/42      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/43      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/44      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/45      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/46      0     0    0     0     0    0     0    0    0
    * GigabitEthernet0/47      0     0    0 5011848     0    0  2000    2    0
      Interface               IHQ   IQD  OHQ   OQD  RXBS RXPS  TXBS TXPS TRTL
      GigabitEthernet0/48      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/49      0     0    0     0     0    0     0    0    0
      GigabitEthernet0/50      0     0    0     0     0    0     0    0    0
    * GigabitEthernet0/51      0     0    0     0  3000    3  1000    1    0
      GigabitEthernet0/52      0     0    0     0     0    0     0    0    0

  • Non-GUI Terminal problem.

    I am having a problem with the terminal at boot (not the terminal emulator). I could have sworn there was a cursor/insertion point (aka flashing vertical bar) in command line. But now whenever I boot into command line, the insertion point is gone.

    I know of no such thing but I am told the hardware sometimes does its own.

Maybe you are looking for