// COMPORTAMIENTO ELASTICO DE LOS COMPONENTES
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
//Leonardo Ramirez Ortiz ( OCT - 21 - 2010 )
class opciones extends JFrame
{
Panel principal;
JFrame ventana1 = new JFrame("Ventana Principal");
JFrame ventana2;
public static void main(String R[]) { new opciones(); }
public opciones()
{
this.setBounds(50, 50, 900, 500);
this.setVisible(true);
this.setLayout(null);
//this.add(principal);
ventana2 = new JFrame("Ventana Chikita");
principal = new Panel(ventana2);
this.add(principal);
principal.setBounds(0,0,900, 500);
principal.setBackground(Color.gray);
principal.setVisible(true);
ventana2.setBounds(1000, 50, 200, 200);
ventana2.setBackground(Color.green);
ventana2.setVisible(true);
}
protected void processWindowEvent(WindowEvent e)
{ if (e.getID() == WindowEvent.WINDOW_CLOSING) System.exit(0); }
}
class Panel extends JPanel
{
RCanvas area;
JButton boton;
JRadioButton op1,op2,op3;
ButtonGroup grupo;
JScrollBar barra;
JFrame ventana8 ;
public Panel( JFrame ventana8 )
{
setLayout(null);
this.ventana8 = ventana8;
boton = new JButton("resize");
add(boton);
boton.setBounds(150,300,80,25);
op1 = new JRadioButton("Boton");
add(op1);
op1.setBounds(50,50,100,50);
//op1.addActionListener(new evento1() );
op2 = new JRadioButton("Ventana");
add(op2);
op2.setBounds(50,100,100,50);
//op2.addActionListener(new evento2() );
op3 = new JRadioButton("Circulo");
add(op3);
op3.setBounds(50,150,100,50);
//op3.addActionListener(new evento3() );
barra = new JScrollBar(JScrollBar.HORIZONTAL,0,1,0,100);
add(barra);
barra.setBounds(0,425,900,50);
barra.addAdjustmentListener( new SCROLL() );
area = new RCanvas();
add(area);
area.setBackground(Color.cyan);
area.setBounds(450,150,450,300);
grupo = new ButtonGroup();
grupo.add(op1);
grupo.add(op2);
grupo.add(op3);
}
class SCROLL implements AdjustmentListener
{
public void adjustmentValueChanged(AdjustmentEvent e)
{
if ( op1.isSelected() ) boton.setSize(new Dimension(80+e.getValue(), 25));
if ( op2.isSelected() ) ventana8.setSize(200+e.getValue(), 200);
if ( op3.isSelected() ) { area.R = e.getValue(); area.repaint(); }
}
}
}
class RCanvas extends Canvas
{
int R = 50;
public RCanvas()
{
setBackground(Color.cyan);
setBounds(450,150,450,300);
}
public void paint(Graphics G)
{
G.drawOval(200, 200, R, R);
}
}