Capturas
Codigo
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* masterdavid.java
*
* Created on 15/12/2009, 12:06:35 AM
*/
package resistenciasmasterdavid;
/**
*
* @author Master David
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ComponentListener;
import java.awt.event.ComponentEvent;
import com.sun.awt.AWTUtilities;
import java.util.Locale;
public class masterdavid extends javax.swing.JFrame {
int fr1,fr2,fr3,fr4;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JButton jButton1;
private javax.swing.JButton boton0;
private javax.swing.JButton boton1;
private javax.swing.JButton boton2;
private javax.swing.JButton boton3;
private javax.swing.JButton boton4;
private javax.swing.JButton boton5;
private javax.swing.JButton boton6;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JComboBox jComboBox3;
private javax.swing.JComboBox jComboBox4;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
/** Creates new form masterdavid */
public masterdavid() {
jLabel6 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
boton0 = new javax.swing.JButton();
boton1 = new javax.swing.JButton();
boton2 = new javax.swing.JButton();
boton3 = new javax.swing.JButton();
boton4 = new javax.swing.JButton();
boton5 = new javax.swing.JButton();
boton6 = new javax.swing.JButton();
jComboBox1 = new javax.swing.JComboBox();
jComboBox2 = new javax.swing.JComboBox();
jComboBox3 = new javax.swing.JComboBox();
jComboBox4 = new javax.swing.JComboBox();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
//boton0
boton0 = new JButton("");
boton0.setBackground(Color.white);
boton0.setBounds(new Rectangle(200+52,112,32,110));
add(boton0);
boton0.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
boton1ActionPerformed(evt);
}
});
//boton1
boton1 = new JButton("");
boton1.setBackground(Color.white);
boton1.setBounds(new Rectangle(300-2,112,32,110));
add(boton1);
boton2 = new JButton("");
boton2.setBackground(Color.white);
boton2.setBounds(new Rectangle(252+96,112,32,110));
add(boton2);
boton3 = new JButton("");
boton3.setBackground(Color.white);
boton3.setBounds(new Rectangle(252+147,112,32,110));
add(boton3);
//Por colores
boton4 = new JButton("Por Colores");
boton4.setBounds(new Rectangle(50,50,120,20));
add(boton4);
boton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
boton4ActionPerformed(evt);
}
});
//Por valor
boton5 = new JButton("Por Valor");
boton5.setBounds(new Rectangle(50,90,120,20));
boton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
boton5ActionPerformed(evt);
}
});
//Calcular
boton6 = new JButton("Obtener Valor");
boton6.setBounds(new Rectangle(100,300,120,20));
add(boton6);
boton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
boton6ActionPerformed(evt);
}
});
//combobox1
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1","Negro", "Cafe", "Rojo", "Naranja","Amarillo","Verde","Azul","Violeta","Gris","Blanco" }));
jComboBox1.setBounds(200,60 , 70, 19);
add(jComboBox1);
jComboBox1.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
jComboBox1ItemStateChanged(evt);
}
});
//combobox2
jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"2","Negro", "Cafe", "Rojo", "Naranja","Amarillo","Verde","Azul","Violeta","Gris","Blanco" }));
jComboBox2.setBounds(200+80,60 , 70, 19);
add(jComboBox2);
jComboBox2.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
jComboBox2ItemStateChanged(evt);
}
});
//combobox3
jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"3","Negro", "Cafe", "Rojo", "Naranja","Amarillo","Verde","Azul","Violeta","Gris","Blanco" }));
jComboBox3.setBounds(200+160,60 , 70, 19);
add(jComboBox3);
jComboBox3.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
jComboBox3ItemStateChanged(evt);
}
});
//combobox4
jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "4", "Plateado", "Dorado" }));
jComboBox4.setBounds(200+240,60 , 70, 19);
add(jComboBox4);
jComboBox4.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
jComboBox4ItemStateChanged(evt);
}
});
// boton para cerrar
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resistenciasmasterdavid/cerrar.png"))); // NOI18N
jButton1.setBounds(580, 40, 30 , 20);
add(jButton1);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
//resultado
jLabel6.setText("El Valor de la Resistencia es: ");
jLabel6.setBounds(170, 250, 170, 20);
add(jLabel6);
jTextField1.setText("Valor");
jTextField1.setBounds(350, 250, 120, 20);
add(jTextField1);
//res max
jLabel3.setText(" Valor Maximo: ");
jLabel3.setBounds(250, 250+30, 170, 20);
add(jLabel3);
jTextField2.setText(" Valor Max");
jTextField2.setBounds(350, 280, 120, 20);
add(jTextField2);
//res min
jLabel4.setText(" Valor Minimo: ");
jLabel4.setBounds(250, 250+60, 170, 20);
add(jLabel4);
jTextField3.setText("Valor Min");
jTextField3.setBounds(350, 310, 120, 20);
add(jTextField3);
//tolerancia
jLabel5.setText("Tolerancia: ");
jLabel5.setBounds(270, 250+90, 170, 20);
add(jLabel5);
jTextField4.setText("Tolerancia");
jTextField4.setBounds(350, 340, 120, 20);
add(jTextField4);
setUndecorated(true);
setResizable(false);
AWTUtilities.setWindowOpaque(this, false);
// setLocation(400, 300);
setSize(660,440);
setLocationRelativeTo(null);
initComponents();
}
public void paintComponent(Graphics g) {
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Resistencias Master David");
setAlwaysOnTop(true);
setCursor(new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR));
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resistenciasmasterdavid/masterbackground.png"))); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if(0==0){
System.exit(0);
}
}
//evento boton 1
public void boton1ActionPerformed(java.awt.event.ActionEvent evt){
if(0==0) {
}
}
//evento boton 4 por color
public void boton4ActionPerformed(java.awt.event.ActionEvent evt){
if(0==0) {
jComboBox1.setSelectedItem(null);
jComboBox2.setSelectedItem(null);
jComboBox3.setSelectedItem(null);
jComboBox4.setSelectedItem(null);
jComboBox1.setEnabled(true);
jComboBox2.setEnabled(true);
jComboBox3.setEnabled(true);
jComboBox4.setEnabled(true);
boton0.setBackground(Color.white);
boton1.setBackground(Color.white);
boton2.setBackground(Color.white);
boton3.setBackground(Color.white);
boton4.setEnabled(false);
boton5.setEnabled(true);
}
}
//evento boton 5 por valor
public void boton5ActionPerformed(java.awt.event.ActionEvent evt){
if(0==0) {
jComboBox1.setSelectedItem(null);
jComboBox2.setSelectedItem(null);
jComboBox3.setSelectedItem(null);
jComboBox4.setSelectedItem(null);
boton0.setBackground(Color.white);
boton1.setBackground(Color.white);
boton2.setBackground(Color.white);
boton3.setBackground(Color.white);
jComboBox1.setEnabled(false);
jComboBox2.setEnabled(false);
jComboBox3.setEnabled(false);
jComboBox4.setEnabled(false);
boton5.setEnabled(false);
boton4.setEnabled(true);
}
}
// evento de jcombobox1
private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {
// int fr1=0;
int opcion = jComboBox1.getSelectedIndex();
if(opcion== 0){
boton0.setBackground(Color.white);
}
if(opcion== 1){
boton0.setBackground(Color.black);
fr1=00;
}
if(opcion== 2){
boton0.setBackground(new Color(152, 102, 0));
fr1=10;
}
if(opcion== 3){
boton0.setBackground(Color.red);
fr1=20;
}
if(opcion== 4){
boton0.setBackground(Color.ORANGE);
fr1=30;
}
if(opcion== 5){
boton0.setBackground(Color.yellow);
fr1=40;
}
if(opcion== 6){
boton0.setBackground(Color.GREEN);
fr1=50;
}
if(opcion== 7){
boton0.setBackground(Color.BLUE);
fr1=60;
}
if(opcion== 8){
boton0.setBackground(new Color(153,0,153));
fr1=70;
}
if(opcion== 9){
boton0.setBackground(Color.GRAY);
fr1=80;
}
if(opcion== 10){
boton0.setBackground(Color.white);
fr1=90;
}
}
private void jComboBox2ItemStateChanged(java.awt.event.ItemEvent evt) {
// int fr2=0;
int opcion2 = jComboBox2.getSelectedIndex();
if(opcion2== 0){
boton1.setBackground(Color.white);
}
if(opcion2== 1){
boton1.setBackground(Color.black);
fr2=0;
}
if(opcion2== 2){
boton1.setBackground(new Color(152, 102, 0));
fr2=1;
}
if(opcion2== 3){
boton1.setBackground(Color.red);
fr2=2;
}
if(opcion2== 4){
boton1.setBackground(Color.ORANGE);
fr2=3;
}
if(opcion2== 5){
boton1.setBackground(Color.yellow);
fr2=4;
}
if(opcion2== 6){
boton1.setBackground(Color.GREEN);
fr2=5;
}
if(opcion2== 7){
boton1.setBackground(Color.BLUE);
fr2=6;
}
if(opcion2== 8){
boton1.setBackground(new Color(153,0,153));
fr2=7;
}
if(opcion2== 9){
boton1.setBackground(Color.GRAY);
fr2=8;
}
if(opcion2== 10){
boton1.setBackground(Color.white);
fr2=9;
} // TODO add your handling code here:
}
private void jComboBox3ItemStateChanged(java.awt.event.ItemEvent evt) {
// int fr3=0;
int opcion3 = jComboBox3.getSelectedIndex();
if(opcion3== 0){
boton2.setBackground(Color.white);
}
if(opcion3== 1){
boton2.setBackground(Color.black);
fr3=1;
}
if(opcion3== 2){
boton2.setBackground(new Color(152, 102, 0));
fr3=10;
}
if(opcion3== 3){
boton2.setBackground(Color.red);
fr3=100;
}
if(opcion3== 4){
boton2.setBackground(Color.ORANGE);
fr3=1000;
}
if(opcion3== 5){
boton2.setBackground(Color.yellow);
fr3=10000;
}
if(opcion3== 6){
boton2.setBackground(Color.GREEN);
fr3=100000;
}
if(opcion3== 7){
boton2.setBackground(Color.BLUE);
fr3=1000000;
}
if(opcion3== 8){
boton2.setBackground(new Color(153,0,153));
fr3=10000000;
}
if(opcion3== 9){
boton2.setBackground(Color.GRAY);
fr3=100000000;
}
if(opcion3== 10){
boton2.setBackground(Color.white);
fr3=1000000000;
} // TODO add your handling code here:
}
private void jComboBox4ItemStateChanged(java.awt.event.ItemEvent evt) {
//int fr4=0;
int opcion4 = jComboBox4.getSelectedIndex();
if(opcion4== 0){// TODO add your handling code here:
boton3.setBackground(Color.white);
}
if(opcion4== 1){// TODO add your handling code here:
boton3.setBackground(new Color(204,204,204));
fr4=10;
}
if(opcion4== 2){
boton3.setBackground(new Color(204,204,0));
fr4=5;
}
}
public void boton6ActionPerformed(java.awt.event.ActionEvent evt){
int resultadores;
int mx;
String max;
int mn;
String min;
int tol=fr4;
String tole;
String produc;
if(0==0) {
resultadores=(fr1+fr2)*fr3;
produc=resultadores+" ohms";
jTextField1.setText(produc);
tole=tol+" %";
jTextField4.setText(tole);
mx=resultadores+((resultadores*fr4)/100);
max=mx+" ohms";
jTextField2.setText(max);
mn=resultadores-((resultadores*fr4)/100);
min=mn+" ohms";
jTextField3.setText(min);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new masterdavid().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel2;
// End of variables declaration
private Image imagen = null;
}
DESCARGAR ARCHIVO