Results 1 to 6 of 6

Thread: How to use BoundedRangeModel interface?

  1. #1
    Join Date
    Jan 2010
    Posts
    112

    How to use BoundedRangeModel interface?

    Hello Friends,

    I need you help to solve my query which is related to the inbuilt classes of advanced java programming. I am totally confused about the use of BoundedRangeModel interface. I an not getting how to use methods of BoundedRangeModel interface of java. If anyone posse good knowledge about the BoundedRangeModel interface, then please let me know that. I will really appreciate your any help over BoundedRangeModel interface.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: How to use BoundedRangeModel interface?

    A BoundedRangeModel interface defines the data model used by components like Sliders and ProgressBars. Defines four interrelated integer properties: minimum, maximum, extent and value. The outer range is minimum,maximum and the inner range is value,value+extent. The inner range must lie within the outer one, i.e. value must be less than or equal to maximum and value+extent must greater than or equal to minimum, and maximum must be greater than or equal to minimum. There are a few features of this model that one might find a little surprising.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to use BoundedRangeModel interface?

    Hi friend,

    If you want to know about the use of BoundedRangeModel interface, then refer following java example:
    Code:
    import javax.swing.BoundedRangeModel;
    import javax.swing.JButton;
    
    public class BoundedRangeModelDM {
    
      public static void main(final String arhgs[]) {
        JFrame af = new JFrame("Offset Example");
        af.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel pn = new JPanel(new BorderLayout());
        final JTextField textField = new JTextField();
        pn.add(textField, BorderLayout.CENTER);
        af.add(pn, BorderLayout.NORTH);
        JButton button = new JButton("Get Offset");
        ActionListener actionListener = new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            System.out.println("Offset: " + textField.getScrollOffset());
            System.out.println("Visibility: " + textField.getHorizontalVisibility());
            BoundedRangeModel model1 = textField.getHorizontalVisibility();
            int extent1 = model1.getExtent();
            textField.setScrollOffset(extent1);
          }
        };
        button.addActionListener(actionListener);
        af.add(button, BorderLayout.SOUTH);
        af.setSize(200, 150);
        af.setVisible(true);
      }
    }

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to use BoundedRangeModel interface?

    Before using properties of BoundedRangeModel interface, you need to be aware about following it's methods:
    • setValueIsAdjusting(boolean bl)
    • setValue(int newValue)
    • setRangeProperties(int val, int extnt, int min, int max, boolean bl)
    • setMinimum(int Min)
    • removeChangeListener(ChangeListener chls)
    • addChangeListener(ChangeListener chls)

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to use BoundedRangeModel interface?

    Hi,

    I hope following java code will help you to know about the BoundedRangeModel interface:
    Code:
    import javax.swing.BoundedRangeModel;
    import javax.swing.event.ChangeListener;
    
    public class BRM extends JFrame 
    {
      public BRM() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JSlider slr = new JSlider();
        BoundedRangeModel mdl = slr.getModel();
        mdl.addChangeListener(new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            BoundedRangeModel m1 = (BoundedRangeModel) e.getSource();
            System.out.println("Slider position changed to " + m1.getValue());
          }
        });
        getContentPane().add(slr);
        pack();
      }
    
      public static void main(String[] args) {
        Main m1 = new Main();
        m1.setVisible(true);
      }
    }

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: How to use BoundedRangeModel interface?

    The setMaximum(int newMaximum) is one of the important method of BoundedRangeModel interface. This method is very useful to accommodate new values to the properties. A BoundedRangeModel interface is nothing but the implementation of class from 'DefaultBoundedRangeModel' class. The interface type of 'BoundedRangeModel interface' is of 'public'.

Similar Threads

  1. Replies: 7
    Last Post: 22-10-2011, 10:35 PM
  2. what is interface in java
    By Ansari Bros in forum Software Development
    Replies: 4
    Last Post: 10-01-2011, 10:07 AM
  3. Interface in C programming
    By Quattro in forum Software Development
    Replies: 4
    Last Post: 02-03-2010, 07:08 PM
  4. How to use RootPaneContainer interface
    By Gajananvihari in forum Software Development
    Replies: 5
    Last Post: 23-02-2010, 12:21 PM
  5. pc to rc car interface
    By agpraneet in forum Hardware Peripherals
    Replies: 6
    Last Post: 20-07-2009, 04:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,780,739.29400 seconds with 16 queries