JSLider Programador Java Interfaz Gráfico GUI AWT Swing 1 Swing 2
JSpinner Programador Java Interfaz Gráfico GUI AWT Swing 1 Swing 2 |
|
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class JSpinnerr extends JFrame {
private JLabel jLabel1 = new JLabel();
private JSpinner jSpinner1 = new JSpinner();
private JLabel jLabel2 = new JLabel();
public JSpinnerr(String title) {
super(title);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
int frameWidth = 300;
int frameHeight = 300;
setSize(frameWidth, frameHeight);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (d.width - getSize().width) / 2;
int y = (d.height - getSize().height) / 2;
setLocation(x, y);
setResizable(false);
Container cp = getContentPane();
cp.setLayout(null);
cp.setBackground(new Color(0x2BD59D));
jLabel1.setBounds(32, 24, 243, 73);
jLabel1.setText("JSpinner");
jLabel1.setFont(new Font("Gunplay 3D", Font.BOLD, 36));
jLabel1.setForeground(Color.MAGENTA);
cp.add(jLabel1);
jSpinner1.setBounds(72, 120, 169, 41);
jSpinner1.setModel(new SpinnerNumberModel(0,0,10,1));
cp.add(jSpinner1);
jLabel2.setBounds(72, 184, 179, 33);
jLabel2.setText("");
cp.add(jLabel2);
jSpinner1.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent evt) {
jSpinner1_stateChanged(evt);
}
});
setVisible(true);
}
public void jSpinner1_stateChanged(ChangeEvent evt) {
jLabel2.setText("El valor es: "+jSpinner1.getValue());
}
public static void main(String[] args) {
new JSpinnerr("JSpinnerr");
}
}
|
No hay comentarios:
Publicar un comentario