elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a la Factorización De Semiprimos (RSA)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  Programar aplicacion
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 3 4 Ir Abajo Respuesta Imprimir
Autor Tema: Programar aplicacion  (Leído 12,348 veces)
jordi_trialbike

Desconectado Desconectado

Mensajes: 17


Ver Perfil
Programar aplicacion
« en: 14 Diciembre 2011, 17:37 pm »

Hola, estoy buscando como crear una aplicacion. Consiste en tener frases con su respectivo numero por ejemplo:
1- Hace frio
2- Hace calor
3- Esta nublado

La aplicacion simplemente tendra una casilla donde introduciras un numero por ejemplo "3" y un boton "Buscar". Cuando pongas el numero y hagas click en buscar que te aparezca la respectiva frase.

Estoy intentando crear un proyecto y no se por donde empezar, he buscado algun ejemplo pero no he encontrado nada.


En línea

Etex

Desconectado Desconectado

Mensajes: 8



Ver Perfil
Re: Programar aplicacion
« Respuesta #1 en: 14 Diciembre 2011, 18:14 pm »

Es bastante simple lo que queres hacer. ¿En que lenguaje lo queres programar?.
Solo habria que ingresar un dato y hacer una condicion dependiendo el numero que se ingrese.

Saludos


En línea

jordi_trialbike

Desconectado Desconectado

Mensajes: 17


Ver Perfil
Re: Programar aplicacion
« Respuesta #2 en: 14 Diciembre 2011, 20:44 pm »

He pensado de hacerlo en java, tengo el netbeans y lo que de momento he hecho es crear un formulario JFrame i he conseguido creat el boton de "Buscar" ahora falta hacer el cuadro donde introducir los caracteres, en este caso los numeros.

Esto es hasta done he conseguido llegar. Si conoceis un metodo mas facil no me importa aprendeer de otra forma.
En línea

Pablo Videla


Desconectado Desconectado

Mensajes: 2.274



Ver Perfil WWW
Re: Programar aplicacion
« Respuesta #3 en: 14 Diciembre 2011, 21:23 pm »

He pensado de hacerlo en java, tengo el netbeans y lo que de momento he hecho es crear un formulario JFrame i he conseguido creat el boton de "Buscar" ahora falta hacer el cuadro donde introducir los caracteres, en este caso los numeros.

Esto es hasta done he conseguido llegar. Si conoceis un metodo mas facil no me importa aprendeer de otra forma.

Se puede saber cual es la idea de todo esto, una de esas en vez de hacerte el ejemplo podríamos aportar ideas y programarlas completamente XD
En línea

jordi_trialbike

Desconectado Desconectado

Mensajes: 17


Ver Perfil
Re: Programar aplicacion
« Respuesta #4 en: 14 Diciembre 2011, 21:34 pm »

Intentare explicaros un poco de que va la cosa. Adquiri una tarjeta pci de diagnostico la cual genera un codigo y yo he de consultar el manual dicho codigo. Se trata de hacerlo un poco mas facil.

Ami la tarjeta me marcaria un numero de error yo la introduzco en el programa que quiero crear y asi me aparecera cual es el error.
En línea

Pablo Videla


Desconectado Desconectado

Mensajes: 2.274



Ver Perfil WWW
Re: Programar aplicacion
« Respuesta #5 en: 14 Diciembre 2011, 21:37 pm »

Intentare explicaros un poco de que va la cosa. Adquiri una tarjeta pci de diagnostico la cual genera un codigo y yo he de consultar el manual dicho codigo. Se trata de hacerlo un poco mas facil.

Ami la tarjeta me marcaria un numero de error yo la introduzco en el programa que quiero crear y asi me aparecera cual es el error.

ah perfecto

Bueno podrias crear la interfaz grafica y darnos la variable de los componentes como el JTextField , el nombre del boton, y la label que te dira el mensaje y asi podremos programar eso, porque es super simple.
En línea

jordi_trialbike

Desconectado Desconectado

Mensajes: 17


Ver Perfil
Re: Programar aplicacion
« Respuesta #6 en: 14 Diciembre 2011, 21:46 pm »

Aqui esta el codigo que se me ha generado al crear la interfaz grafica donde jTextField1 es donde pondre el numero a buscar, jButton1 es el boton de buscar y jScrollPane2 el panel donde me mostrara el error. Aqui va el codigo completo, perdon si he puesto mas de lo que debia... es la primera vez que intento programar.

public class NewJFrame extends javax.swing.JFrame {

    private static class value_1 {

        public value_1() {
        }
    }

    /** Creates new form NewJFrame */
    public NewJFrame() {
        initComponents();
    }

    /** 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() {

        jDialog1 = new javax.swing.JDialog();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextPane1 = new javax.swing.JTextPane();

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTextField1.setText("jTextField1");

        jButton1.setText("Buscar");
        jButton1.setToolTipText("");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jScrollPane2.setViewportView(jTextPane1);

        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()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(80, 80, 80)
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 98, Short.MAX_VALUE)
                        .addComponent(jButton1)))
                .addGap(82, 82, 82))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(58, 58, 58)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(57, 57, 57)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(140, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>

private void jButton1ActionPerformed(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) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new NewJFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextPane jTextPane1;
    // End of variables declaration
}
En línea

Pablo Videla


Desconectado Desconectado

Mensajes: 2.274



Ver Perfil WWW
Re: Programar aplicacion
« Respuesta #7 en: 14 Diciembre 2011, 21:53 pm »

Aqui esta el codigo que se me ha generado al crear la interfaz grafica donde jTextField1 es donde pondre el numero a buscar, jButton1 es el boton de buscar y jScrollPane2 el panel donde me mostrara el error. Aqui va el codigo completo, perdon si he puesto mas de lo que debia... es la primera vez que intento programar.

public class NewJFrame extends javax.swing.JFrame {

    private static class value_1 {

        public value_1() {
        }
    }

    /** Creates new form NewJFrame */
    public NewJFrame() {
        initComponents();
    }

    /** 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() {

        jDialog1 = new javax.swing.JDialog();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextPane1 = new javax.swing.JTextPane();

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTextField1.setText("jTextField1");

        jButton1.setText("Buscar");
        jButton1.setToolTipText("");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jScrollPane2.setViewportView(jTextPane1);

        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()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(80, 80, 80)
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 98, Short.MAX_VALUE)
                        .addComponent(jButton1)))
                .addGap(82, 82, 82))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(58, 58, 58)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(57, 57, 57)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(140, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>

private void jButton1ActionPerformed(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) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new NewJFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextPane jTextPane1;
    // End of variables declaration
}


Código
  1. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  2. // TODO add your handling code here:
  3.  
  4.    String mensaje = jTextField1.getText();
  5.  
  6.    if(mensaje.equalsIgnoreCase("1")){
  7.  
  8.        label1.setText("Frio");
  9.    }else if(mensaje.equalsIgnoreCase("2")){
  10.  
  11.        label1.setText("caliente");
  12.    }
  13. }

ahi un ejemplo

en vez del scrollpanel te puse un label

aqui el codigo completo, que ni he probado pero funciona,

Código
  1.  
  2.  
  3.  
  4. /*
  5.  * DesktopApplication1View.java
  6.  */
  7.  
  8. package desktopapplication1;
  9.  
  10. import org.jdesktop.application.Action;
  11. import org.jdesktop.application.ResourceMap;
  12. import org.jdesktop.application.SingleFrameApplication;
  13. import org.jdesktop.application.FrameView;
  14. import org.jdesktop.application.TaskMonitor;
  15. import java.awt.event.ActionEvent;
  16. import java.awt.event.ActionListener;
  17. import javax.swing.Timer;
  18. import javax.swing.Icon;
  19. import javax.swing.JDialog;
  20. import javax.swing.JFrame;
  21.  
  22. /**
  23.  * The application's main frame.
  24.  */
  25. public class DesktopApplication1View extends FrameView {
  26.  
  27.    public DesktopApplication1View(SingleFrameApplication app) {
  28.        super(app);
  29.  
  30.        initComponents();
  31.  
  32.        // status bar initialization - message timeout, idle icon and busy animation, etc
  33.        ResourceMap resourceMap = getResourceMap();
  34.        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
  35.        messageTimer = new Timer(messageTimeout, new ActionListener() {
  36.            public void actionPerformed(ActionEvent e) {
  37.                statusMessageLabel.setText("");
  38.            }
  39.        });
  40.        messageTimer.setRepeats(false);
  41.        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
  42.        for (int i = 0; i < busyIcons.length; i++) {
  43.            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
  44.        }
  45.        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
  46.            public void actionPerformed(ActionEvent e) {
  47.                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
  48.                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
  49.            }
  50.        });
  51.        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
  52.        statusAnimationLabel.setIcon(idleIcon);
  53.        progressBar.setVisible(false);
  54.  
  55.        // connecting action tasks to status bar via TaskMonitor
  56.        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
  57.        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
  58.            public void propertyChange(java.beans.PropertyChangeEvent evt) {
  59.                String propertyName = evt.getPropertyName();
  60.                if ("started".equals(propertyName)) {
  61.                    if (!busyIconTimer.isRunning()) {
  62.                        statusAnimationLabel.setIcon(busyIcons[0]);
  63.                        busyIconIndex = 0;
  64.                        busyIconTimer.start();
  65.                    }
  66.                    progressBar.setVisible(true);
  67.                    progressBar.setIndeterminate(true);
  68.                } else if ("done".equals(propertyName)) {
  69.                    busyIconTimer.stop();
  70.                    statusAnimationLabel.setIcon(idleIcon);
  71.                    progressBar.setVisible(false);
  72.                    progressBar.setValue(0);
  73.                } else if ("message".equals(propertyName)) {
  74.                    String text = (String)(evt.getNewValue());
  75.                    statusMessageLabel.setText((text == null) ? "" : text);
  76.                    messageTimer.restart();
  77.                } else if ("progress".equals(propertyName)) {
  78.                    int value = (Integer)(evt.getNewValue());
  79.                    progressBar.setVisible(true);
  80.                    progressBar.setIndeterminate(false);
  81.                    progressBar.setValue(value);
  82.                }
  83.            }
  84.        });
  85.    }
  86.  
  87.    @Action
  88.    public void showAboutBox() {
  89.        if (aboutBox == null) {
  90.            JFrame mainFrame = DesktopApplication1.getApplication().getMainFrame();
  91.            aboutBox = new DesktopApplication1AboutBox(mainFrame);
  92.            aboutBox.setLocationRelativeTo(mainFrame);
  93.        }
  94.        DesktopApplication1.getApplication().show(aboutBox);
  95.    }
  96.  
  97.    /** This method is called from within the constructor to
  98.      * initialize the form.
  99.      * WARNING: Do NOT modify this code. The content of this method is
  100.      * always regenerated by the Form Editor.
  101.      */
  102.    @SuppressWarnings("unchecked")
  103.    // <editor-fold defaultstate="collapsed" desc="Generated Code">
  104.    private void initComponents() {
  105.  
  106.        mainPanel = new javax.swing.JPanel();
  107.        jTextField1 = new javax.swing.JTextField();
  108.        jButton1 = new javax.swing.JButton();
  109.        label1 = new java.awt.Label();
  110.        menuBar = new javax.swing.JMenuBar();
  111.        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
  112.        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
  113.        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
  114.        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
  115.        statusPanel = new javax.swing.JPanel();
  116.        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
  117.        statusMessageLabel = new javax.swing.JLabel();
  118.        statusAnimationLabel = new javax.swing.JLabel();
  119.        progressBar = new javax.swing.JProgressBar();
  120.  
  121.        mainPanel.setName("mainPanel"); // NOI18N
  122.  
  123.        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(desktopapplication1.DesktopApplication1.class).getContext().getResourceMap(DesktopApplication1View.class);
  124.        jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N
  125.        jTextField1.setName("jTextField1"); // NOI18N
  126.  
  127.        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
  128.        jButton1.setName("jButton1"); // NOI18N
  129.        jButton1.addActionListener(new java.awt.event.ActionListener() {
  130.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  131.                jButton1ActionPerformed(evt);
  132.            }
  133.        });
  134.  
  135.        label1.setName("label1"); // NOI18N
  136.        label1.setText(resourceMap.getString("label1.text")); // NOI18N
  137.  
  138.        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
  139.        mainPanel.setLayout(mainPanelLayout);
  140.        mainPanelLayout.setHorizontalGroup(
  141.            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  142.            .addGroup(mainPanelLayout.createSequentialGroup()
  143.                .addGap(123, 123, 123)
  144.                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  145.                    .addComponent(jButton1)
  146.                    .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  147.                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  148.                .addContainerGap(204, Short.MAX_VALUE))
  149.        );
  150.        mainPanelLayout.setVerticalGroup(
  151.            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  152.            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
  153.                .addContainerGap(115, Short.MAX_VALUE)
  154.                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  155.                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  156.                .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  157.                .addGap(19, 19, 19)
  158.                .addComponent(jButton1)
  159.                .addGap(42, 42, 42))
  160.        );
  161.  
  162.        menuBar.setName("menuBar"); // NOI18N
  163.  
  164.        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
  165.        fileMenu.setName("fileMenu"); // NOI18N
  166.  
  167.        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(desktopapplication1.DesktopApplication1.class).getContext().getActionMap(DesktopApplication1View.class, this);
  168.        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
  169.        exitMenuItem.setName("exitMenuItem"); // NOI18N
  170.        fileMenu.add(exitMenuItem);
  171.  
  172.        menuBar.add(fileMenu);
  173.  
  174.        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
  175.        helpMenu.setName("helpMenu"); // NOI18N
  176.  
  177.        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
  178.        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
  179.        helpMenu.add(aboutMenuItem);
  180.  
  181.        menuBar.add(helpMenu);
  182.  
  183.        statusPanel.setName("statusPanel"); // NOI18N
  184.  
  185.        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N
  186.  
  187.        statusMessageLabel.setName("statusMessageLabel"); // NOI18N
  188.  
  189.        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
  190.        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N
  191.  
  192.        progressBar.setName("progressBar"); // NOI18N
  193.  
  194.        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
  195.        statusPanel.setLayout(statusPanelLayout);
  196.        statusPanelLayout.setHorizontalGroup(
  197.            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  198.            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
  199.            .addGroup(statusPanelLayout.createSequentialGroup()
  200.                .addContainerGap()
  201.                .addComponent(statusMessageLabel)
  202.                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 230, Short.MAX_VALUE)
  203.                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  204.                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  205.                .addComponent(statusAnimationLabel)
  206.                .addContainerGap())
  207.        );
  208.        statusPanelLayout.setVerticalGroup(
  209.            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  210.            .addGroup(statusPanelLayout.createSequentialGroup()
  211.                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
  212.                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  213.                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  214.                    .addComponent(statusMessageLabel)
  215.                    .addComponent(statusAnimationLabel)
  216.                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  217.                .addGap(3, 3, 3))
  218.        );
  219.  
  220.        setComponent(mainPanel);
  221.        setMenuBar(menuBar);
  222.        setStatusBar(statusPanel);
  223.    }// </editor-fold>
  224.  
  225. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  226. // TODO add your handling code here:
  227.  
  228.    String mensaje = jTextField1.getText();
  229.  
  230.    if(mensaje.equalsIgnoreCase("1")){
  231.  
  232.        label1.setText("Frio");
  233.    }else if(mensaje.equalsIgnoreCase("2")){
  234.  
  235.        label1.setText("caliente");
  236.    }
  237. }
  238.  
  239.    // Variables declaration - do not modify
  240.    private javax.swing.JButton jButton1;
  241.    private javax.swing.JTextField jTextField1;
  242.    private java.awt.Label label1;
  243.    private javax.swing.JPanel mainPanel;
  244.    private javax.swing.JMenuBar menuBar;
  245.    private javax.swing.JProgressBar progressBar;
  246.    private javax.swing.JLabel statusAnimationLabel;
  247.    private javax.swing.JLabel statusMessageLabel;
  248.    private javax.swing.JPanel statusPanel;
  249.    // End of variables declaration
  250.  
  251.    private final Timer messageTimer;
  252.    private final Timer busyIconTimer;
  253.    private final Icon idleIcon;
  254.    private final Icon[] busyIcons = new Icon[15];
  255.    private int busyIconIndex = 0;
  256.  
  257.    private JDialog aboutBox;
  258. }
  259.  
  260.  
  261.  
En línea

jordi_trialbike

Desconectado Desconectado

Mensajes: 17


Ver Perfil
Re: Programar aplicacion
« Respuesta #8 en: 14 Diciembre 2011, 22:08 pm »

perdona mi ignorancia pero añadiendo el codigo que me has dicho deberia de funcionar?
he provado de poner solo lo qeu has modificado y no funcionaba despues he probado de poner el codogo completo y tampoco. QUe puedo estar haciendo mal?
En línea

Pablo Videla


Desconectado Desconectado

Mensajes: 2.274



Ver Perfil WWW
Re: Programar aplicacion
« Respuesta #9 en: 14 Diciembre 2011, 22:11 pm »

perdona mi ignorancia pero añadiendo el codigo que me has dicho deberia de funcionar?
he provado de poner solo lo qeu has modificado y no funcionaba despues he probado de poner el codogo completo y tampoco. QUe puedo estar haciendo mal?

coloca solo el codigo que te mande


y compilalo y lo pruebas, o lo otro que puedes hacer es crear un evento action del boton

(Boton derecho del mouse sobre el boton y actionevent algo asi y lo presionas, te creara el metodo que te di yo y solo colocas el contenido del metodo que te puse

En línea

Páginas: [1] 2 3 4 Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
PROGRAMAR PLC
Electrónica
IVANNA 4 9,426 Último mensaje 31 Julio 2005, 06:42 am
por MR. J
Aplicacion sobre aplicacion en pantalla completa xD
Programación Visual Basic
spaceboy90 1 2,474 Último mensaje 28 Enero 2007, 23:10 pm
por Red Mx
Saber cual es la aplicación activa y volver activa una aplicación
Programación Visual Basic
seba64 1 2,331 Último mensaje 2 Diciembre 2011, 22:19 pm
por raul338
Programar web en python? Programar OS en Phyton?
Scripting
GeorgArming 2 5,088 Último mensaje 30 Diciembre 2011, 22:56 pm
por RakNae
me gustaría programar una aplicacion para celular
Programación General
Beginner Web 2 2,558 Último mensaje 3 Noviembre 2020, 09:58 am
por Beginner Web
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines