🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #9739

How do I move the Thumb?

#9739
From: Fred H. Porter PE
Date: Thu, 10 Feb 2000 00:00
76 lines
2470 bytes
The following applet works fine except when I enter data for 8:00 the
slider
shows up, but I do not know how to move the slider to the end.  How can
I programmatically move the Thumb to the bottom of the slide so the last

entry is visible?

Thanks in advance,
Fred
//****************************
package Temperatures;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Temperature extends JApplet implements ActionListener
{
  String times[] = {
    "00:00", "01:00", "02:00", "03:00", "04:00", "05:00",
    "06:00", "07:00", "08:00", "09:00", "10:00", "11:00",
    "12:00", "13:00", "14:00", "15:00", "16:00", "17:00",
    "18:00", "19:00", "20:00", "21:00", "22:00", "23:00"
  };

  int temp[] = new int[ 24 ];
  int i = 0;

  JLabel title = new JLabel("           Daily Temperatures
");
  JLabel tempPrompt = new JLabel(times[0]);
  JTextField tempIn = new JTextField(10);
  JTextArea results;

  public void init()
  {

    Container AC = getContentPane();
    AC.setLayout(new FlowLayout()); //change the layout manager
    AC.add(title);
    AC.add(tempPrompt);
    AC.add(tempIn);

    results = new JTextArea("Results of Calculations:\n", 10, 25);
    results.setRows(10);

    AC.add(new JScrollPane(results)); //add JScrollPane to get a slider

    tempIn.addActionListener(this);   //register to get text change
events

  }//end void main

  public void actionPerformed(ActionEvent e) // Button press event
handler
  {

    temp[i] = Integer.parseInt(tempIn.getText());   //obtain values
    results.append("\nTime: " + times[i] + " temperature is " +
temp[i]);

    if (++i < 24)
    {
      tempPrompt.setText(times[i]);
      tempIn.setText("");
    }
    else
    {
      JOptionPane.showMessageDialog(null, "Finished", "Trip
Information",
        JOptionPane.INFORMATION_MESSAGE );
      System.exit( 0 );
    }

  } // end void actionPerformed
}
Technical Details
Message-ID: <38A2DF69.F18B0E8F@pdspp.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,d4acbe03b613c6f1,start
X-Google-Attributes: gid111d45,public
From: "Fred H. Porter PE" <fredp@pdspp.com>
Subject: How do I move the Thumb?
Date: 2000/02/10
Message-ID: <38A2DF69.F18B0E8F@pdspp.com>
X-Deja-AN: 584148576
Content-Transfer-Encoding: 7bit
Organization: Porter Data Systems, Inc.
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing