PROGRAMAS CONTROLES
3

import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.html.*;
/**
* This class can take a variable number of
parameters on the command
* line. Program
execution begins with the main() method. The class
* constructor is not
invoked unless an object of type 'Form1' is
* created in the
main() method.
*/
public class Form1 extends Form
{
public
Form1()
{
// Required for
Visual J++ Form Designer support
initForm();
// TODO: Add any
constructor code after initForm call
}
/**
* Form1 overrides dispose so it can clean up
the
* component list.
*/
int
h1=0;
int
h2=0;
int
h3=0;
int
suma=0;
public
void dispose()
{
super.dispose();
components.dispose();
trackBar1.setValue(100);
}
private
void button1_click(Object source, Event e)
{
label1.setText(comboBox1.getText()+ " " +
listBox1.getSelectedItem());
}
private
void HScrollBar1_scroll(Object source, ScrollEvent e)
{
h1=HScrollBar1.getValue();
suma=h1+h2+h3;
if (suma<100)
{
edit1.setText(String.valueOf(h1));
edit4.setText(String.valueOf(100 - suma));
}
}
private
void HScrollBar2_scroll(Object source, ScrollEvent e)
{
h2=HScrollBar2.getValue();
suma=h1+h2+h3;
if (suma<100)
{
edit2.setText(String.valueOf(h2));
edit4.setText(String.valueOf(100 - suma));
}
}
private
void HScrollBar3_scroll(Object source, ScrollEvent e)
{
h3=HScrollBar3.getValue();
suma=h1+h2+h3;
if (suma<100)
{
edit3.setText(String.valueOf(h3));
edit4.setText(String.valueOf(100 - suma));
}
}
private
void Form1_click(Object source, Event e)
{
}
private
void trackBar1_scroll(Object source, Event e)
{
edit5.setText(String.valueOf(100 - trackBar1.getValue()));
}
/**
* NOTE: The following code is required by the
Visual J++ form
* designer. It can be modified using the form
editor. Do not
* modify it using the
code editor.
*/
Container components = new Container();
ComboBox comboBox1 = new ComboBox();
ListBox listBox1 = new ListBox();
Label label1 = new Label();
Button button1 = new Button();
HScrollBar HScrollBar1 = new HScrollBar();
HScrollBar HScrollBar2 = new HScrollBar();
HScrollBar HScrollBar3 = new HScrollBar();
Edit edit1 = new Edit();
Edit edit2 = new Edit();
Edit edit3 = new Edit();
Edit edit4 = new Edit();
TrackBar trackBar1 = new TrackBar();
Edit edit5 = new Edit();
private
void initForm()
{
this.setText("Form1");
this.setAutoScaleBaseSize(new Point(5, 13));
this.setClientSize(new Point(495, 428));
this.addOnClick(new EventHandler(this.Form1_click));
comboBox1.setLocation(new Point(48, 80));
comboBox1.setSize(new Point(152, 21));
comboBox1.setTabIndex(0);
comboBox1.setText("Escoje el saludo");
comboBox1.setItems(new Object[] {
"Buenos Dias",
"Buenas Noches",
"Saludos",
"Adios",
"Hasta Maņana",
"Nos vemos el viernes"});
listBox1.setLocation(new Point(216, 80));
listBox1.setSize(new Point(144, 95));
listBox1.setTabIndex(1);
listBox1.setText("listBox1");
listBox1.setUseTabStops(true);
listBox1.setItems(new Object[] {
"Juan",
"Pedro",
"Salvador",
"Cecilio"});
label1.setLocation(new Point(96, 256));
label1.setSize(new Point(288, 24));
label1.setTabIndex(2);
label1.setTabStop(false);
label1.setText("");
button1.setLocation(new Point(80, 208));
button1.setSize(new Point(304, 24));
button1.setTabIndex(3);
button1.setText("construye el saludo");
button1.addOnClick(new EventHandler(this.button1_click));
HScrollBar1.setLocation(new Point(104, 304));
HScrollBar1.setSize(new Point(192, 16));
HScrollBar1.setTabIndex(4);
HScrollBar1.setText("HScrollBar1");
HScrollBar1.addOnScroll(new
ScrollEventHandler(this.HScrollBar1_scroll));
HScrollBar2.setLocation(new Point(104, 328));
HScrollBar2.setSize(new Point(192, 16));
HScrollBar2.setTabIndex(5);
HScrollBar2.setText("HScrollBar2");
HScrollBar2.addOnScroll(new ScrollEventHandler(this.HScrollBar2_scroll));
HScrollBar3.setLocation(new Point(104, 352));
HScrollBar3.setSize(new Point(192, 16));
HScrollBar3.setTabIndex(6);
HScrollBar3.setText("HScrollBar3");
HScrollBar3.addOnScroll(new ScrollEventHandler(this.HScrollBar3_scroll));
edit1.setLocation(new Point(48, 304));
edit1.setSize(new Point(40, 20));
edit1.setTabIndex(7);
edit1.setText("edit1");
edit2.setLocation(new Point(48, 328));
edit2.setSize(new Point(40, 20));
edit2.setTabIndex(8);
edit2.setText("edit2");
edit3.setLocation(new Point(48, 352));
edit3.setSize(new Point(40, 20));
edit3.setTabIndex(9);
edit3.setText("edit3");
edit4.setLocation(new Point(48, 384));
edit4.setSize(new Point(40, 20));
edit4.setTabIndex(10);
edit4.setText("edit4");
trackBar1.setLocation(new Point(376, 280));
trackBar1.setSize(new Point(42, 144));
trackBar1.setTabIndex(11);
trackBar1.setText("trackBar1");
trackBar1.setMaximum(100);
trackBar1.setOrientation(Orientation.VERTICAL);
trackBar1.addOnScroll(new
EventHandler(this.trackBar1_scroll));
edit5.setLocation(new Point(320, 328));
edit5.setSize(new Point(48, 20));
edit5.setTabIndex(12);
edit5.setText("edit5");
this.setNewControls(new Control[] {
edit5,
trackBar1,
edit4,
edit3,
edit2,
edit1,
HScrollBar3,
HScrollBar2,
HScrollBar1,
button1,
label1,
listBox1,
comboBox1});
}
/**
* The main entry point for the application.
*
* @param args Array
of parameters passed to the application
* via the command
line.
*/
public
static void main(String args[])
{
Application.run(new Form1());
}
}