rendered paste bodypackage de.fhro.gui.basic.uebung01;import java.awt.*;import java.awt.event.*;public class JDBCBrowser { public static void main(String[] args) { BrowserFrame frame = new BrowserFrame(); frame.setVisible(true); frame.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent we){ System.exit(0); } }); }}class BrowserFrame extends Frame { private BrowserView view; public BrowserFrame() { view = new BrowserView(); add(view); super.pack(); } public BrowserView getBrowserView() { return view; }}class BrowserView extends Panel { private HeadingView heading; private CenterView center; private FooterView footer; private ApplicationController controller; public BrowserView() { setLayout(new BorderLayout()); heading = new HeadingView(); center = new CenterView(); controller = new ApplicationController(center); footer = new FooterView(controller); add(heading, BorderLayout.NORTH); add(center, BorderLayout.CENTER); add(footer, BorderLayout.SOUTH); } public HeadingView getHeading() { return heading; } public void setHeading(HeadingView heading) { this.heading = heading; } public CenterView getCenter() { return center; } public void setCenter(CenterView center) { this.center = center; } public ApplicationController getController() { return controller; } public void setController(ApplicationController controller) { this.controller = controller; } public FooterView getFooter() { return footer; } public void setFooter(FooterView footer) { this.footer = footer; }}class HeadingView extends Panel { public HeadingView() { setLayout(new FlowLayout()); Label driverLbl = new Label("Driver:"); TextField driverInput = new TextField("oracle.djbc.driver.OracleDriver"); Label dbLbl = new Label("Database:"); TextField dbInput = new TextField("jdbc:oracle:thin:@141.60.120.130:1521"); Label userLbl = new Label("User:"); TextField userInput = new TextField("system"); // sollte pw verstecken Label passwordLbl = new Label("Password:"); TextField passwordInput = new TextField("manager"); add(driverLbl); add(driverInput); add(dbLbl); add(dbInput); add(userLbl); add(userInput); add(passwordLbl); add(passwordInput); }}class CenterView extends Panel { private CenterPane pane1; private CenterPane pane2; public CenterView() { setLayout(new GridLayout(0,1)); this.pane1 = new CenterPane("select * from article"); this.pane2 = new CenterPane(); add(pane1); add(pane2); } public CenterPane getUpperPane() { return pane1; } public CenterPane getLowerPane() { return pane2; }}class CenterPane extends ScrollPane { private TextArea textArea; public CenterPane() { super(ScrollPane.SCROLLBARS_ALWAYS); textArea = new TextArea("", 1, 1, TextArea.SCROLLBARS_NONE); add(textArea); } public CenterPane(String defaultText) { super(ScrollPane.SCROLLBARS_ALWAYS); textArea = new TextArea(defaultText, 1, 1, TextArea.SCROLLBARS_NONE); add(textArea); } public TextArea getTextArea(){ return this.textArea; }}class FooterView extends Panel { public FooterView(ApplicationController ac) { setLayout(new FlowLayout(FlowLayout.CENTER)); Button connectBtn = new Button("Connect"); connectBtn.setActionCommand("connect"); connectBtn.addActionListener(ac); Button infoBtn = new Button("DB-Info"); infoBtn.setActionCommand("info"); infoBtn.addActionListener(ac); Button submitBtn = new Button("Submit"); submitBtn.setActionCommand("submit"); submitBtn.addActionListener(ac); Button prepareBtn = new Button("Prepare"); prepareBtn.setActionCommand("prepare"); prepareBtn.addActionListener(ac); Button executeBtn = new Button("Execute"); executeBtn.setActionCommand("execute"); executeBtn.addActionListener(ac); Button commitBtn = new Button("Commit"); commitBtn.setActionCommand("commit"); commitBtn.addActionListener(ac); Button rollbackBtn = new Button("Rollback"); rollbackBtn.setActionCommand("rollback"); rollbackBtn.addActionListener(ac); add(connectBtn); add(infoBtn); add(submitBtn); add(prepareBtn); add(executeBtn); add(commitBtn); add(rollbackBtn); }}class ApplicationController implements ActionListener { private Panel theView; public ApplicationController(Panel view) { this.theView = view; } public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("connect")) { TextArea x = ((CenterView)this.theView).getUpperPane().getTextArea(); TextArea y = ((CenterView)this.theView).getLowerPane().getTextArea(); String toBeCopied = x.getText(); y.setText(toBeCopied); } if (e.getActionCommand().equals("info")) { System.out.println(e.getSource().toString()); } if (e.getActionCommand().equals("submit")) { System.out.println(e.getSource().toString()); } if (e.getActionCommand().equals("prepare")) { System.out.println(e.getSource().toString()); } if (e.getActionCommand().equals("execute")) { System.out.println(e.getSource().toString()); } if (e.getActionCommand().equals("commit")) { System.out.println(e.getSource().toString()); } if (e.getActionCommand().equals("rollback")) { System.out.println(e.getSource().toString()); } }}