mi ATM funciona en teoria ya que np me produce fall alguno, pero no me despliega ninguna pantalla.
Mi codigo
Código:
El codigo 2 es de un ATM que me encontre internet algo sencillo.package com.Mybank.gui; import com.Mybank.data.DataSource; import java.awt.BorderLayout; import java.awt.Button; import java.awt.Frame; import java.awt.GridLayout; import java.awt.Panel; import java.awt.TextArea; import java.awt.TextField; import java.io.IOException; public class ATMClient { private static final String USAGE= "USAGE: java com.mybank.gui.ATMClient <dataFilePath>"; public static void main(String[] args) { String dataFilePath = "C:\\Account\\data\\test.dat"; try { System.out.println("Reading data file: " + dataFilePath); // Create the data source and load the Bank data DataSource dataSource = new DataSource(dataFilePath); dataSource.loadData(); // Run the ATM GUI ATMClient client = new ATMClient(); client.launchFrame(); } catch (IOException ioe) { System.out.println("Could not load the data file."); System.out.println(ioe.getMessage()); ioe.printStackTrace(System.err); } } // PLACE YOUR GUI CODE HERE // GUI component instance variables private Frame frame; private Panel pLeftHalf; private Panel pRightHalf; private TextField entryField; private TextField messageField; private TextArea outputArea; public ATMClient() { frame = new Frame(/*Bank.getName() +*/ " ATM"); initializeFrameComponents(); } public void launchFrame() { frame.pack(); frame.setResizable(false); frame.setVisible(true); } private void initializeFrameComponents() { initLeftHalf(); initRightHalf(); } private void initLeftHalf() { pLeftHalf = new Panel(); pLeftHalf.setLayout(new GridLayout(2, 1)); initTopLeft(); initBottomLeft(); frame.add(pLeftHalf, BorderLayout.WEST); } private void initTopLeft() { Panel topLeftPanel = new Panel(); topLeftPanel.setLayout(new GridLayout(3, 1)); Button[] menuButtons = new Button[] {new Button("Display account balance"), new Button("Make a deposit"), new Button("Make a withdrawal")}; for (int i=0; i<3; i++) { topLeftPanel.add(menuButtons[i]); } pLeftHalf.add(topLeftPanel); } private void initBottomLeft() { // Initialize entry text field and keypad grid panel Panel entryKeyPadPanel = new Panel(); entryKeyPadPanel.setLayout(new BorderLayout()); // Create and add entry text field entryField = new TextField(10); entryKeyPadPanel.add(entryField, BorderLayout.NORTH); // Create keypad grid and buttons Panel keyPadGrid = new Panel(); keyPadGrid.setLayout(new GridLayout(4, 3)); Button[] keyPadButtons = new Button[] {new Button("1"), new Button("2"), new Button("3"), new Button("4"), new Button("5"), new Button("6"), new Button("7"), new Button("8"), new Button("9"), new Button("0"), new Button(""), new Button("ENTER")}; for (int i=0; i<12; i++) { keyPadGrid.add(keyPadButtons[i]); } entryKeyPadPanel.add(keyPadGrid, BorderLayout.SOUTH); // Add entry/keypad panel to left-half panel pLeftHalf.add(entryKeyPadPanel); } private void initRightHalf() { pRightHalf = new Panel(); pRightHalf.setLayout(new BorderLayout()); outputArea = new TextArea(10, 75); pRightHalf.add(outputArea, BorderLayout.CENTER); messageField = new TextField(75); pRightHalf.add(messageField, BorderLayout.SOUTH); pRightHalf.setEnabled(false); frame.add(pRightHalf, BorderLayout.EAST); } }
El que baje de internet
Código:
ahora quisiera saber si me puden darme una mano para que sepa como combinar mi ATM con el ATM que descargue package bank; import java.text.*; import java.awt.event.*; import java.awt.*; import javax.swing.*; import java.math.*; public class ATM { private JFrame f; private JTextField vn; private JTextArea v; private JPanel p; private JPanel pp; private JPanel ppp; private JPanel pppp; private JButton one, two, three; private JButton q, w, e, r, t, y, u, i, o, n, a, s; public ATM() { f = new JFrame("ATM Program"); p = new JPanel(); pp = new JPanel(); ppp = new JPanel(); pppp = new JPanel(); vn = new JTextField(); v = new JTextArea(); one = new JButton("Display Account Balance"); two = new JButton("Make a Deposit"); three = new JButton("Make a Withdraw"); q = new JButton("1"); w = new JButton("2"); e = new JButton("3"); r = new JButton("4"); t = new JButton("5"); y = new JButton("6"); u = new JButton("7"); i = new JButton("8"); o = new JButton("9"); n = new JButton("0"); s = new JButton("."); a = new JButton("Enter"); } public void ATM() { one.addActionListener(new ButtonHandler()); two.addActionListener(new ButtonHandler()); three.addActionListener(new ButtonHandler()); q.addActionListener(new ButtonHandler()); w.addActionListener(new ButtonHandler()); e.addActionListener(new ButtonHandler()); r.addActionListener(new ButtonHandler()); t.addActionListener(new ButtonHandler()); y.addActionListener(new ButtonHandler()); u.addActionListener(new ButtonHandler()); i.addActionListener(new ButtonHandler()); o.addActionListener(new ButtonHandler()); n.addActionListener(new ButtonHandler()); s.addActionListener(new ButtonHandler()); a.addActionListener(new ButtonHandler()); f.setPreferredSize(new Dimension(610, 150)); f.setResizable(true); pp.setLayout(new GridLayout(4,1)); pp.add(one); pp.add(two); pp.add(three); pp.add(vn); p.add(pp, BorderLayout.NORTH); ppp.setLayout(new GridLayout(4,3)); ppp.add(q); ppp.add(w); ppp.add(e); ppp.add(r); ppp.add(t); ppp.add(y); ppp.add(u); ppp.add(i); ppp.add(o); ppp.add(n); ppp.add(a); ppp.add(s); p.add(ppp, BorderLayout.SOUTH); pppp.setLayout(new GridLayout(1, 0)); pppp.add(v = new JTextArea(7, 20)); p.add(pppp, BorderLayout.CENTER); f.add(p); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); } class ButtonHandler implements ActionListener { Checking check = new Checking(); double value = 0.00; public void set() { check.setBalance(check.getBalance() + value); } public void actionPerformed(ActionEvent e) { JButton source = (JButton)(e.getSource()); String text = source.getText(); if (text.equals("1")) { vn.setText(vn.getText() + 1); } if (text.equals("2")) { vn.setText(vn.getText() + 2); } if (text.equals("3")) { vn.setText(vn.getText() + 3); } if (text.equals("4")) { vn.setText(vn.getText() + 4); } if (text.equals("5")) { vn.setText(vn.getText() + 5); } if (text.equals("6")) { vn.setText(vn.getText() + 6); } if (text.equals("7")) { vn.setText(vn.getText() + 7); } if (text.equals("8")) { vn.setText(vn.getText() + 8); } if (text.equals("9")) { vn.setText(vn.getText() + 9); } if (text.equals("0")) { vn.setText(vn.getText() + 0); } if (text.equals("Enter")) { value = Double.parseDouble(vn.getText()); v.setText("What would you like to do?"); } if (text.equals("Display Account Balance")) { set(); v.setText(v.getText() + check.getBalance()); } if (text.equals("Make a Deposit")) { set(); v.setText(v.getText() + "your acount has been updated" ); } if (text.equals("Make a Withdraw")) { try { check.withdraw(value); } catch (IllegalArgumentException ex) { check.deductOverDraftPenalty(); v.setText("" + ex.getMessage()); } catch (NoAvailableFundsException ex) { v.setText("" + ex.getMessage()); } catch (OverDraftException ex) { v.setText("" + ex.getMessage()); } finally { check.deductOverDraftPenalty(); } } } } public static void main(String[] args) { ATM guiWindow = new ATM(); guiWindow.ATM(); } }
Trate de combinarlos pero no resulto.
o que devo hacerle a mi interfas grafica para que se muestre
Grasias de Antemano