Código
Si, esta hecho con netbeans, al que no le guste que no mire xDDD
/* * Programa que resuelve ecuaciones de segundo grado * con capacidad ilimitada. */ /* * Main.java * * Created on 20-nov-2009, 15:53:49 */ package ecuaciones; /** * * @author debci */ /** Creates new form Main */ public Main() { initComponents(); } /** Definicion de los mtodo y datos para la interfaz */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { setTitle("Resolucion de ecuaciones de 2o Grado"); Muestra.setToolTipText("Muestra de la ecuacion de segundo grado"); jLabel1.setText("Resolucion de una ecuacion de segundo grado"); jTextField1.setText("0"); jLabel2.setText("="); jLabel3.setText("+"); bActionPerformed(evt); } }); jLabel4.setText("X"); jLabel5.setText("+"); Consola.setColumns(20); Consola.setEditable(false); Consola.setRows(5); Consola.setText("--Solventador de ecuaciones sencillo--\n--Version beta--\n--Andoni Diaz <andoni94@gmail.com>--\n----------------------------------------------------\n_____________________________________\n----------------------------------------------------\n"); Consola.setToolTipText("Consola de resolucion de ecuaciones"); Consola.setAutoscrolls(true); jScrollPane1.setViewportView(Consola); btnResolver.setText("Resolver Ecuacion"); btnResolverActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(68, 68, 68) .addComponent(jLabel1) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(Muestra, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(164, 164, 164)) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(a, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(3, 3, 3) .addComponent(XCuadrado, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(b, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(4, 4, 4) .addComponent(jLabel4) .addGap(18, 18, 18) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(c, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 382, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(btnResolver) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(15, 15, 15) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(Muestra, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2) .addComponent(a, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3) .addComponent(b, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4) .addComponent(c, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(4, 4, 4) .addComponent(XCuadrado, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnResolver) .addContainerGap()) ); pack(); }// </editor-fold> // TODO add your handling code here: } int a_i; int b_i; int c_i; int x; int y; //Transformacion de valores a entero //Calculo del primer coeficiente, este es positivo //Calculo del segundo coeficiente, este es negativo Consola.append("Resultados de la ecuacion obtenidos:\n"); Consola.append("X = "+ ResultadoX + "\n"); Consola.append("Y = "+ ResultadoY + "\n"); Consola.append("La dos raizes de la ecuacion son X y Y\n\n"); Consola.append("--------------------------------------\n\n"); } /** * @param args the command line arguments */ public void run() { new Main().setVisible(true); Muestra.setText("a*x^2+b*x+c"); XCuadrado.setText("X²"); } }); } // Variables declaration - do not modify // End of variables declaration }
Sinceramente, diseñar interfaces con netbeans es mas rapido y ahorra tiempo de programacion, y mas os aseguro que antes programaba interfaces con la clase Swing y era un toston.
Bueno disfrutadlo ^^
Saludos