You are on page 1of 56

PONTIFICIA UNIVERSIDAD CATLICA DEL ECUADOR

SEDE IBARRA

Nombre: Marcos Ruales.


Fecha: 19/04/17

ESCUELA DE INGENIERA

INTALACION DE VB Decompiler Lite.


EJEMPLOS:

VERSION 5.00

Begin VB.Form Form1

Caption = "Calculadora by marco"

ScaleMode = 1

AutoRedraw = False

FontTransparent = True

BorderStyle = 4 'Fixed ToolWindow

'Icon = n/a

LinkTopic = "Form1"

MaxButton = 0 'False

MinButton = 0 'False

ClientLeft = 45

ClientTop = 285

ClientWidth = 3975

ClientHeight = 3195

ShowInTaskbar = 0 'False

StartUpPosition = 3 'Windows Default

Begin CommandButton salir


Caption = "Salir"

Left = 2160 Top

= 2520

Width = 1695

Height = 495

TabIndex = 11

End

Begin CommandButton new

Caption = "Nuevo calculo"

Left = 120

Top = 2520

Width = 1695

Height = 495

TabIndex = 10

End

Begin CommandButton dividir

Caption = "/"
Left = 3240 Top

= 1800

Width = 615

Height = 495

TabIndex = 9

BeginProperty Font

Name = "MS Sans Serif"

Size = 13,5

Charset = 0

Weight = 400

Underline = 0 'False

Italic = 0 'False
Strikethrough = 0 'False

EndProperty

End

Begin CommandButton por

Caption = "x"
Left = 2160 Top

= 1800

Width = 615

Height = 495

TabIndex = 8

BeginProperty Font

Name = "MS Sans Serif"

Size = 13,5

Charset = 0

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

End

Begin CommandButton restar

Caption = "-"

Left = 1200

Top = 1800

Width = 615

Height = 495

TabIndex = 7

BeginProperty Font

Name = "MS Sans Serif"


Size = 13,5

Charset = 0

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

End

Begin CommandButton sumar

Caption = "+"

Left = 120

Top = 1800

Width = 615

Height = 495

TabIndex = 6

BeginProperty Font

Name = "MS Sans Serif"

Size = 13,5

Charset = 0

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

End

Begin TextBox res

Left = 1680

Top = 1080

Width = 1215
Height = 405

TabIndex = 5

BeginProperty Font

Name = "MS Sans Serif"

Size = 9,75

Charset = 0

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

End

Begin TextBox can2

Left = 1680

Top = 600

Width = 1215

Height = 405

TabIndex = 4

BeginProperty Font

Name = "MS Sans Serif"

Size = 9,75

Charset = 0

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

End

Begin TextBox can1


Left = 1680

Top = 120

Width = 1215

Height = 405

TabIndex = 3

BeginProperty Font

Name = "MS Sans Serif"

Size = 9,75

Charset = 0

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

End

Begin Label Label3

Caption = "Resultado"

Left = 240

Top = 1200

Width = 1095

Height = 255

TabIndex = 2

BeginProperty Font

Name = "MS Sans Serif"

Size = 9,75

Charset = 0

Weight = 700

Underline = 0 'False

Italic = 0 'False
Strikethrough = 0 'False

EndProperty

End

Begin Label Label2

Caption = "Cantidad2"
Left = 240 Top

= 720

Width = 1095

Height = 615

TabIndex = 1

BeginProperty Font

Name = "MS Sans Serif"

Size = 9,75

Charset = 0

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

End

Begin Label Label1

Caption = "Cantidad1"
Left = 240 Top

= 240

Width = 1215

Height = 495

TabIndex = 0

BeginProperty Font

Name = "MS Sans Serif"


Size = 9,75

Charset = 0

Weight = 700

Underline = 0 'False Italic = 0 'False

Strikethrough = 0 'False

EndProperty

End

End

Attribute VB_Name = "Form1"

EJERCICIO 2

Public Sub .ctor() '402050

Code: TinyFormat

Start: 402051

Size: 23

loc_402051: ldarg.0 loc_402052:

ldnull loc_402053: stfld


components loc_402058: ldarg.0

loc_402059: call .ctor loc_40205E:

nop

loc_40205F: nop loc_402060: ldarg.0

loc_402061: call InitializeComponent

loc_402066: nop loc_402067: ret

End Sub

JD-GUI Ejercicio 3

package investigacionoperaciones;

import java.awt.Color; import java.awt.Container;


import java.awt.EventQueue; import java.awt.Font;
import java.awt.event.ActionEvent; import
java.awt.event.ActionListener; import
java.util.ArrayList; import java.util.logging.Level;
import java.util.logging.Logger; import
javax.swing.BorderFactory; import
javax.swing.DefaultListModel; import
javax.swing.GroupLayout; import
javax.swing.GroupLayout.Alignment; import
javax.swing.GroupLayout.ParallelGroup; import
javax.swing.GroupLayout.SequentialGroup; import
javax.swing.JButton; import javax.swing.JFrame;
import javax.swing.JLabel; import
javax.swing.JOptionPane; import javax.swing.JPanel;
import javax.swing.JScrollPane; import
javax.swing.JTable; import javax.swing.JTextArea;
import javax.swing.JTextField;

import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.UIManager; import
javax.swing.UIManager.LookAndFeelInfo; import
javax.swing.UnsupportedLookAndFeelException; import
javax.swing.border.MatteBorder; import
javax.swing.table.DefaultTableModel; import
javax.swing.table.TableModel;

public class Ejecutar extends


JFrame
{

TableModel tableModelDatos;

TableModel tableModelDatos2;

TableModel tableModelDatos3;

public Ejecutar()

initComponents();

private void initComponents()

this.jScrollPane1 = new JScrollPane(); this.Tabla


= new JTable(); this.jLabel3 = new JLabel();
this.jPanel1 = new JPanel(); this.jLabel2 = new
JLabel(); this.txtNumFilas = new JTextField();
this.jLabel1 = new JLabel(); this.txtNumColumna =
new JTextField(); this.Btn_Generar = new
JButton(); this.jPanel2 = new JPanel();
this.Btn_Equilibrar = new JButton();
this.Btn_EsquinaNoroeste = new JButton();
this.BtnCostoMinimo = new JButton();
this.jScrollPane2 = new JScrollPane();
this.TablaDatos2 = new JTable(); this.jScrollPane3
= new JScrollPane(); this.Txta_Impresion = new
JTextArea(); this.jLabel4 = new JLabel();
this.jLabel5 = new JLabel(); this.jScrollPane4 =
new JScrollPane(); this.TablaDatos3 = new
JTable();

setDefaultCloseOperation(3);

this.Tabla.setModel(new DefaultTableModel(new Object[0][], new String[0]));

this.jScrollPane1.setViewportView(this.Tabla);

this.jLabel3.setFont(new Font("Times New Roman", 1, 36)); this.jLabel3.setForeground(new


Color(255, 204, 0)); this.jLabel3.setText("INVESTIGACION DE OPERACIONES");

this.jPanel1.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));

this.jLabel2.setFont(new Font("Times New Roman", 1, 14)); this.jLabel2.setText("Ingrese el


numero de ofertas :");

this.txtNumFilas.setFont(new Font("Times New Roman", 1, 12));

this.jLabel1.setFont(new Font("Times New Roman", 1, 14)); this.jLabel1.setText("Ingrese el


numero de demandas :");

this.txtNumColumna.setFont(new Font("Times New Roman", 1, 12));

this.Btn_Generar.setFont(new Font("Times New Roman", 1, 14));


this.Btn_Generar.setText("Crear");

this.Btn_Generar.addActionListener(new ActionListener()

{
public void actionPerformed(ActionEvent evt)

Ejecutar.this.Btn_GenerarActionPerformed(evt);

});

GroupLayout jPanel1Layout = new GroupLayout(this.jPanel1);


this.jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout
.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()

.addComponent(this.jLabel2)

.addGap(32, 32, 32))

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(this.jLabel1)

.addGap(14, 14, 14)))

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)

.addComponent(this.txtNumColumna, -1, 86, 32767)

.addComponent(this.txtNumFilas))

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)

.addComponent(this.Btn_Generar, -2, 88, -2)

.addContainerGap(18, 32767)));

jPanel1Layout.setVerticalGroup(jPanel1Layout
.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(22, 22, 22)


.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)

.addComponent(this.jLabel2)

.addComponent(this.txtNumFilas, -2, -1, -2))

.addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)

.addComponent(this.jLabel1)

.addComponent(this.txtNumColumna, -2, -1, -2)))

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(20, 20, 20)

.addComponent(this.Btn_Generar, -2, 58, -2)))

.addContainerGap(29, 32767)));

this.jPanel2.setBorder(new MatteBorder(null));

this.Btn_Equilibrar.setFont(new Font("Times New Roman", 1, 14));


this.Btn_Equilibrar.setForeground(new Color(204, 0, 0));
this.Btn_Equilibrar.setText("Equilibrar");

this.Btn_Equilibrar.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt) {


Ejecutar.this.Btn_EquilibrarActionPerformed(evt);

} }); this.Btn_EsquinaNoroeste.setFont(new Font("Times New Roman", 1,


14)); this.Btn_EsquinaNoroeste.setForeground(new Color(204, 0, 0));
this.Btn_EsquinaNoroeste.setText("Esquina Noroeste");
this.Btn_EsquinaNoroeste.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

Ejecutar.this.Btn_EsquinaNoroesteActionPerformed(evt);

} });

this.BtnCostoMinimo.setFont(new Font("Times New Roman", 1, 14));


this.BtnCostoMinimo.setText("Costo Minimo");
this.BtnCostoMinimo.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

Ejecutar.this.BtnCostoMinimoActionPerformed(evt);

});

GroupLayout jPanel2Layout = new GroupLayout(this.jPanel2);


this.jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout
.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addContainerGap()

.addComponent(this.Btn_Equilibrar)

.addGap(18, 18, 18)

.addComponent(this.Btn_EsquinaNoroeste)

.addGap(32, 32, 32)

.addComponent(this.BtnCostoMinimo)

.addContainerGap(41, 32767)));

jPanel2Layout.setVerticalGroup(jPanel2Layout
.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addGap(23, 23, 23)

.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)

.addComponent(this.BtnCostoMinimo, -1, 52, 32767)

.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)

.addComponent(this.Btn_EsquinaNoroeste, -1, -1, 32767)

.addComponent(this.Btn_Equilibrar, -1, 52, 32767)))

.addContainerGap(36, 32767)));

this.TablaDatos2.setModel(new DefaultTableModel(new Object[0][], new String[0]));


this.jScrollPane2.setViewportView(this.TablaDatos2);

this.Txta_Impresion.setColumns(20); this.Txta_Impresion.setRows(5);

this.jScrollPane3.setViewportView(this.Txta_Impresion);

this.jLabel4.setFont(new Font("Times New Roman", 1, 36));


this.jLabel4.setForeground(new Color(102, 255, 51)); this.jLabel4.setText("Tabla Datos ");

this.jLabel5.setFont(new Font("Times New Roman", 1, 36)); this.jLabel5.setText("Tabla


Resultados");

this.TablaDatos3.setModel(new DefaultTableModel(new Object[0][], new String[0]));

this.jScrollPane4.setViewportView(this.TablaDatos3);

GroupLayout layout = new GroupLayout(getContentPane());


getContentPane().setLayout(layout); layout.setHorizontalGroup(layout

.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(133, 133, 133)

.addComponent(this.jLabel4)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, -1, 32767)

.addComponent(this.jLabel5)

.addGap(114, 114, 114))

.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

.addContainerGap(-1, 32767)

.addComponent(this.jLabel3)

.addGap(138, 138, 138))

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()

.addComponent(this.jPanel1, -2, -1, -2)

.addGap(18, 18, 18)

.addComponent(this.jPanel2, -2, -1, -2))

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)

.addComponent(this.jScrollPane2, -2, 430, -2)

.addComponent(this.jScrollPane4, -2, 430, -2))

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)

.addComponent(this.jScrollPane3, -2, 430, -2)

.addComponent(this.jScrollPane1, -2, 430, -2))))

.addContainerGap(-1, 32767)));

layout.setVerticalGroup(layout

.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(this.jLabel3)

.addGap(9, 9, 9)

.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)

.addComponent(this.jPanel2, -2, -1, -2)

.addComponent(this.jPanel1, -2, -1, -2))

.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, -1, 32767)

.addComponent(this.jLabel5)

.addGap(10, 10, 10))

.addGroup(layout.createSequentialGroup()

.addGap(18, 18, 18)


.addComponent(this.jLabel4)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 49, 32767)))

.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)

.addComponent(this.jScrollPane2, GroupLayout.Alignment.TRAILING, -2, 180, -2)

.addComponent(this.jScrollPane1, GroupLayout.Alignment.TRAILING, -2, 180, -2))

.addGap(30, 30, 30)

.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)

.addComponent(this.jScrollPane3, -2, 165, -2)

.addComponent(this.jScrollPane4, -2, 165, -2))

.addContainerGap()));

pack();

DefaultListModel model = new DefaultListModel();

DefaultListModel modelo2 = new DefaultListModel();


DefaultListModel modelo3 = new DefaultListModel(); int filas;

int columnas; int


sumaOferta = 0; int
sumaDemanda = 0;

ArrayList<Integer> vectorOferta;

ArrayList<Integer> vectorDemanda;

ArrayList<Integer> Demanda;

ArrayList<Integer> oferta;

Object[] auxDemanda;

Object[] auxOferta;

DefaultTableModel mitableModel;

DefaultTableModel mitableModel2;

DefaultTableModel mitableModel3;
Object[][] matriz; boolean temp =
false; int temfilas; int temcolumnas;
int auxi; int auxj; int sumaMinima;
boolean rec;
private void Btn_GenerarActionPerformed(ActionEvent evt)

{ this.filas = (Integer.parseInt(this.txtNumFilas.getText()) + 2); this.columnas =


(Integer.parseInt(this.txtNumColumna.getText()) + 2); this.temfilas = this.filas;
this.temcolumnas = this.columnas; this.sumaOferta = 0; this.sumaDemanda =
0;

this.matriz = new Object[this.filas][this.columnas];

this.tableModelDatos = this.Tabla.getModel();

this.mitableModel = ((DefaultTableModel)this.Tabla.getModel()); this.model.clear();

this.mitableModel.setNumRows(this.filas);
this.mitableModel.setColumnCount(this.columnas); int
cont = 1; this.vectorOferta = new ArrayList();
this.vectorDemanda = new ArrayList(); this.oferta = new
ArrayList(); this.Demanda = new ArrayList();

this.auxDemanda = new Object[this.columnas - 1]; this.auxOferta = new


Object[this.filas - 1]; this.tableModelDatos2 =
this.TablaDatos2.getModel();

this.mitableModel2 = ((DefaultTableModel)this.TablaDatos2.getModel());
this.modelo2.clear();

this.mitableModel2.setNumRows(this.filas);
this.mitableModel2.setColumnCount(this.columnas);
this.tableModelDatos3 = this.TablaDatos3.getModel();

this.mitableModel3 = ((DefaultTableModel)this.TablaDatos3.getModel());
this.modelo3.clear();

this.mitableModel3.setNumRows(this.filas);
this.mitableModel3.setColumnCount(this.columnas); for (int i =
0; i < this.filas; i++)

for (int j = 0; j < this.columnas - 1; j++) { if (i == 0) {


this.tableModelDatos.setValueAt("Pers " + (j + 1), i, j + 1);
this.tableModelDatos2.setValueAt("Pers " + (j + 1), i, j + 1);
this.tableModelDatos3.setValueAt("Pers " + (j + 1), i, j + 1); this.matriz[i][(j +
1)] = ("Pers " + (j + 1)); if (j == this.columnas - 2)

{
this.tableModelDatos.setValueAt("OFERTA ", i, j + 1);
this.tableModelDatos2.setValueAt("OFERTA ", i, j + 1);
this.tableModelDatos3.setValueAt("OFERTA ", i, j + 1); this.matriz[i][(j + 1)] = "OFERTA ";

} }

else if (j == 0)

{ this.tableModelDatos.setValueAt("Suc " + i, i, j);


this.tableModelDatos2.setValueAt("Suc " + i, i, j);
this.tableModelDatos3.setValueAt("Suc " + i, i, j); this.matriz[i][j]
= ("Suc " + i); if (i == this.filas - 1)

this.tableModelDatos.setValueAt("DEMANDA ", i, j);


this.tableModelDatos2.setValueAt("DEMANDA ", i, j);
this.tableModelDatos3.setValueAt("DEMANDA ", i, j); this.matriz[i][j] = "DEMANDA ";

} }

else if (i <= this.filas - 2)

int num = (int)(Math.random() * 11.0D + 5.0D);

this.tableModelDatos.setValueAt(Integer.valueOf(num), i, j);
this.tableModelDatos2.setValueAt(Integer.valueOf(num), i, j);
this.tableModelDatos3.setValueAt(Integer.valueOf(num), i, j); this.matriz[i][j] =
Integer.valueOf(num);

else if (i == this.filas - 1)

int num3 = (int)(Math.random() * 18.0D + 100.0D);


this.tableModelDatos.setValueAt(Integer.valueOf(num3), i, j);
this.tableModelDatos2.setValueAt(Integer.valueOf(num3), i, j);
this.tableModelDatos3.setValueAt(Integer.valueOf(num3), i, j);

this.vectorDemanda.add(Integer.valueOf(num3));
this.Demanda.add(Integer.valueOf(num3)); this.auxDemanda[j] =
Integer.valueOf(num3); this.sumaDemanda += num3;

this.matriz[i][j] = Integer.valueOf(num3);

} }
int num3 = (int)(Math.random() * 31.0D + 120.0D); if (i <
this.filas - 2)

this.tableModelDatos.setValueAt(Integer.valueOf(num3), cont, this.columnas -

1);

this.tableModelDatos2.setValueAt(Integer.valueOf(num3), cont, this.columnas -

1);

this.tableModelDatos3.setValueAt(Integer.valueOf(num3), cont, this.columnas -

1);

this.matriz[cont][(this.columnas - 1)] = Integer.valueOf(num3);

if (cont <= this.filas - 2)

{ this.vectorOferta.add(Integer.valueOf(num3));
this.oferta.add(Integer.valueOf(num3)); this.sumaOferta
+= num3;

this.auxOferta[cont] = Integer.valueOf(num3);

} cont++; }
this.Tabla.setVisible(false);
this.TablaDatos3.setVisible(false);
this.temp = true;

private void Btn_EquilibrarActionPerformed(ActionEvent evt)

if (this.temp)
{

if (this.sumaDemanda > this.sumaOferta)

Equilibrio(true); this.rec = true;

} else
{

Equilibrio(false); this.rec = false;


}
this.temp = false;
}

private void Btn_EsquinaNoroesteActionPerformed(ActionEvent evt)

{ try
{

String cadena = ""; int


resultado = 0;
this.model.clear();

int calculOferta = 0;int calculoDemanda = 0; if


(this.sumaOferta == this.sumaDemanda)

{ for (int i = 1; i < this.filas - 1; i++) { for (int j = 1;


j < this.columnas - 1; j++)

if (((Integer)this.vectorOferta.get(i - 1)).intValue() >=

((Integer)this.vectorDemanda.get(j - 1)).intValue())

if (((Integer)this.vectorDemanda.get(j - 1)).intValue() > 0)

cadena = cadena + "(" + this.matriz[i][j] + "*" + this.vectorDemanda.get(j - 1) + ")+";

resultado += Integer.parseInt(this.matriz[i][j] + "") *

((Integer)this.vectorDemanda.get(j - 1)).intValue();

this.tableModelDatos.setValueAt(this.vectorDemanda.get(j - 1), i, j); calculOferta


= ((Integer)this.vectorOferta.get(i - 1)).intValue() -

((Integer)this.vectorDemanda.get(j - 1)).intValue();

calculoDemanda = ((Integer)this.vectorDemanda.get(j - 1)).intValue()

- ((Integer)this.vectorDemanda.get(j - 1)).intValue();

this.vectorOferta.set(i - 1, Integer.valueOf(calculOferta));
this.vectorDemanda.set(j - 1, Integer.valueOf(calculoDemanda));

} else
{
this.tableModelDatos.setValueAt("", i, j);
} }

else if (((Integer)this.vectorOferta.get(i - 1)).intValue() > 0)

cadena = cadena + "(" + this.matriz[i][j] + "*" + this.vectorOferta.get(j - 1) + ")+";

resultado += Integer.parseInt(this.matriz[i][j] + "") *

((Integer)this.vectorOferta.get(j - 1)).intValue();

this.tableModelDatos.setValueAt(this.vectorOferta.get(i - 1), i, j); calculOferta =


((Integer)this.vectorOferta.get(i - 1)).intValue() -

((Integer)this.vectorOferta.get(i - 1)).intValue();

calculoDemanda = ((Integer)this.vectorDemanda.get(j - 1)).intValue() -

((Integer)this.vectorOferta.get(i - 1)).intValue();

this.vectorOferta.set(i - 1, Integer.valueOf(calculOferta)); this.vectorDemanda.set(j


- 1, Integer.valueOf(calculoDemanda));

} else
{
this.tableModelDatos.setValueAt("", i, j);

} if ((i + 1 == this.filas - 1) && (j + 1 == this.columnas - 1)) {


this.tableModelDatos.setValueAt("Total " + this.sumaOferta, i + 1, j + 1);
}

} }

this.Txta_Impresion.setText(cadena + " = " + resultado);

} else
{

JOptionPane.showMessageDialog(this, "La oferta no cumple con la demanda"); } }


catch (Exception e)

JOptionPane.showMessageDialog(this, e.getMessage());

int confila = 1;

ArrayList<Object> datosTem; private


JButton BtnCostoMinimo; private JButton
Btn_Equilibrar; private JButton
Btn_EsquinaNoroeste; private JButton
Btn_Generar; private JTable Tabla; private
JTable TablaDatos2; private JTable
TablaDatos3; private JTextArea
Txta_Impresion; private JLabel jLabel1;
private JLabel jLabel2; private JLabel
jLabel3; private JLabel jLabel4; private
JLabel jLabel5; private JPanel jPanel1;
private JPanel jPanel2; private JScrollPane
jScrollPane1; private JScrollPane
jScrollPane2; private JScrollPane
jScrollPane3; private JScrollPane
jScrollPane4; private JTextField
txtNumColumna; private JTextField
txtNumFilas;

private void BtnCostoMinimoActionPerformed(ActionEvent evt)

{ try {
this.TablaDatos3.setVisible(true);
this.datosTem = new ArrayList();

int suma = 0; int b =


sumaDatos(); while (suma
!= b)

int a = BuscarMenor();

if (((Integer)this.Demanda.get(this.auxj - 1)).intValue() >

((Integer)this.oferta.get(this.auxi - 1)).intValue())

this.TablaDatos3.setValueAt(this.oferta.get(this.auxi - 1), this.auxi, this.auxj);

this.datosTem.add(this.oferta.get(this.auxi - 1)); suma +=


((Integer)this.oferta.get(this.auxi - 1)).intValue(); int rec1 =
((Integer)this.Demanda.get(this.auxj - 1)).intValue() -

((Integer)this.oferta.get(this.auxi - 1)).intValue(); this.oferta.set(this.auxi - 1,


Integer.valueOf(0)); this.Demanda.set(this.auxj - 1, Integer.valueOf(rec1));

DatosX2(this.auxi, this.auxj);

} else
{
this.TablaDatos3.setValueAt(this.Demanda.get(this.auxj - 1), this.auxi, this.auxj);

this.datosTem.add(this.Demanda.get(this.auxj - 1)); suma +=


((Integer)this.Demanda.get(this.auxj - 1)).intValue(); int rec1 =
((Integer)this.oferta.get(this.auxi - 1)).intValue() -

((Integer)this.Demanda.get(this.auxj - 1)).intValue(); this.Demanda.set(this.auxj - 1,


Integer.valueOf(0)); this.oferta.set(this.auxi - 1, Integer.valueOf(rec1));

DatosX(this.auxi, this.auxj);

} }

this.Txta_Impresion.setText("Costo minimo = " + suma);

catch (Exception e)

JOptionPane.showMessageDialog(null, e.getCause());

public int BuscarMenor()

{ this.auxi = 0; this.auxj =
0; int aux = ValoxTemp();

for (int i = 1; i < this.filas - 1; i++) { for (int j = 1; j <


this.columnas - 1; j++) {

if ((!(this.tableModelDatos3.getValueAt(i, j) + "").equals("x")) && (aux >


Integer.parseInt(this.tableModelDatos3.getValueAt(i, j) + "")))

aux = Integer.parseInt(this.tableModelDatos3.getValueAt(i, j) + ""); this.auxi =


i; this.auxj = j;

} } return
aux;

public void Equilibrio(boolean aux)


{
this.Tabla.setVisible(true); if (aux)
{

this.auxDemanda[0] = "DEMANDA"; int sum =


this.sumaDemanda - this.sumaOferta; for (int i = 0; i <
this.filas; i++) { for (int j = 0; j < this.columnas; j++) {
if (i == this.filas - 1)

this.tableModelDatos.setValueAt(Integer.valueOf(0), i, j);
this.tableModelDatos3.setValueAt(Integer.valueOf(0), i, j); if (j == 0) {
this.tableModelDatos.setValueAt("Suc " + i, i, j); this.tableModelDatos3.setValueAt("Suc "
+ i, i, j);

if (j == this.columnas - 1)

{ this.tableModelDatos.setValueAt(Integer.valueOf(sum), i, j);
this.tableModelDatos3.setValueAt(Integer.valueOf(sum), i, j);
this.vectorOferta.add(Integer.valueOf(sum));
this.oferta.add(Integer.valueOf(sum));

} }
this.mitableModel.addRow(this.auxDemanda);
this.mitableModel3.addRow(this.auxDemanda);
this.filas += 1; this.sumaOferta += sum;

} else { int sum = this.sumaOferta -


this.sumaDemanda; for (int i = 0; i < this.filas; i++) {
for (int j = 0; j < this.columnas; j++) { if (j ==
this.columnas - 1)

this.tableModelDatos.setValueAt(Integer.valueOf(0), i, j);
this.tableModelDatos3.setValueAt(Integer.valueOf(0), i, j); if (i == 0)
{ this.tableModelDatos.setValueAt("Pers " + j, i, j);
this.tableModelDatos3.setValueAt("Pers " + j, i, j);

if (i == this.filas - 1)

{ this.tableModelDatos.setValueAt(Integer.valueOf(sum), i, j);
this.tableModelDatos3.setValueAt(Integer.valueOf(sum), i, j);
this.vectorDemanda.add(Integer.valueOf(sum));
this.Demanda.add(Integer.valueOf(sum));

} }

this.auxOferta[0] = "OFERTA";

this.mitableModel.addColumn("Z", this.auxOferta);
this.mitableModel3.addColumn("Z", this.auxOferta);
this.columnas += 1; this.sumaDemanda += sum;

} sumaDatos();

public int ValoxTemp()

{ int aux = 0; boolean


rec = true;

for (int i = 1; i < this.filas - 1; i++) { for (int j = 1; j <


this.columnas - 1; j++) { if ((rec) &&

(!(this.tableModelDatos3.getValueAt(i, j) + "").equals("x")))

aux = Integer.parseInt(this.tableModelDatos3.getValueAt(i, j) + ""); rec = false;

} } return
aux;

public int sumaDatos()

{ int suma = 0; for (int i = 0; i < this.Demanda.size(); i++) {


suma += ((Integer)this.Demanda.get(i)).intValue();

} return suma;

public void DatosX(int i, int j)


{

for (int h = 1; h < this.filas - 1; h++)

{
Object tem1 = Verificador(this.TablaDatos3.getValueAt(h, j)); if
(!tem1.equals("a")) {

this.TablaDatos3.setValueAt(this.TablaDatos3.getValueAt(h, j), i, j);

} else {
this.TablaDatos3.setValueAt("x", h, j);

public void DatosX2(int i, int j)


{

for (int h = 1; h < this.columnas - 1; h++)

Object tem2 = Verificador(this.TablaDatos3.getValueAt(i, h)); if


(!tem2.equals("a")) {

this.TablaDatos3.setValueAt(this.TablaDatos3.getValueAt(i, h), i, h);

} else {
this.TablaDatos3.setValueAt("x", i, h);

public Object Verificador(Object dato)

Object rec = "a";

for (int i = 0; i < this.datosTem.size(); i++) { if


(this.datosTem.get(i).equals(dato))

{ rec = this.datosTem.get(i); i
= this.datosTem.size();

} } return
rec;

public static void main(String[] args)


{ try { for (UIManager.LookAndFeelInfo info : )
{ if ("Nimbus".equals(info.getName()))

UIManager.setLookAndFeel(info.getClassName()); break;

} }

catch (ClassNotFoundException ex)

Logger.getLogger(Ejecutar.class.getName()).log(Level.SEVERE, null, ex);

catch (InstantiationException ex)

Logger.getLogger(Ejecutar.class.getName()).log(Level.SEVERE, null, ex);

catch (IllegalAccessException ex)

Logger.getLogger(Ejecutar.class.getName()).log(Level.SEVERE, null, ex);

catch (UnsupportedLookAndFeelException ex)

Logger.getLogger(Ejecutar.class.getName()).log(Level.SEVERE, null, ex);

EventQueue.invokeLater(new Runnable()

public void run()


{

new Ejecutar().setVisible(true);

});

}
}

Ejercicio 4

import java.awt.Color; import


java.awt.Container; import
java.awt.Dimension; import
java.awt.EventQueue; import
java.awt.Font; import
java.awt.event.ActionEvent; import
java.awt.event.ActionListener; import
java.awt.event.MouseAdapter; import
java.awt.event.MouseEvent; import
java.util.Iterator; import java.util.Stack;
import java.util.logging.Level; import
java.util.logging.Logger; import
javax.swing.BorderFactory; import
javax.swing.GroupLayout; import
javax.swing.GroupLayout.Alignment;
import
javax.swing.GroupLayout.ParallelGroup;
import
javax.swing.GroupLayout.SequentialGroup;
import javax.swing.ImageIcon; import
javax.swing.JButton; import
javax.swing.JFrame; import
javax.swing.JLabel; import
javax.swing.JOptionPane; import
javax.swing.JPanel;

import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.UIManager; import
javax.swing.UIManager.LookAndFeelInfo; import
javax.swing.UnsupportedLookAndFeelException;

public class PlayGame extends JFrame {


private VFondo fondo; private boolean caraUp
= false; private ImageIcon im1; private
ImageIcon im2; private JButton[] pbtn = new
JButton[2]; private boolean primerc = false;
private int puntaje = 0;

public PlayGame() {

initComponents();

this.fondo = new VFondo(getWidth(), getHeight());


add(this.fondo, "Center"); setCards();

PilaJuego objLogica = new PilaJuego();


private JButton btnC1; private JButton
btnC10; private JButton btnC11; private
JButton btnC12; private JButton btnC13;
private JButton btnC14; private JButton
btnC15; private JButton btnC16; private
JButton btnC2; private JButton btnC3;
private JButton btnC4; private JButton btnC5;
private JButton btnC6; private JButton btnC7;
private JButton btnC8; private JButton btnC9;
private JButton btnReiniciar; private JLabel
jLabel1; private JPanel jPanel1;

private void setCards()


{

Stack pila = this.objLogica.getCardNumbers();


Iterator auxInte = pila.iterator(); int[] numbers = new
int[16]; int aux = 0; while (auxInte.hasNext())

{
Object tem = auxInte.next(); int num =
Integer.parseInt(tem.toString()); numbers[aux] =
num; aux++; }

this.btnC1.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[0]


+ ".png")));

this.btnC2.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[1]


+ ".png")));

this.btnC3.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[2]


+ ".png")));

this.btnC4.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[3]


+ ".png")));

this.btnC5.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[4]


+ ".png")));

this.btnC6.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[5]


+ ".png")));

this.btnC7.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[6]


+ ".png")));

this.btnC8.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[7]


+ ".png")));

this.btnC9.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[8]


+ ".png")));

this.btnC10.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" +
numbers[9] + ".png")));

this.btnC11.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" +
numbers[10] + ".png")));

this.btnC12.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" +
numbers[11] + ".png")));

this.btnC13.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" +
numbers[12] + ".png")));

this.btnC14.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" +
numbers[13] + ".png")));

this.btnC15.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" +
numbers[14] + ".png")));

this.btnC16.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" +
numbers[15] + ".png")));
}

private void btnEnabled(JButton btn)

if (!this.caraUp)

btn.setEnabled(false);

this.im1 = ((ImageIcon)btn.getDisabledIcon());
this.pbtn[0] = btn; this.caraUp = true; this.primerc =
false;

} else {
btn.setEnabled(false);

this.im2 = ((ImageIcon)btn.getDisabledIcon());
this.pbtn[1] = btn; this.primerc = true; this.puntaje +=
20; pregwin();

private void compare()


{

if ((this.caraUp) && (this.primerc))

if (this.im1.getDescription().compareTo(this.im2.getDescription()) != 0)

{ this.pbtn[0].setEnabled(true);
this.pbtn[1].setEnabled(true); if
(this.puntaje > 10) { this.puntaje -= 10;

} }

this.caraUp = false;
}

private void reiniciar()

{ this.btnC1.setEnabled(true);
this.btnC2.setEnabled(true);
this.btnC3.setEnabled(true);
this.btnC4.setEnabled(true);
this.btnC5.setEnabled(true);
this.btnC6.setEnabled(true);
this.btnC7.setEnabled(true);
this.btnC8.setEnabled(true);
this.btnC9.setEnabled(true);
this.btnC10.setEnabled(true);
this.btnC11.setEnabled(true);
this.btnC12.setEnabled(true);
this.btnC13.setEnabled(true);
this.btnC14.setEnabled(true);
this.btnC15.setEnabled(true);
this.btnC16.setEnabled(true);

this.primerc = false; this.caraUp =


false; this.puntaje = 0;
}

private void pregwin()


{

if ((!this.btnC1.isEnabled()) && (!this.btnC2.isEnabled()) &&

(!this.btnC3.isEnabled()) && (!this.btnC4.isEnabled()) && (!this.btnC5.isEnabled())

&& (!this.btnC6.isEnabled()) &&

(!this.btnC7.isEnabled()) && (!this.btnC8.isEnabled()) &&

(!this.btnC9.isEnabled()) && (!this.btnC10.isEnabled()) && (!this.btnC11.isEnabled()) &&

(!this.btnC12.isEnabled()) && (!this.btnC13.isEnabled()) &&

(!this.btnC14.isEnabled()) && (!this.btnC15.isEnabled()) &&

(!this.btnC16.isEnabled())) {

JOptionPane.showMessageDialog(this, "Felicidades, usted ha ganado. Su puntaje es: " +


this.puntaje, "Win!!", 1);
}

private void initComponents()

{ this.jLabel1 = new JLabel();


this.jPanel1 = new JPanel();
this.btnC1 = new JButton();
this.btnC2 = new JButton();
this.btnC3 = new JButton();
this.btnC4 = new JButton();
this.btnC8 = new JButton();
this.btnC7 = new JButton();
this.btnC6 = new JButton();
this.btnC5 = new JButton();
this.btnC12 = new JButton();
this.btnC11 = new JButton();
this.btnC10 = new JButton();
this.btnC9 = new JButton();
this.btnC16 = new JButton();
this.btnC15 = new JButton();
this.btnC14 = new JButton();
this.btnC13 = new JButton();
this.btnReiniciar = new JButton();

setDefaultCloseOperation(3); setTitle("Juego Dos


Caras");

this.jLabel1.setFont(new Font("Tahoma", 1, 18)); this.jLabel1.setForeground(new


Color(102, 102, 102)); this.jLabel1.setText("BIENVENIDO");

this.jPanel1.setBackground(new Color(204, 0, 0));

this.jPanel1.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));

this.btnC1.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC1.setBorder(null); this.btnC1.setBorderPainted(false);
this.btnC1.setContentAreaFilled(false); this.btnC1.setFocusable(false);
this.btnC1.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC1.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC1MouseExited(evt);

} });

this.btnC1.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)


{

PlayGame.this.btnC1ActionPerformed(evt);

} });

this.btnC2.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC2.setBorder(null); this.btnC2.setBorderPainted(false);
this.btnC2.setContentAreaFilled(false); this.btnC2.setFocusable(false);
this.btnC2.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC2.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC2MouseExited(evt);

} });

this.btnC2.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC2ActionPerformed(evt);

} });

this.btnC3.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC3.setBorder(null); this.btnC3.setBorderPainted(false);
this.btnC3.setContentAreaFilled(false); this.btnC3.setFocusable(false);
this.btnC3.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC3.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC3MouseExited(evt);

} });

this.btnC3.addActionListener(new ActionListener()
{

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC3ActionPerformed(evt);

} });

this.btnC4.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC4.setBorder(null); this.btnC4.setBorderPainted(false);
this.btnC4.setContentAreaFilled(false); this.btnC4.setFocusable(false);
this.btnC4.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC4.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC4MouseExited(evt);

} });

this.btnC4.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC4ActionPerformed(evt);

} });

this.btnC8.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC8.setBorder(null); this.btnC8.setBorderPainted(false);
this.btnC8.setContentAreaFilled(false); this.btnC8.setFocusable(false);
this.btnC8.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC8.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC8MouseExited(evt);
} });

this.btnC8.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC8ActionPerformed(evt);

} });

this.btnC7.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC7.setBorder(null); this.btnC7.setBorderPainted(false);
this.btnC7.setContentAreaFilled(false); this.btnC7.setFocusable(false);
this.btnC7.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC7.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC7MouseExited(evt);

});

this.btnC7.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC7ActionPerformed(evt);

} });

this.btnC6.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC6.setBorder(null); this.btnC6.setBorderPainted(false);
this.btnC6.setContentAreaFilled(false); this.btnC6.setFocusable(false);
this.btnC6.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC6.addMouseListener(new
MouseAdapter()

{
public void mouseExited(MouseEvent evt)

PlayGame.this.btnC6MouseExited(evt);

} });

this.btnC6.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC6ActionPerformed(evt);

} });

this.btnC5.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC5.setBorder(null); this.btnC5.setBorderPainted(false);
this.btnC5.setContentAreaFilled(false); this.btnC5.setFocusable(false);
this.btnC5.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC5.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC5MouseExited(evt);

} });

this.btnC5.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC5ActionPerformed(evt);

} });

this.btnC12.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC12.setBorder(null); this.btnC12.setBorderPainted(false);
this.btnC12.setContentAreaFilled(false); this.btnC12.setFocusable(false);
this.btnC12.setRolloverIcon(new
ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC12.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC12MouseExited(evt);

} });

this.btnC12.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC12ActionPerformed(evt);

} });

this.btnC11.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC11.setBorder(null); this.btnC11.setBorderPainted(false);
this.btnC11.setContentAreaFilled(false); this.btnC11.setFocusable(false);
this.btnC11.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC11.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC11MouseExited(evt);

} });

this.btnC11.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC11ActionPerformed(evt);

} });

this.btnC10.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC10.setBorder(null); this.btnC10.setBorderPainted(false);
this.btnC10.setContentAreaFilled(false); this.btnC10.setFocusable(false);
this.btnC10.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC10.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC10MouseExited(evt);

} });

this.btnC10.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC10ActionPerformed(evt);

} });

this.btnC9.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC9.setBorder(null); this.btnC9.setBorderPainted(false);
this.btnC9.setContentAreaFilled(false); this.btnC9.setFocusable(false);
this.btnC9.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC9.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC9MouseExited(evt);

} });

this.btnC9.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC9ActionPerformed(evt);
} });

this.btnC16.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC16.setBorder(null); this.btnC16.setBorderPainted(false);
this.btnC16.setContentAreaFilled(false); this.btnC16.setFocusable(false);
this.btnC16.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC16.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC16MouseExited(evt);

} });

this.btnC16.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC16ActionPerformed(evt);

} });

this.btnC15.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC15.setBorder(null); this.btnC15.setBorderPainted(false);
this.btnC15.setContentAreaFilled(false); this.btnC15.setFocusable(false);
this.btnC15.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC15.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC15MouseExited(evt);

} });

this.btnC15.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)


{

PlayGame.this.btnC15ActionPerformed(evt);

} });

this.btnC14.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC14.setBorder(null); this.btnC14.setBorderPainted(false);
this.btnC14.setContentAreaFilled(false); this.btnC14.setFocusable(false);
this.btnC14.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC14.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC14MouseExited(evt);

} });

this.btnC14.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC14ActionPerformed(evt);

} });

this.btnC13.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));
this.btnC13.setBorder(null); this.btnC13.setBorderPainted(false);
this.btnC13.setContentAreaFilled(false); this.btnC13.setFocusable(false);
this.btnC13.setRolloverIcon(new
ImageIcon(getClass().getResource("/imagenes/cr.png"))); this.btnC13.addMouseListener(new
MouseAdapter()

public void mouseExited(MouseEvent evt)

PlayGame.this.btnC13MouseExited(evt);

} });

this.btnC13.addActionListener(new ActionListener()
{

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnC13ActionPerformed(evt);

});

GroupLayout jPanel1Layout = new GroupLayout(this.jPanel1);


this.jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout
.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(this.btnC1)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(this.btnC2)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)

.addComponent(this.btnC3)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)

.addComponent(this.btnC4))

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(this.btnC5)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(this.btnC6)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(this.btnC7)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)

.addComponent(this.btnC8))

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(this.btnC9)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(this.btnC10)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(this.btnC11)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)

.addComponent(this.btnC12))

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(this.btnC13)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)

.addComponent(this.btnC14)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(this.btnC15)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)

.addComponent(this.btnC16)))

.addContainerGap(-1, 32767)));

jPanel1Layout.setVerticalGroup(jPanel1Layout
.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(this.btnC2)

.addComponent(this.btnC1)

.addComponent(this.btnC3)

.addComponent(this.btnC4))

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)

.addComponent(this.btnC6)

.addComponent(this.btnC5)

.addComponent(this.btnC7)

.addComponent(this.btnC8))

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(this.btnC9)

.addComponent(this.btnC10)

.addComponent(this.btnC11)

.addComponent(this.btnC12))

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)

.addComponent(this.btnC13)

.addComponent(this.btnC14)

.addComponent(this.btnC15)

.addComponent(this.btnC16))

.addContainerGap(-1, 32767)));

this.btnReiniciar.setFont(new Font("Tahoma", 1, 12)); this.btnReiniciar.setForeground(new


Color(0, 204, 0)); this.btnReiniciar.setText("Reiniciar");

this.btnReiniciar.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent evt)

PlayGame.this.btnReiniciarActionPerformed(evt);

});

GroupLayout layout = new GroupLayout(getContentPane());


getContentPane().setLayout(layout); layout.setHorizontalGroup(layout

.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(this.jPanel1, -2, -1, -2)

.addContainerGap(-1, 32767))

.addGroup(layout.createSequentialGroup()

.addContainerGap(-1, 32767)
.addComponent(this.jLabel1)

.addGap(35, 35, 35)

.addComponent(this.btnReiniciar)

.addGap(32, 32, 32)));

layout.setVerticalGroup(layout

.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(this.btnReiniciar))

.addComponent(this.jLabel1))

.addGap(18, 18, 18)

.addComponent(this.jPanel1, -1, -1, 32767)

.addContainerGap()));

setSize(new Dimension(400, 538)); setLocationRelativeTo(null);

private void btnC1ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC1);

private void btnC2ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC2);

private void btnC3ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC3);
}

private void btnC4ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC4);

private void btnC5ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC5);

private void btnC6ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC6);

private void btnC7ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC7);

private void btnC8ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC8);

private void btnC9ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC9);

private void btnC10ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC10);

}
private void btnC11ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC11);

private void btnC12ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC12);

private void btnC13ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC13);

private void btnC14ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC14);

private void btnC15ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC15);

private void btnC16ActionPerformed(ActionEvent evt)

btnEnabled(this.btnC16);

private void btnC1MouseExited(MouseEvent evt)

{ compare();

private void btnC2MouseExited(MouseEvent evt)

{ compare();
}

private void btnC3MouseExited(MouseEvent evt)

{ compare();

private void btnC4MouseExited(MouseEvent evt)

{ compare();

private void btnC5MouseExited(MouseEvent evt)

{ compare();

private void btnC6MouseExited(MouseEvent evt)

{ compare();

private void btnC7MouseExited(MouseEvent evt)

{ compare();

private void btnC8MouseExited(MouseEvent evt)

{ compare();

private void btnC9MouseExited(MouseEvent evt)

{ compare();

private void btnC10MouseExited(MouseEvent evt)

{ compare();

private void btnC11MouseExited(MouseEvent evt)

{ compare(); }

private void btnC12MouseExited(MouseEvent evt)

{ compare();
}

private void btnC13MouseExited(MouseEvent evt)

{ compare();

private void btnC14MouseExited(MouseEvent evt)

{ compare();

private void btnC15MouseExited(MouseEvent evt)

{ compare();

private void btnC16MouseExited(MouseEvent evt)

{ compare();

private void btnReiniciarActionPerformed(ActionEvent evt)

reiniciar();

public static void main(String[] args)

{ try { for (UIManager.LookAndFeelInfo info : )


{ if ("Nimbus".equals(info.getName()))

UIManager.setLookAndFeel(info.getClassName()); break;

} }

catch (ClassNotFoundException ex)

Logger.getLogger(PlayGame.class.getName()).log(Level.SEVERE, null, ex);

catch (InstantiationException ex)


{

Logger.getLogger(PlayGame.class.getName()).log(Level.SEVERE, null, ex);

catch (IllegalAccessException ex)

Logger.getLogger(PlayGame.class.getName()).log(Level.SEVERE, null, ex);

catch (UnsupportedLookAndFeelException ex)

Logger.getLogger(PlayGame.class.getName()).log(Level.SEVERE, null, ex);

EventQueue.invokeLater(new Runnable()

public void run()


{

new PlayGame().setVisible(true);

});

You might also like