package jb_app_kjv;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import javax.swing.border.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class Main_class
extends JFrame {
JPanel contentPane;
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenuFile = new JMenu();
JMenuItem jMenuFileExit = new JMenuItem();
BorderLayout borderLayout1 = new BorderLayout();
JMenuItem jMenuBook = new JMenuItem();
JMenuItem jMenuAbout = new JMenuItem();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
FlowLayout flowLayout2 = new FlowLayout();
JPanel jPanel3 = new JPanel();
ImageIcon image1;
JLabel imageLabel = new JLabel();
JLabel jLabel1 = new JLabel();
XYLayout xYLayout1 = new XYLayout();
Border border1;
//Construct the frame
public Main_class() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel)this.getContentPane();
image1 = new
ImageIcon(jb_app_kjv.Main_class.class.getResource(
"ingraphic1.gif"));
border1 = BorderFactory.createEmptyBorder();
contentPane.setLayout(borderLayout1);
this.getContentPane().setBackground(SystemColor.control);
this.setContentPane(contentPane);
this.setEnabled(true);
this.setResizable(false);
this.setSize(new Dimension(469, 359));
this.setState(Frame.NORMAL);
this.setTitle("Main ...");
jMenuFile.setFont(new java.awt.Font("Times
New Roman", 1, 11));
jMenuFile.setActionCommand("Main Menu");
jMenuFile.setText("Main Menu");
jMenuFileExit.setFont(new
java.awt.Font("Times New Roman", 1, 11));
jMenuFileExit.setText("Exit");
jMenuFileExit.addActionListener(new
Main_class_jMenuFileExit_ActionAdapter(this));
jMenuBar1.setFont(new java.awt.Font("Times
New Roman", 0, 11));
jMenuBook.setFont(new java.awt.Font("Times
New Roman", 1, 11));
jMenuBook.setActionCommand("Book");
jMenuBook.setText("Book");
jMenuBook.addActionListener(new
Main_class_jMenuBook_actionAdapter(this));
jMenuAbout.setFont(new java.awt.Font("Times
New Roman", 1, 11));
jMenuAbout.setText("About");
jMenuAbout.addActionListener(new
Main_class_jMenuAbout_actionAdapter(this));
jPanel1.setLayout(xYLayout1);
jPanel2.setLayout(flowLayout2);
jPanel1.setBackground(SystemColor.control);
jPanel1.setAlignmentY( (float) 0.5);
jPanel1.setDebugGraphicsOptions(DebugGraphics.LOG_OPTION);
jPanel1.setOpaque(true);
jPanel1.setPreferredSize(new Dimension(100,
100));
jPanel2.setBackground(SystemColor.control);
jPanel2.setDebugGraphicsOptions(DebugGraphics.LOG_OPTION);
jPanel2.setPreferredSize(new Dimension(50,
50));
jPanel3.setBackground(SystemColor.control);
image1.setDescription("");
imageLabel.setIcon(image1);
jLabel1.setFont(new java.awt.Font("Times New
Roman", 3, 13));
jLabel1.setBorder(border1);
jLabel1.setDebugGraphicsOptions(0);
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel1.setText("Welcome to JB_App_KJV
learn how to write a Borland JBuilder X
Application");
contentPane.setMaximumSize(new
Dimension(2147483647, 2147483647));
jMenuFile.add(jMenuBook);
jMenuFile.addSeparator();
jMenuFile.add(jMenuAbout);
jMenuFile.addSeparator();
jMenuFile.add(jMenuFileExit);
jMenuBar1.add(jMenuFile);
contentPane.add(jPanel2, BorderLayout.NORTH);
contentPane.add(jPanel1, BorderLayout.SOUTH);
jPanel1.add(jLabel1, new
XYConstraints(10, 36, 442, -1));
contentPane.add(jPanel3, BorderLayout.CENTER);
jPanel3.add(imageLabel, null);
this.setJMenuBar(jMenuBar1);
}
//File | Exit action performed
public void
jMenuFileExit_actionPerformed(ActionEvent e) {
System.exit(0);
}
//Overridden so we can exit when window is
closed
protected void processWindowEvent(WindowEvent
e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING)
{
jMenuFileExit_actionPerformed(null);
}
}
void jMenuAbout_actionPerformed(ActionEvent e) {
Main_class_AboutBox dlg = new
Main_class_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.pack();
dlg.show();
}
void jMenuBook_actionPerformed(ActionEvent e) {
Book_Frame BookFrame = new Book_Frame()
;
BookFrame.pack();
//Center the window
Dimension screenSize =
Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize =
BookFrame.getPreferredSize();
if (frameSize.height >
screenSize.height)
frameSize.height =
screenSize.height;
if (frameSize.width > screenSize.width)
frameSize.width = screenSize.width;
BookFrame.setLocation((screenSize.width
- frameSize.width) / 2, (screenSize.height -
frameSize.height) / 2);
BookFrame.show() ;
}
}
class Main_class_jMenuFileExit_ActionAdapter
implements ActionListener {
Main_class adaptee;
Main_class_jMenuFileExit_ActionAdapter(Main_class
adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuFileExit_actionPerformed(e);
}
}
class Main_class_jMenuAbout_actionAdapter
implements
java.awt.event.ActionListener {
Main_class adaptee;
Main_class_jMenuAbout_actionAdapter(Main_class
adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuAbout_actionPerformed(e);
}
}
class Main_class_jMenuBook_actionAdapter
implements java.awt.event.ActionListener {
Main_class adaptee;
Main_class_jMenuBook_actionAdapter(Main_class
adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuBook_actionPerformed(e);
}
}
|