Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By Tolls

Thread: how to add functionality in dialog window

  1. #1
    lookinginfo is offline Member
    Join Date
    Feb 2013
    Posts
    4
    Rep Power
    0

    Question how to add functionality in dialog window

    Hello, i am new to AWT.

    created the login window.

    Question is how to add the following

    1) Dialog window should disappear when click on "X"
    2) Dialog window should minimize when click on "-"
    3) Dialog window should maximize when click on "="
    4) Dialog window should disappear when click on "Cancel"

    Java Code:
     
    
    import java.awt.*;
    
    public class LoginWindow extends Frame
    {
    	
    	public LoginWindow(String s1)
    	{
    		super(s1);
    		setBounds(300, 200, 325, 140);
    		
    		setLayout(new FlowLayout());
    		setBackground(Color.GRAY);
    		
    		add(new Label("Username"));
    		TextField tf1=new TextField(10);
    		add(tf1);
    		
    		add(new Label("Password"));
    		TextField tf2=new TextField(10);
    		tf2.setEchoChar('*');
    		add(tf2);
    		
    		Button bt1=new Button ("Login");
    		bt1.setBackground(Color.gray);
    		add(bt1);
    		
    		Button bt2=new Button ("Canel");
    		bt2.setBackground(Color.gray);
    		add(bt2);
    		
    	}
    	
    	public static void main (String []arg)
    	{
    		Frame myframe=new LoginWindow("Login Window");
    		myframe.setVisible(true);
    				
    	}
    
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,085
    Rep Power
    20

    Default Re: how to add functionality in dialog window

    If you're learning then can I suggest learning Swing or Java FX?
    Swing has been the GUI framework for Java since the late 90s, until recently...itself being replaced by JavaFX 2.
    It seems to me you'll just pick up bad habits if you learn AWT.
    DarrylBurke likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    lookinginfo is offline Member
    Join Date
    Feb 2013
    Posts
    4
    Rep Power
    0

    Default Re: how to add functionality in dialog window

    thanks for your suggestion. but i need to learn AWT and make this code work. any help would be appreciated

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default Re: how to add functionality in dialog window

    Quote Originally Posted by lookinginfo View Post
    ... i need to learn AWT ...
    Why?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default Re: how to add functionality in dialog window

    AWT never was used much...
    The Java Tutorial. Read it.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default Re: how to add functionality in dialog window

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Closing secondary window from button in primary window
    By KoncentriK in forum New To Java
    Replies: 4
    Last Post: 02-26-2012, 01:24 AM
  2. Replies: 28
    Last Post: 12-30-2010, 11:40 PM
  3. Replies: 3
    Last Post: 05-05-2010, 03:10 AM
  4. Replies: 18
    Last Post: 11-22-2008, 05:25 PM
  5. main window & print dialog
    By roo7 in forum Advanced Java
    Replies: 3
    Last Post: 01-02-2008, 06:50 AM

Posting Permissions

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