Advertisement
carlos0722

Untitled

Mar 11th, 2021
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 2.42 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.JOptionPane;
  9. //import java.awt.Scrollbar;
  10. import javax.swing.JTable;
  11. public class menuNew implements ActionListener{
  12.  
  13.     private JFrame frame;
  14.     private JTable table;
  15.     JMenuBar menu= new JMenuBar();
  16.     JMenu calculadora, suma,resta, multiplicar;
  17.      int t;
  18.  
  19.     /**
  20.      * Launch the application.
  21.      */
  22.     public static void main(String[] args) {
  23.         EventQueue.invokeLater(new Runnable() {
  24.             public void run() {
  25.                 try {
  26.                     menuNew window = new menuNew();
  27.                     window.frame.setVisible(true);
  28.                 } catch (Exception e) {
  29.                     e.printStackTrace();
  30.                 }
  31.             }
  32.         });
  33.     }
  34.  
  35.     /**
  36.      * Create the application.
  37.      */
  38.     public menuNew() {
  39.         initialize();
  40.        
  41.     }
  42.     private void initialize() {
  43.         CrearMenu();
  44.           frame = new JFrame("calculadora");
  45.         frame.setBounds(100, 100, 200, 300);
  46.         frame.setJMenuBar(menu);
  47.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  48.         frame.getContentPane().setLayout(null);
  49.        
  50.         table = new JTable();
  51.         table.setBounds(173, 216, -159, -156);
  52.         frame.getContentPane().add(table);
  53.     }
  54.  
  55.     private void CrearMenu() {
  56.         // TODO Auto-generated method stub
  57.         calculadora =new JMenu("calcular");
  58.         menu.add(calculadora);
  59.         //suma
  60.         suma =new JMenu("Sumar");
  61.         suma.addActionListener(new ActionListener() {
  62.             public void actionPerformed(ActionEvent e) {
  63.             }
  64.            
  65.         });
  66.         calculadora.add(suma);
  67.         suma.add("sumar dos numeros");
  68.         suma.add("sumar tres numeros");
  69.         //resta
  70.         resta =new JMenu("Restar");
  71.         calculadora.add(resta);
  72.         resta.add("restar dos numero negativo");
  73.         resta.add("restar dos numero positivo");
  74.         //mu
  75.         multiplicar =new JMenu("Multiplicar");
  76.         calculadora.add(multiplicar);
  77.         multiplicar.add("multiplicar dos numeros");
  78.        
  79.        
  80.        
  81.        
  82.         multiplicar.add("multiplicar tres numeros");
  83.        
  84.        
  85.        
  86.     }
  87.  
  88.     @Override
  89.     public void actionPerformed(ActionEvent e) {
  90.         // TODO Auto-generated method stub
  91.        
  92.        
  93. }
  94.        
  95.        
  96.        
  97.    
  98.    
  99.     protected float[] cargaNumeros(int i) {
  100.         // TODO Auto-generated method stub
  101.           float nums[]= new float[t];
  102.           for (int i1=0; i1 < nums.length ;i1++ ) {
  103.                   nums[i1]=Float.parseFloat(JOptionPane.showInputDialog("Ingrese un numero: "));
  104.           }      
  105.           return nums;
  106.     }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement