Foro de elhacker.net

Programación => Java => Mensaje iniciado por: multiuso en 23 Octubre 2013, 18:44 pm



Título: Problema con mi aplicacion
Publicado por: multiuso en 23 Octubre 2013, 18:44 pm
Hola a todos, estoy haciendo una aplicación e java y me encontré con el siguiente problema:
Yo quiero que la aplicación tenga una serie de botones al costado izquierdo y que dependiendo que botón aprietes el lado derecho cambie. Seria algo así:

Botones (Lado izquierdo)....|.........(Lado derecho - Opciones del botón)
*Pedidos...........................|.........Ejemplo: Pedidos
*Factura............................|.........Cantidad:...................Fecha:
*Cuenta Corriente...............|.........Detalle:....................Cliente:
*Clientes...........................|..........Fecha de entrega:
*Usuarios..........................|..........Aceptar(Botón).........Cancelar(Botón)

Ahora si apretarían en clientes el "lado derecho" debería cambiar por completo, y así con cada opción. Me estoy matando y no logro conseguirlo.
No les pido el código, sino que me digan que herramientas puedo usar, porque no encuentro la solución con las que me proporciona java.

Desde ante mano muchisimas gracias!


Título: Re: Problema con mi aplicacion
Publicado por: 1mpuls0 en 23 Octubre 2013, 19:10 pm
Código
  1. /**
  2.  *
  3.  * @author 1mpulso
  4.  */
  5. public class NewJFrame extends javax.swing.JFrame {
  6.  
  7.    /** Creates new form NewJFrame */
  8.    public NewJFrame() {
  9.        initComponents();
  10.    }
  11.  
  12.    /** This method is called from within the constructor to
  13.      * initialize the form.
  14.      * WARNING: Do NOT modify this code. The content of this method is
  15.      * always regenerated by the Form Editor.
  16.      */
  17.    @SuppressWarnings("unchecked")
  18.    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  19.    private void initComponents() {
  20.  
  21.        jPanel1 = new javax.swing.JPanel();
  22.        jButton1 = new javax.swing.JButton();
  23.        jButton2 = new javax.swing.JButton();
  24.        jButton3 = new javax.swing.JButton();
  25.        jPanel2 = new javax.swing.JPanel();
  26.  
  27.        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  28.        setMinimumSize(new java.awt.Dimension(500, 300));
  29.        getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));
  30.  
  31.        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("P. Izquierdo"));
  32.        jPanel1.setLayout(new java.awt.GridLayout(5, 1, 5, 5));
  33.  
  34.        jButton1.setText("jButton1");
  35.        jButton1.addActionListener(new java.awt.event.ActionListener() {
  36.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  37.                jButton1ActionPerformed(evt);
  38.            }
  39.        });
  40.        jPanel1.add(jButton1);
  41.  
  42.        jButton2.setText("jButton2");
  43.        jButton2.addActionListener(new java.awt.event.ActionListener() {
  44.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  45.                jButton2ActionPerformed(evt);
  46.            }
  47.        });
  48.        jPanel1.add(jButton2);
  49.  
  50.        jButton3.setText("jButton3");
  51.        jPanel1.add(jButton3);
  52.  
  53.        getContentPane().add(jPanel1);
  54.  
  55.        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("P. Derecho"));
  56.        getContentPane().add(jPanel2);
  57.  
  58.        pack();
  59.    }// </editor-fold>//GEN-END:initComponents
  60.  
  61. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  62. // TODO add your handling code here:
  63.    jPanel2.removeAll();
  64.    NewJPanel p0 = new NewJPanel();
  65.    jPanel2.add(p0);
  66.    jPanel2.updateUI();
  67.      jPanel2.repaint();
  68.      repaint();
  69. }//GEN-LAST:event_jButton1ActionPerformed
  70.  
  71. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  72. // TODO add your handling code here:
  73.    jPanel2.removeAll();
  74.    NewJPanel1 p1 = new NewJPanel1();
  75.    jPanel2.add(p1);
  76.    jPanel2.updateUI();
  77.      jPanel2.repaint();
  78.      repaint();
  79. }//GEN-LAST:event_jButton2ActionPerformed
  80.  
  81.    /**
  82.      * @param args the command line arguments
  83.      */
  84.    public static void main(String args[]) {
  85.        /* Set the Nimbus look and feel */
  86.        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  87.        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  88.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  89.          */
  90.        try {
  91.            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  92.                if ("Nimbus".equals(info.getName())) {
  93.                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
  94.                    break;
  95.                }
  96.            }
  97.        } catch (ClassNotFoundException ex) {
  98.            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  99.        } catch (InstantiationException ex) {
  100.            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  101.        } catch (IllegalAccessException ex) {
  102.            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  103.        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  104.            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  105.        }
  106.        //</editor-fold>
  107.  
  108.        /* Create and display the form */
  109.        java.awt.EventQueue.invokeLater(new Runnable() {
  110.  
  111.            public void run() {
  112.                new NewJFrame().setVisible(true);
  113.            }
  114.        });
  115.    }
  116.    // Variables declaration - do not modify//GEN-BEGIN:variables
  117.    private javax.swing.JButton jButton1;
  118.    private javax.swing.JButton jButton2;
  119.    private javax.swing.JButton jButton3;
  120.    private javax.swing.JPanel jPanel1;
  121.    private javax.swing.JPanel jPanel2;
  122.    // End of variables declaration//GEN-END:variables
  123. }
  124.  

Código
  1. /**
  2.  *
  3.  * @author 1mpuls0
  4.  */
  5. public class NewJPanel extends javax.swing.JPanel {
  6.  
  7.    /** Creates new form NewJPanel */
  8.    public NewJPanel() {
  9.        initComponents();
  10.    }
  11.  
  12.    /** This method is called from within the constructor to
  13.      * initialize the form.
  14.      * WARNING: Do NOT modify this code. The content of this method is
  15.      * always regenerated by the Form Editor.
  16.      */
  17.    @SuppressWarnings("unchecked")
  18.    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  19.    private void initComponents() {
  20.  
  21.        jRadioButton1 = new javax.swing.JRadioButton();
  22.        jCheckBox1 = new javax.swing.JCheckBox();
  23.        jScrollPane1 = new javax.swing.JScrollPane();
  24.        jTextArea1 = new javax.swing.JTextArea();
  25.  
  26.        setBorder(javax.swing.BorderFactory.createTitledBorder("Panel0"));
  27.  
  28.        jRadioButton1.setText("jRadioButton1");
  29.        add(jRadioButton1);
  30.  
  31.        jCheckBox1.setText("jCheckBox1");
  32.        add(jCheckBox1);
  33.  
  34.        jTextArea1.setColumns(20);
  35.        jTextArea1.setRows(5);
  36.        jScrollPane1.setViewportView(jTextArea1);
  37.  
  38.        add(jScrollPane1);
  39.    }// </editor-fold>//GEN-END:initComponents
  40.    // Variables declaration - do not modify//GEN-BEGIN:variables
  41.    private javax.swing.JCheckBox jCheckBox1;
  42.    private javax.swing.JRadioButton jRadioButton1;
  43.    private javax.swing.JScrollPane jScrollPane1;
  44.    private javax.swing.JTextArea jTextArea1;
  45.    // End of variables declaration//GEN-END:variables
  46. }
  47.  

Código
  1. /**
  2.  *
  3.  * @author 1mpuls0
  4.  */
  5. public class NewJPanel1 extends javax.swing.JPanel {
  6.  
  7.    /** Creates new form NewJPanel1 */
  8.    public NewJPanel1() {
  9.        initComponents();
  10.    }
  11.  
  12.    /** This method is called from within the constructor to
  13.      * initialize the form.
  14.      * WARNING: Do NOT modify this code. The content of this method is
  15.      * always regenerated by the Form Editor.
  16.      */
  17.    @SuppressWarnings("unchecked")
  18.    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  19.    private void initComponents() {
  20.  
  21.        jButton1 = new javax.swing.JButton();
  22.        jComboBox1 = new javax.swing.JComboBox();
  23.        jTextField1 = new javax.swing.JTextField();
  24.  
  25.        setBorder(javax.swing.BorderFactory.createTitledBorder("Panel1"));
  26.  
  27.        jButton1.setText("jButton1");
  28.        add(jButton1);
  29.  
  30.        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
  31.        add(jComboBox1);
  32.  
  33.        jTextField1.setText("jTextField1");
  34.        add(jTextField1);
  35.    }// </editor-fold>//GEN-END:initComponents
  36.    // Variables declaration - do not modify//GEN-BEGIN:variables
  37.    private javax.swing.JButton jButton1;
  38.    private javax.swing.JComboBox jComboBox1;
  39.    private javax.swing.JTextField jTextField1;
  40.    // End of variables declaration//GEN-END:variables
  41. }
  42.