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

Thread: Why does it get smaller when it's suppose to get bigger

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Why does it get smaller when it's suppose to get bigger

    So when you slide the slider the text is suppose to get BIGGER not SMALLER...anybody know what I've done wrong??
    int height=100;
    		int width=300;
    		setSize(width, height);
    		setLocation (0,0);
     
    		sentenceLabel=new JLabel ("Music Volume");
    		sentenceLabel.setFont (new Font ("Serif", Font.BOLD, 12));
     
    		slider=new JSlider (1,5,1);
    		slider.setPaintTicks(true);
    		slider.setMajorTickSpacing (1);
    		slider.setPaintLabels(true);
     
    		sizeAction=new ChangeListener()
    		{
    			public void stateChanged (ChangeEvent event)
    			{
    				JSlider slider=(JSlider)event.getSource();
    				Size=slider.getValue();
    				sentenceLabel.setFont (new Font ("Serif", Font.BOLD, Size));
    			}
    		};
    		slider.addChangeListener(sizeAction);
    		add (slider);
    		add (sentenceLabel);
     
    	}
    Last edited by helloworld922; March 26th, 2011 at 11:31 PM.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Why does it get smaller when it's suppose to get bigger

    Are you sure you're increasing the slider value? Put a println statement inside your ChangeListener and see if you are indeed dragging the slider the correct direction.

    Also, the value of the slider could be moved below or above the initial size so you'd have an instantaneous change in size at the first slider movement.

Similar Threads

  1. Bigger triangle made up of multiple ones?
    By Kimimaru in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 30th, 2011, 11:18 AM
  2. Is there an integer-type variable bigger than "long"?
    By bardd in forum Java Theory & Questions
    Replies: 2
    Last Post: September 3rd, 2010, 02:43 PM
  3. Bigger and Smaller
    By dylgod in forum Loops & Control Statements
    Replies: 4
    Last Post: July 28th, 2010, 09:18 AM
  4. Replies: 0
    Last Post: May 25th, 2010, 08:19 AM
  5. 2D Object makes my object smaller, Why?
    By MassiveResponse in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 15th, 2010, 02:33 PM