Help - Using JSlider to zoom on a grid

Discussion in 'Programming General' started by Darkgroove, Oct 15, 2010.

Help - Using JSlider to zoom on a grid
  1. Unread #1 - Oct 15, 2010 at 6:09 PM
  2. Darkgroove
    Referrals:
    0

    Darkgroove Guest

    Help - Using JSlider to zoom on a grid

    I have no idea how I'd go about doing this. Can anyone provide some insight?
     
  3. Unread #2 - Oct 15, 2010 at 6:24 PM
  4. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Help - Using JSlider to zoom on a grid

    Add your own implementation of the ChangeListener interface to your JSlider. In the overridden stateChanged() method, get the current value of the JSlider and use that to zoom.

    In pseudo-code
    Code:
    final JSlider jSlider = ...; //Whatever your JSlider is; it's marked final so it can be accessed by the anonymous inner class declared below
    jSlider.addChangeListener(new ChangeListener()
    {
        @Override
        public void stateChanged(ChangeEvent e)
        {
            int zoomValue = jSlider.getValue();
            zoom(zoomValue); //Do whatever you need to do to zoom to the given value; idk what you're using specifically as your grid so I can't go into much more detail on this
        }
    });
     
  5. Unread #3 - Oct 15, 2010 at 7:40 PM
  6. Darkgroove
    Referrals:
    0

    Darkgroove Guest

    Help - Using JSlider to zoom on a grid

    I've already done all the listeners. I don't know how I'd physically zoom into a GridLayout though.
     
< 1 bit games? | Really good C video tutorials >

Users viewing this thread
1 guest


 
 
Adblock breaks this site