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.

[6159 byte] By [RobRob47a] at [2007-11-26 22:50:20]
# 1

I haven't read all your code but my advice is to sprinkle in a couple of

System.out.println("listener invoked") statements in your code and see

what happens. (or whatever text is applicable)

If the first System.out.println() prints fine but the second doesn't, add

some more of those in the middle until you've cornered the bug.

kind regards,

Jos

JosAHa at 2007-7-10 12:11:31 > top of Java-index,Java Essentials,New To Java...