RADIO BUTTON Y COMBO
package Sexto;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JButton;
public class seis extends JFrame {
int vh=0,ht=0,he=0,vho=0,s=0,chm=0,vhm=0;
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JLabel texvalorhora = null;
private JTextField txtvalorhora = null;
private JLabel texcantidaddehoras = null;
private JTextField txthoras = null;
private JButton btnversalario = null;
private JTextField txtsalario = null;
private JLabel texsalario = null;
private JButton btnsiguiente = null;
private JButton btnsalir = null;
/**
* This method initializes txtvalorhora
*
* @return javax.swing.JTextField
*/
private JTextField getTxtvalorhora() {
if (txtvalorhora == null) {
txtvalorhora = new JTextField();
txtvalorhora.setBounds(new Rectangle(273, 13, 141, 19));
}
return txtvalorhora;
}
/**
* This method initializes txthoras
*
* @return javax.swing.JTextField
*/
private JTextField getTxthoras() {
if (txthoras == null) {
txthoras = new JTextField();
txthoras.setBounds(new Rectangle(274, 40, 139, 20));
}
return txthoras;
}
/**
* This method initializes btnversalario
*
* @return javax.swing.JButton
*/
private JButton getBtnversalario() {
if (btnversalario == null) {
btnversalario = new JButton();
btnversalario.setBounds(new Rectangle(419, 42, 128, 19));
btnversalario.setText("ver salario");
btnversalario.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
vh=Integer.parseInt(txtvalorhora.getText());
ht=Integer.parseInt(txthoras.getText());
if (ht>40){
he=(ht-40);
if (he<=8){
vho=((he*vh)*2);
s=((40*vh)+(vho));
}
if (he>8){
vho=((8*vh)*2);
chm=(he-8);
vhm=((chm*vh)*3);
s=((40*vh)+(vho)+(vhm));
}
}
else {
s=(vh*ht);
}
txtsalario.setText(String.valueOf(s));
}
});
}
return btnversalario;
}
/**
* This method initializes txtsalario
*
* @return javax.swing.JTextField
*/
private JTextField getTxtsalario() {
if (txtsalario == null) {
txtsalario = new JTextField();
txtsalario.setBounds(new Rectangle(223, 105, 157, 19));
}
return txtsalario;
}
/**
* This method initializes btnsiguiente
*
* @return javax.swing.JButton
*/
private JButton getBtnsiguiente() {
if (btnsiguiente == null) {
btnsiguiente = new JButton();
btnsiguiente.setBounds(new Rectangle(388, 106, 174, 17));
btnsiguiente.setText("siguiente empleado");
btnsiguiente.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
txthoras.setText("");
txtsalario.setText("");
txtvalorhora.setText("");
}
});
}
return btnsiguiente;
}
/**
* This method initializes btnsalir
*
* @return javax.swing.JButton
*/
private JButton getBtnsalir() {
if (btnsalir == null) {
btnsalir = new JButton();
btnsalir.setBounds(new Rectangle(479, 133, 85, 20));
btnsalir.setText("salir");
btnsalir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
dispose();
}
});
}
return btnsalir;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SwingUtilities.invokeLater(new Runnable() {
public void run() {
seis thisClass = new seis();
thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
thisClass.setVisible(true);
}
});
}
/**
* This is the default constructor
*/
public seis() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(606, 200);
this.setContentPane(getJContentPane());
this.setTitle("JFrame");
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
texsalario = new JLabel();
texsalario.setBounds(new Rectangle(14, 107, 195, 17));
texsalario.setText("el salario del empleado es ");
texcantidaddehoras = new JLabel();
texcantidaddehoras.setBounds(new Rectangle(15, 42, 253, 15));
texcantidaddehoras.setText("digite la cantidad de horas que trabajo");
texvalorhora = new JLabel();
texvalorhora.setBounds(new Rectangle(15, 13, 255, 19));
texvalorhora.setText("digite el valor de una hora de trabajo normal");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(texvalorhora, null);
jContentPane.add(getTxtvalorhora(), null);
jContentPane.add(texcantidaddehoras, null);
jContentPane.add(getTxthoras(), null);
jContentPane.add(getBtnversalario(), null);
jContentPane.add(getTxtsalario(), null);
jContentPane.add(texsalario, null);
jContentPane.add(getBtnsiguiente(), null);
jContentPane.add(getBtnsalir(), null);
}
return jContentPane;
}
} // @jve:decl-index=0:visual-constraint="10,10"
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JButton;
public class seis extends JFrame {
int vh=0,ht=0,he=0,vho=0,s=0,chm=0,vhm=0;
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JLabel texvalorhora = null;
private JTextField txtvalorhora = null;
private JLabel texcantidaddehoras = null;
private JTextField txthoras = null;
private JButton btnversalario = null;
private JTextField txtsalario = null;
private JLabel texsalario = null;
private JButton btnsiguiente = null;
private JButton btnsalir = null;
/**
* This method initializes txtvalorhora
*
* @return javax.swing.JTextField
*/
private JTextField getTxtvalorhora() {
if (txtvalorhora == null) {
txtvalorhora = new JTextField();
txtvalorhora.setBounds(new Rectangle(273, 13, 141, 19));
}
return txtvalorhora;
}
/**
* This method initializes txthoras
*
* @return javax.swing.JTextField
*/
private JTextField getTxthoras() {
if (txthoras == null) {
txthoras = new JTextField();
txthoras.setBounds(new Rectangle(274, 40, 139, 20));
}
return txthoras;
}
/**
* This method initializes btnversalario
*
* @return javax.swing.JButton
*/
private JButton getBtnversalario() {
if (btnversalario == null) {
btnversalario = new JButton();
btnversalario.setBounds(new Rectangle(419, 42, 128, 19));
btnversalario.setText("ver salario");
btnversalario.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
vh=Integer.parseInt(txtvalorhora.getText());
ht=Integer.parseInt(txthoras.getText());
if (ht>40){
he=(ht-40);
if (he<=8){
vho=((he*vh)*2);
s=((40*vh)+(vho));
}
if (he>8){
vho=((8*vh)*2);
chm=(he-8);
vhm=((chm*vh)*3);
s=((40*vh)+(vho)+(vhm));
}
}
else {
s=(vh*ht);
}
txtsalario.setText(String.valueOf(s));
}
});
}
return btnversalario;
}
/**
* This method initializes txtsalario
*
* @return javax.swing.JTextField
*/
private JTextField getTxtsalario() {
if (txtsalario == null) {
txtsalario = new JTextField();
txtsalario.setBounds(new Rectangle(223, 105, 157, 19));
}
return txtsalario;
}
/**
* This method initializes btnsiguiente
*
* @return javax.swing.JButton
*/
private JButton getBtnsiguiente() {
if (btnsiguiente == null) {
btnsiguiente = new JButton();
btnsiguiente.setBounds(new Rectangle(388, 106, 174, 17));
btnsiguiente.setText("siguiente empleado");
btnsiguiente.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
txthoras.setText("");
txtsalario.setText("");
txtvalorhora.setText("");
}
});
}
return btnsiguiente;
}
/**
* This method initializes btnsalir
*
* @return javax.swing.JButton
*/
private JButton getBtnsalir() {
if (btnsalir == null) {
btnsalir = new JButton();
btnsalir.setBounds(new Rectangle(479, 133, 85, 20));
btnsalir.setText("salir");
btnsalir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
dispose();
}
});
}
return btnsalir;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SwingUtilities.invokeLater(new Runnable() {
public void run() {
seis thisClass = new seis();
thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
thisClass.setVisible(true);
}
});
}
/**
* This is the default constructor
*/
public seis() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(606, 200);
this.setContentPane(getJContentPane());
this.setTitle("JFrame");
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
texsalario = new JLabel();
texsalario.setBounds(new Rectangle(14, 107, 195, 17));
texsalario.setText("el salario del empleado es ");
texcantidaddehoras = new JLabel();
texcantidaddehoras.setBounds(new Rectangle(15, 42, 253, 15));
texcantidaddehoras.setText("digite la cantidad de horas que trabajo");
texvalorhora = new JLabel();
texvalorhora.setBounds(new Rectangle(15, 13, 255, 19));
texvalorhora.setText("digite el valor de una hora de trabajo normal");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(texvalorhora, null);
jContentPane.add(getTxtvalorhora(), null);
jContentPane.add(texcantidaddehoras, null);
jContentPane.add(getTxthoras(), null);
jContentPane.add(getBtnversalario(), null);
jContentPane.add(getTxtsalario(), null);
jContentPane.add(texsalario, null);
jContentPane.add(getBtnsiguiente(), null);
jContentPane.add(getBtnsalir(), null);
}
return jContentPane;
}
} // @jve:decl-index=0:visual-constraint="10,10"
Comentarios
Publicar un comentario