Documente Academic
Documente Profesional
Documente Cultură
/** * @param args the command line arguments */ Mtodo; Aqu se escribe el cdigo del programa. public static void main(String[] args) { // TODO code application logic here System.out.println("hola mundo");
Funciones
2. CREAR UNA CLASE; ES UM MOLDE O UN PLAN O MODELO. SE CREA LA ESTRUCTURA PARA LOS OBJETOS.
Creando una clase; public class SESION1 { public void Imprimir(String dato) {
public void EscribirPuerto(short pin,short value){ paralelo.output(pin, value); 11. ABRIR EL EMULADOR DEL PUERTO PARALELO EN PROTEUS APLICAR PLAY Y OK.
13. PROBAR
Programar para encender leds. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package practica.java;
/** * 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() { obj.EscribirPuerto(puerto,(short)255); jToggleButton1 = new javax.swing.JToggleButton(); jToggleButton2 = new javax.swing.JToggleButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jToggleButton1.setText("prender led");
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(262, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jToggleButton2) .addComponent(jToggleButton1)) .addGap(33, 33, 33)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(45, 45, 45) .addComponent(jToggleButton1) .addGap(46, 46, 46) .addComponent(jToggleButton2) .addContainerGap(163, Short.MAX_VALUE)) );
private void jToggleButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: obj.EscribirPuerto(puerto,(short)255); }
/** * @param args the command line arguments */ public static void main(String args[]) { /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) {
public void run() { new interfazparalela().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JToggleButton jToggleButton1; private javax.swing.JToggleButton jToggleButton2;
Cdigo sin terminar /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package practica.java;
/** * Creates new form interfazparalela */ paralelo obj; short puerto= (short)0x0378; int suma, led1 = 0;
int c1; public interfazparalela() { initComponents(); obj = new paralelo(); } public void prnderled(int valor){ obj.EscribirPuerto(puerto,(short)valor); } /** * 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() {
jPanel1 = new javax.swing.JPanel(); jCheckBox1 = new javax.swing.JCheckBox(); jCheckBox2 = new javax.swing.JCheckBox(); jCheckBox3 = new javax.swing.JCheckBox(); jCheckBox4 = new javax.swing.JCheckBox(); jCheckBox5 = new javax.swing.JCheckBox(); jCheckBox6 = new javax.swing.JCheckBox(); jCheckBox7 = new javax.swing.JCheckBox(); jCheckBox8 = new javax.swing.JCheckBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jToggleButton1.setText("prender led"); jToggleButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton1ActionPerformed(evt); } });
jToggleButton2.setText("apagar leds"); jToggleButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton2ActionPerformed(evt); } });
jCheckBox1.setText("led1");
jCheckBox3.setText("led3");
jCheckBox4.setText("led4");
jCheckBox6.setText("led6");
jCheckBox7.setText("led7");
jCheckBox8.setText("led8");
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING ) .addComponent(jCheckBox8) .addComponent(jCheckBox6) .addComponent(jCheckBox5) .addComponent(jCheckBox4) .addComponent(jCheckBox3) .addComponent(jCheckBox2) .addComponent(jCheckBox1) .addComponent(jCheckBox7)) .addContainerGap(92, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jCheckBox1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jCheckBox2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jCheckBox3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jCheckBox4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jCheckBox5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jCheckBox6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jCheckBox7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jCheckBox8) .addContainerGap()) );
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 117, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(45, 45, 45) .addComponent(jToggleButton1) .addGap(46, 46, 46) .addComponent(jToggleButton2)) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(73, Short.MAX_VALUE)) );
private void jToggleButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: obj.EscribirPuerto(puerto,(short)255); }
private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: c1++;
private void jCheckBox5ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
/** * @param args the command line arguments */ public static void main(String args[]) { /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */
try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) {
public void run() { new interfazparalela().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JCheckBox jCheckBox1; private javax.swing.JCheckBox jCheckBox2; private javax.swing.JCheckBox jCheckBox3; private javax.swing.JCheckBox jCheckBox4; private javax.swing.JCheckBox jCheckBox5; private javax.swing.JCheckBox jCheckBox6; private javax.swing.JCheckBox jCheckBox7; private javax.swing.JCheckBox jCheckBox8; private javax.swing.JPanel jPanel1; private javax.swing.JToggleButton jToggleButton1; private javax.swing.JToggleButton jToggleButton2; // End of variables declaration }