Results 1 to 2 of 2
  1. #1
    er.raj is offline Member
    Join Date
    Mar 2012
    Posts
    15
    Rep Power
    0

    Default Problem with GUI in java applet using swing in eclipse

    I am trying to make a chat like GUI in eclipse using the swing library.
    The basic code is working with one small problem. When I run the program, the graphics are not displayed. But, when I click on the window boundary or maximize it, they show up. I can't figure out whats the issue here.

    This is my code
    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    
    public class TextArea1 extends JApplet implements ActionListener {
      private static final String NULL = null;
      JTextField Input;
      JTextArea Echo;
      JScrollPane scrolltxt ;
      Container Panel;
      LayoutManager Layout;
    
      public TextArea1 () {
    	  JFrame frame = new JFrame("Counselling centre");
    	  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	  setLayout(new BorderLayout());
    
    	Input = new JTextField (20);
        Echo = new JTextArea ("\n");
        JLabel label=new JLabel("YOU :");
        JLabel label1=new JLabel("WELCOME");
        Layout = new FlowLayout ();
        Panel = getContentPane ();
        Panel.setLayout(null);
        Echo.setEditable (false); 
        scrolltxt = new JScrollPane(Echo);
        Input.addActionListener (this);
        
        label1.setBounds(40, 10, 220, 30);
        label.setBounds(20, 400, 220, 30);
        Input.setBounds(70, 400, 450, 30);
    	scrolltxt.setBounds(40, 45, 500, 300);
    	  
        Echo.setLineWrap (true);
        Panel.add(label1);
        Panel.add(label);
        Panel.add (Input);
        Panel.add (scrolltxt);
       
    
        frame.add(Panel);
        frame.setSize(600,600);
        frame.setVisible(true);
    
      }
    
      public void actionPerformed (ActionEvent e)  {
        String Reply;
        Reply =  Input.getText();
    	Input.setText("");
        Echo.append("YOU : "+ Reply + "\n\n");
        
       
      }
    public static void main(String[] args){
      TextArea1 obj = new TextArea1();
    }
        
    }
    Any help on this will be appreciated.
    Last edited by er.raj; 03-26-2012 at 03:23 PM.

  2. #2
    er.raj is offline Member
    Join Date
    Mar 2012
    Posts
    15
    Rep Power
    0

    Default Re: Problem with GUI in java applet using swing in eclipse

    Okay so the problem seems to be solved now.
    Removing "extends JApplet" fixed it.

Similar Threads

  1. Swing -> Applet size problem
    By y2k in forum Java Applets
    Replies: 5
    Last Post: 03-07-2012, 08:33 PM
  2. Replies: 4
    Last Post: 09-13-2011, 08:28 PM
  3. Swing applet problem
    By link6790 in forum New To Java
    Replies: 9
    Last Post: 05-24-2011, 02:31 PM
  4. Running as Java Applet in eclipse
    By atomant in forum New To Java
    Replies: 0
    Last Post: 12-05-2010, 02:22 AM
  5. Replies: 0
    Last Post: 11-20-2008, 01:49 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •