Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Confuced when import packages...

  1. #1
    Junior Member
    Join Date
    May 2010
    Location
    Ratnapura,Sri Lanka
    Posts
    8
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Post Confuced when import packages...

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class MyFrame extends JFrame{
    	JButton btYes;
    	JButton btNo;
    	JButton btCancel;
     
    	MyFrame(){
    		setLayout(new FlowLayout());
     
    		btYes=new JButton("Yes");
    		btYes.addActionListener(new MyAction());
    		btNo =new JButton("No");
    		btCancel=new JButton("Cancel");
     
    		add(btCancel);
    		add(btNo);
    		add(btYes);
    		pack();
    	}
    	public static void main(String args[]){
    	new MyFrame().setVisible(true);
    	}
    }
    class MyAction implements ActionListener{
    	public void actionPerformed(ActionEvent evt){
    		JOptionPane.showMessageDialog(null,"You pressed Yes Button");
    	}
    }

    Dear java friends; I'm confused when import package using * .
    When we import awt package by import java.awt.*; as I know it imports all the classes in awt package. If so why we have to call import java.awt.event.*; in this program. Please be kind to help me to solve this problem.


  2. #2
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    491
    Thanks
    8
    Thanked 47 Times in 45 Posts

    Default Re: Confuced when import packages...

    What problem?

    db

  3. #3
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    491
    Thanks
    8
    Thanked 47 Times in 45 Posts

    Default Re: Confuced when import packages...

    More here (link below)
    Packages

    db

  4. The Following User Says Thank You to Darryl.Burke For This Useful Post:

    Delmi (May 21st, 2010)

Similar Threads

  1. [SOLVED] placing packages of the same directory into an array
    By javanub:( in forum Java Theory & Questions
    Replies: 16
    Last Post: May 18th, 2010, 07:49 AM
  2. from where i should import
    By javaking in forum Java SE APIs
    Replies: 0
    Last Post: April 12th, 2010, 07:51 AM
  3. [SOLVED] Do i need to import anything here?
    By straw in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 6th, 2010, 05:42 PM
  4. A Question Regarding Abstract Classes & Packages
    By Kerubu in forum Object Oriented Programming
    Replies: 3
    Last Post: December 21st, 2009, 12:27 PM
  5. importing packages..
    By chronoz13 in forum Java IDEs
    Replies: 4
    Last Post: November 23rd, 2009, 04:49 PM