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 5 of 5

Thread: Image Load

  1. #1
    Junior Member shadihrr's Avatar
    Join Date
    Jan 2010
    Location
    home
    Posts
    23
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Image Load

    Hi All!!!
    I wrote an applet class which has two panel: one panel is for program options contains a JcomboBox and the other has 1000 buttons(why 1000 button? see rest of the post I have questions on that too )
    when I run the applet I can't see the 1000 buttons on my screen unless I move my mouse on applet then they show up.
    and about 1000 buttons : my program is a game and I have a map .when you click on that it must handle the action. I write the class that extends Jbutton . and I know it's stupid.
    Please help me about it what is the better way to do that
    thanks all


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,894
    Thanks
    55
    Thanked 2,350 Times in 2,321 Posts

    Default Re: Image Load

    Can you make a small program that compiles and executes and demonstrates your problem?

  3. #3
    Member
    Join Date
    Jul 2010
    Location
    Washington, USA
    Posts
    307
    Thanks
    16
    Thanked 43 Times in 39 Posts

    Default Re: Image Load

    If you're trying to detect where a user clicks; Then I think a MouseListener would be more reliable.

    Here's a tutorial: How to Write a Mouse Listener

  4. #4
    Junior Member shadihrr's Avatar
    Join Date
    Jan 2010
    Location
    home
    Posts
    23
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: Image Load

    If you're trying to detect where a user clicks; Then I think a MouseListener would be more reliable.
    thanks for your posts. if this is about the second question I want to make a special area (for example a rectangle) as a component that has graphical features and could handle actions( for example like a button) . because each amount of area has its own properties.
    this is the simple code that has the first problem I guess that is because of the size of first panel. but why the next panel and All its buttons doesn't start from next to the first panel?
    public void init(){
    		this.setSize(500,600);
    		JPanel start=new JPanel();
    		start.setSize(100, 300);
    		String []names={"test1","test2"};
    		JComboBox jc=new JComboBox(names);
    		start.add(jc);
    		JPanel p2=new JPanel();
    		for (int i = 0; i < 1000; i++) {
    			JButton jb=new JButton();
    			jb.setBackground(Color.blue);
    			p2.add(jb);
    		}
    		start.setVisible(true);
    		p2.setVisible(true);
    		this.add(start);
    		this.add(p2);
    	}

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,894
    Thanks
    55
    Thanked 2,350 Times in 2,321 Posts

    Default Re: Image Load

    why the next panel and All its buttons doesn't start from next to the first panel?
    Sorry, I don't understand what the problem you are having is. Can you explain please?

    Are you talking about where the layout manager places added components in a container? The components are start and p2 and the container is "this"

Similar Threads

  1. Is it possible to load classes at runtime that are discovered from a directory
    By mydarkpassenger in forum Java Theory & Questions
    Replies: 11
    Last Post: June 10th, 2010, 11:33 AM
  2. pictures wont load
    By wolfgar in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 14th, 2010, 10:34 AM
  3. [SOLVED] I cant load the icon!!!!
    By chronoz13 in forum AWT / Java Swing
    Replies: 12
    Last Post: January 22nd, 2010, 03:52 AM
  4. Arraylist Save and Load
    By frankycool in forum Collections and Generics
    Replies: 1
    Last Post: November 14th, 2009, 06:48 AM
  5. Pixel Alteration in an image/image rotation
    By bguy in forum Java Theory & Questions
    Replies: 3
    Last Post: November 1st, 2009, 10:50 AM