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

Thread: need help for the few question for java program!!

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default need help for the few question for java program!!

    i have some confuse this dew question!can you let me know how to solution this few question!thank you!!!pls refer the attachment!

    1.jpg2.jpg


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: need help for the few question for java program!!

    Please post the full text of the questions (not an image!!!) and your answers for all of them or what your ideas are about each question so we can help you understand.

    Is this the same question:
    need help for the few question for java program!!
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: need help for the few question for java program!!

    Are you seriously just dumping your homework here? That's pretty rude...
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    Junior Member
    Join Date
    Apr 2012
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: need help for the few question for java program!!

    for q4!my program on below,cab you let me know why i click the button,why can not change the size?please help!!

    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class tma2 {

    public static void main(String[] args) {
    JFrame jj=new JFrame("adjust");
    int size=200;
    JButton big=new JButton("BIG");
    JButton small=new JButton("SMALL");
    big.addActionListener(new ActionListener(){
    protected int i=1;
    public void actionPerformed(ActionEvent e)
    {

    System.out.println(i++);
    }
    });
    small.addActionListener(new ActionListener(){
    protected int j=20;
    public void actionPerformed(ActionEvent e)
    {

    System.out.println(j++);
    }
    });
    jj.addWindowListener(new WindowAdapter()
    {
    public void WindowClosing(WindowEvent e)
    {
    System.exit(0);
    }
    });
    jj.getContentPane().add(big,"North");
    jj.getContentPane().add(small,"South");
    jj.setSize(size,size);
    jj.setVisible(true);
    }
    }

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: need help for the few question for java program!!

    Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting. Your formatting makes it very to hard and understand your code.

    Where do you try to change the size?
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Apr 2012
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: need help for the few question for java program!!

    please refer my attachment on below!

    11.jpg

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: need help for the few question for java program!!

    Please post what we need to see here on the forum.
    You can not copy and paste from an image.

    Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Junior Member
    Join Date
    Apr 2012
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: need help for the few question for java program!!

    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class jframe {
     
      public static void main(String[] args) {
        JFrame jj=new JFrame("adjust");
     
         int i=200;
     
        JButton big=new JButton("BIG");
        JButton small=new JButton("SMALL");
        big.addActionListener(new ActionListener(){
     
          public void actionPerformed(ActionEvent e)
          {
     
            System.out.println(i++);
     
            }
        });
        small.addActionListener(new ActionListener(){
     
          public void actionPerformed(ActionEvent e)
          {
     
            System.out.println(i--);
          }
        });
        jj.addWindowListener(new WindowAdapter()
        {
          public void WindowClosing(WindowEvent e)
          {
            System.exit(0);
       }
       });  
        jj.getContentPane().add(big,"North");
        jj.getContentPane().add(small,"South");
        jj.setSize(i,i);
        jj.setVisible(true);
      }
    }

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: need help for the few question for java program!!

    i click the button,why can not change the size
    Where do you try to change the size of anything?

    I see that the value of the variable: i is changed in the button listeners.
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Junior Member
    Join Date
    Apr 2012
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: need help for the few question for java program!!

    for part a
    You can change the size of a JFrame by using the setSize(int h, int v) method,where h and v give the horizontal and vertical dimensions of the applet’s window in pixels. Write a GUI application that contains two JButtons, labeled “Big” and “Small.” Whenever the user clicks on Small, set the applets dimensions to 200 x100, and whenever the user clicks on Big, set the dimensions to 300 x 200.
    for part b
    Rewrite your solution to the previous exercise so that it uses a single button, whose label is toggled appropriately each time it is clicked. Obviously, when the JButtonis labeled “Big,” clicking it should give the applet its big dimensions.

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: need help for the few question for java program!!

    Is that the answer to my question? I don't see how it does.

    How does the posted code change the size of anything?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Question About Program
    By metaleddie13 in forum Java Theory & Questions
    Replies: 3
    Last Post: October 14th, 2011, 06:19 PM
  2. First post, I have a question regarding this program
    By ResidentBiscuit in forum What's Wrong With My Code?
    Replies: 7
    Last Post: September 14th, 2011, 12:19 PM
  3. Question About A Program
    By torres9 in forum Java Theory & Questions
    Replies: 3
    Last Post: May 15th, 2011, 08:56 PM
  4. java applet program question (on getting path fails)
    By hellocheese in forum What's Wrong With My Code?
    Replies: 6
    Last Post: March 30th, 2011, 04:34 PM
  5. [SOLVED] How to narrow down the range of input in java?
    By big_c in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 20th, 2009, 11:38 AM