//Title: Hello World //Version: //Copyright: Copyright (c) 1997 //Author: Vesa Lappalainen //Company: jyu //Description:Eka Java-ohjelma package Hello; import java.awt.*; import java.awt.event.*; import borland.jbcl.control.*; import borland.jbcl.layout.*; public class cHelloFrame extends DecoratedFrame { BorderLayout borderLayout1 = new BorderLayout(); XYLayout xYLayout2 = new XYLayout(); BevelPanel bevelPanel1 = new BevelPanel(); MenuBar menuBar1 = new MenuBar(); Menu menuFile = new Menu(); MenuItem menuFileExit = new MenuItem(); Menu menuHelp = new Menu(); MenuItem menuHelpAbout = new MenuItem(); ButtonBar buttonBar = new ButtonBar(); StatusBar statusBar = new StatusBar(); //Construct the frame public cHelloFrame() { try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } //Component initialization public void jbInit() throws Exception{ this.setLayout(borderLayout1); this.setSize(new Dimension(400, 300)); this.setTitle("Hello World"); menuFile.setLabel("File"); menuFileExit.setLabel("Exit"); menuFileExit.addActionListener(new cHelloFrame_menuFileExit_ActionAdapter(this)); menuHelp.setLabel("Help"); menuHelpAbout.setLabel("About"); menuHelpAbout.addActionListener(new cHelloFrame_menuHelpAbout_ActionAdapter(this)); buttonBar.setButtonType(ButtonBar.IMAGE_ONLY); buttonBar.setLabels(new String[] {"File", "Close", "Help"}); buttonBar.setImageBase("image"); buttonBar.setImageNames(new String[] {"openFile.gif", "closeFile.gif", "help.gif"}); bevelPanel1.setLayout(xYLayout2); menuFile.add(menuFileExit); menuHelp.add(menuHelpAbout); menuBar1.add(menuFile); menuBar1.add(menuHelp); this.setMenuBar(menuBar1); this.add(buttonBar, BorderLayout.NORTH); this.add(statusBar, BorderLayout.SOUTH); this.add(bevelPanel1, BorderLayout.CENTER); } //File | Exit action performed public void fileExit_actionPerformed(ActionEvent e) { System.exit(0); } //Help | About action performed public void helpAbout_actionPerformed(ActionEvent e) { cHelloFrame_AboutBox dlg = new cHelloFrame_AboutBox(this); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.show(); } } class cHelloFrame_menuFileExit_ActionAdapter implements ActionListener { cHelloFrame adaptee; cHelloFrame_menuFileExit_ActionAdapter(cHelloFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.fileExit_actionPerformed(e); } } class cHelloFrame_menuHelpAbout_ActionAdapter implements ActionListener { cHelloFrame adaptee; cHelloFrame_menuHelpAbout_ActionAdapter(cHelloFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.helpAbout_actionPerformed(e); } } class cHelloFrame_AboutBox extends Dialog implements ActionListener { Panel panel1 = new Panel(); BevelPanel bevelPanel1 = new BevelPanel(); cHelloFrame_InsetsPanel insetsPanel1 = new cHelloFrame_InsetsPanel(); cHelloFrame_InsetsPanel insetsPanel2 = new cHelloFrame_InsetsPanel(); cHelloFrame_InsetsPanel insetsPanel3 = new cHelloFrame_InsetsPanel(); Button button1 = new Button(); ImageControl imageControl1 = new ImageControl(); Label label1 = new Label(); Label label2 = new Label(); Label label3 = new Label(); Label label4 = new Label(); BorderLayout borderLayout1 = new BorderLayout(); BorderLayout borderLayout2 = new BorderLayout(); FlowLayout flowLayout1 = new FlowLayout(); GridLayout gridLayout1 = new GridLayout(); String product = "Hello World"; String version = ""; String copyright = "Copyright (c) 1997"; String comments = "Eka Java-ohjelma"; public cHelloFrame_AboutBox(Frame parent) { super(parent); try { jbInit(); } catch (Exception e) { e.printStackTrace(); } pack(); } void jbInit() throws Exception{ this.setTitle("About"); setResizable(false); panel1.setLayout(borderLayout1); bevelPanel1.setLayout(borderLayout2); insetsPanel2.setLayout(flowLayout1); insetsPanel2.setInsets(new Insets(10, 10, 10, 10)); gridLayout1.setRows(4); gridLayout1.setColumns(1); label1.setText(product); label2.setText(version); label3.setText(copyright); label4.setText(comments); insetsPanel3.setLayout(gridLayout1); insetsPanel3.setInsets(new Insets(10, 60, 10, 10)); button1.setLabel("OK"); button1.addActionListener(this); imageControl1.setImageName(""); insetsPanel2.add(imageControl1, null); bevelPanel1.add(insetsPanel2, BorderLayout.WEST); this.add(panel1, null); insetsPanel3.add(label1, null); insetsPanel3.add(label2, null); insetsPanel3.add(label3, null); insetsPanel3.add(label4, null); bevelPanel1.add(insetsPanel3, BorderLayout.CENTER); insetsPanel1.add(button1, null); panel1.add(insetsPanel1, BorderLayout.SOUTH); panel1.add(bevelPanel1, BorderLayout.NORTH); pack(); } public void actionPerformed(ActionEvent e) { if (e.getSource() == button1) { setVisible(false); dispose(); } } } class cHelloFrame_InsetsPanel extends Panel { protected Insets insets; public Insets getInsets() { return insets == null ? super.getInsets() : insets; } public void setInsets(Insets insets) { this.insets = insets; } }