Adblock breaks this site

Help - Using JSlider to zoom on a grid

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

  1. Darkgroove

    Darkgroove Guest

    Referrals:
    0
    Help - Using JSlider to zoom on a grid

    I have no idea how I'd go about doing this. Can anyone provide some insight?
     
  2. Jimmy

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25
    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
        }
    });
     
  3. Darkgroove

    Darkgroove Guest

    Referrals:
    0
    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 >


 
 
Adblock breaks this site