carlos0722

Untitled

Mar 11th, 2021 (edited)
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.26 KB | None | 0 0
  1. package ji;
  2. import java.awt.EventQueue;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import javax.swing.JFrame;
  6. import javax.swing.JMenu;
  7. import javax.swing.JMenuBar;
  8. import javax.swing.JMenuItem;
  9. import javax.swing.JOptionPane;
  10. import javax.swing.JScrollPane;
  11. import javax.swing.JTable;
  12. import javax.swing.table.DefaultTableModel;
  13. public class menuNew implements ActionListener{
  14.  
  15.     private JFrame frame;
  16.     private JTable table;
  17.     JMenuBar menu= new JMenuBar();
  18.     JMenu calculadora, suma,resta, multiplicar;
  19.     JMenuItem sum2num;
  20.      int t;
  21.      String refere;
  22.       float resu;
  23.     private DefaultTableModel tab;
  24.      private JScrollPane scroll;
  25.      private JTable tabl;
  26.  
  27.     /**
  28.      * Launch the application.
  29.      */
  30.     public static void main(String[] args) {
  31.         EventQueue.invokeLater(new Runnable() {
  32.             public void run() {
  33.                 try {
  34.                     menuNew window = new menuNew();
  35.                     window.frame.setVisible(true);
  36.                 } catch (Exception e) {
  37.                     e.printStackTrace();
  38.                 }
  39.             }
  40.         });
  41.     }
  42.  
  43.     /**
  44.      * Create the application.
  45.      */
  46.     public menuNew() {
  47.         initialize();
  48.        
  49.     }
  50.     private void initialize() {
  51.         CrearMenu();
  52.           frame = new JFrame("calculadora");
  53.         frame.setBounds(100, 100, 268, 300);
  54.         frame.setJMenuBar(menu);
  55.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  56.         frame.getContentPane().setLayout(null);
  57.        
  58.        
  59.         Object[][] filas= {};
  60.         String[] columnas= {"Descripciones","Resultado"};
  61.                        
  62.         tab= new DefaultTableModel(filas,columnas) {
  63.                 /**
  64.              *
  65.              */
  66.  
  67.                 @Override
  68.                 public boolean isCellEditable(int Rows,int Columns) {
  69.                         return false;
  70.                 }
  71.         };
  72.         tabl = new JTable();
  73.         tabl.setModel(tab);
  74.         tabl.getTableHeader().setReorderingAllowed(false);
  75.         scroll= new JScrollPane(tabl);
  76.         scroll.setBounds(0,50,251,200);
  77.         frame.getContentPane().add(scroll);
  78.     }
  79.  
  80.     private void CrearMenu() {
  81.         // TODO Auto-generated method stub
  82.         calculadora =new JMenu("calcular");
  83.         menu.add(calculadora);
  84.         //suma
  85.         suma =new JMenu("Sumar");
  86.         calculadora.add(suma);
  87.         JMenuItem sum2num= new JMenuItem("Sumar dos numeros");
  88.         suma.add(sum2num);
  89.        JMenuItem sum3num= new JMenuItem("Sumar tres numeros");
  90.         suma.add(sum3num);
  91.         //resta
  92.         resta =new JMenu("Restar");
  93.         calculadora.add(resta);
  94.          JMenuItem resne= new JMenuItem("restar dos numero negativo");
  95.          JMenuItem respo= new JMenuItem("restar dos numero positivo");
  96.         resta.add(resne);
  97.         resta.add(respo);
  98.         //mu
  99.         multiplicar =new JMenu("Multiplicar");
  100.         calculadora.add(multiplicar);
  101.          JMenuItem mul2= new JMenuItem("multiplicar dos numeros");
  102.          JMenuItem mul3= new JMenuItem("multiplicar tres numeros");
  103.         multiplicar.add(mul2);
  104.         multiplicar.add(mul3);
  105.        
  106.        
  107.        
  108.     }
  109.  
  110.     @Override
  111.     public void actionPerformed(ActionEvent e) {
  112.         // TODO Auto-generated method stub
  113.        
  114.        
  115. }
  116.        
  117.        
  118.        
  119.    
  120.    
  121.     protected float[] cargaNumeros(int i) {
  122.         // TODO Auto-generated method stub
  123.           float nums[]= new float[t];
  124.           for (int i1=0; i1 < nums.length ;i1++ ) {
  125.                   nums[i1]=Float.parseFloat(JOptionPane.showInputDialog("Ingrese un numero: "));
  126.           }      
  127.           return nums;
  128.     }
  129. }
Add Comment
Please, Sign In to add comment