Help with calling a class file
Posted before without posting all my code which may be the reason i still can't get it to work :/
I really need help with calling this class file.
Main
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
public class Main extends JFrame implements ActionListener
{
private JPanel jPanelSouth;
private JPanel jPanelEast;
private JPanel jPanelWest;
private JPanel jPanelNorth;
private Container c;
private JPanel toolbar1;
JMenuItem menuSave, menuQuit, menuAbout, menuNew;
public static void main(String[] args)
{
Border myBorder = new Border();
}
public void actionPerformed(ActionEvent arg0)
{
}
}
Main calls border
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Border extends JFrame implements ActionListener
{
private JPanel jPanelCenter;
private JPanel jPanelSouth;
private JPanel jPanelEast;
private JPanel jPanelWest;
private JPanel jMenuNorth;
private static Container c;
private JPanel toolbar1;
JMenu menu, submenu;
JMenuItem menuSave, menuQuit, menuAbout, menuNew;
JCheckBoxMenuItem cbMenuItem;
JRadioButtonMenuItem rbMenuItem;
JFrame frame;
ActionListener actionListener;
publicJMenuBar menuBar;
public JFrame window = new JFrame("Border Layout");
public JLabel title;
public JButton screen1, screen2;
public Border()
{
c = window.getContentPane();
window.setDefaultCloseOperation(EXIT_ON_CLOSE);
c.setLayout(new BorderLayout());
jPanelCenter = new JPanel();
c.add(jPanelCenter, BorderLayout.CENTER);
jPanelCenter.setBackground(new Color(255,255,255));
jMenuNorth = new JPanel();
c.add(jMenuNorth, BorderLayout.NORTH);
jMenuNorth.setBackground(new Color(245,245,255));
menuBar = new JMenuBar();
menu = new JMenu ("File");
menuNew = new JMenuItem("New");
menu.add(menuNew);
menuNew.addActionListener(this);
menuBar.add(menu);
menuSave = new JMenuItem("Save");
menu.add(menuSave);
menuQuit = new JMenuItem("Quit");
menu.add(menuQuit);
menuQuit.addActionListener(this);
menuBar.add(menu);
menu = new JMenu ("Help");
menuAbout = new JMenuItem("About");
menu.add(menuAbout);
menuAbout.addActionListener(this);
menuBar.add(menu);
window.setJMenuBar(menuBar);
jPanelWest = new JPanel();
c.add(jPanelWest, BorderLayout.WEST);
jPanelWest.setBackground(new Color(245,245,255));
jPanelEast = new JPanel();
c.add(jPanelEast, BorderLayout.EAST);
jPanelEast.setPreferredSize(new Dimension(100,100));
jPanelEast.setBackground(new Color(245,245,255));
jPanelSouth = new JPanel();
c.add(jPanelSouth, BorderLayout.SOUTH);
/* jPanelSouth.setPreferredSize(new Dimension(150,150));
jPanelSouth.setBackground(new Color(255,255,255));*/
window.setSize(1024, 720);
window.setVisible(true);
}
public void actionPerformed(ActionEvent arg0)
{
if(arg0.getSource() == menuAbout)
{
about();
}
else if(arg0.getSource() == menuNew)
{
News();
}
else if(arg0.getSource() == menuQuit)
{
quit();
}
}
protected void News()
{
bmitest mybmitest = new bmitest();
}
protected void about()
{
JOptionPane.showMessageDialog(null,"This program is designed for the pupose" +
"of watching your weight\n or making it easier to watch your weight" +
" Version 1.0.0");
}
protected void quit()
{
System.exit(0);
}
}
I'm trying to get New to work to call this
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class bmitest extends JFrame
{
/**
*
*/
private static final long serialVersionUID = 1L;
public static void main(String[] args)
{
bmitest window = new bmitest();
window.setVisible(true);
}
// Declare and initialize instance variables that are
// referred to when the program is running.
private JTextField _mField= new JTextField(4); // height
private JTextField _kgField = new JTextField(4); // weight
private JTextField _bmiField = new JTextField(4); // BMI
public bmitest()
{
// Create button and add action listener.
JButton bmiButton = new JButton("Compute BMI");
bmiButton.addActionListener(new BMIListener());
// Set layout and add components.
JPanel content = new JPanel();
content.setLayout(new FlowLayout());
content.add(new JLabel("Weight in kilograms"));
content.add(_kgField);
content.add(new JLabel("Height in meters"));
content.add(_mField);
content.add(bmiButton);
content.add(new JLabel("Your BMI is"));
content.add(_bmiField);
// Set the window characteristics.
setContentPane(content);
setTitle("Body Mass Index");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack(); // Do layout.
setLocationRelativeTo(null);// Center window.
}
private class BMIListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
double kilograms = Double.parseDouble(_kgField.getText());
double meters= Double.parseDouble(_mField.getText());
intbmi= (int)computeBMI(kilograms, meters);
_bmiField.setText("" + bmi);
}
}
public static double computeBMI(double weight, double height)
{
return weight / (height*height);
}
}
When I click New on border, I want it to call bmitest which seems not to work and i can't figure it out.

