M
mohed.haidar
Hello guys. I just wrote my first java program and i have a couple of
questions and a problem. I would be glad if someone can give me a
hand.
The questions :
1. How do i pack everything into i nice executable file for others
to run without the need to open a cmd prompt and typing java ... and
so on ?
2. How do you guys do when your looking for a command. Is there some
kind of registry online, or do you have books or do you just know it
all from the getgo ?
The problem is that, while the compailer doesn't complain, i still get
an error at runtime. The error staits
Exception in thread "main" java.lang.NullPointerException
at DiveLog.DiveLog.populateMettoMenu(DiveLog.java:76)
at DiveLog.DiveLog.<init>(DiveLog.java:38)
at DiveLog.DiveLog.main(DiveLog.java:15)
Press any key to continue . . .
and i cant get the program running.
The source looks like this
package DiveLog;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Metto
{
private JFrame mettoFrame;
private JTabbedPane mettoPane;
public static void main(String[] args)
{
Metto go = new Metto();
}
public Metto()
{
JFrame mettoFrame = new JFrame("Metto ligger långt efter");
mettoFrame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
mettoPane = new JTabbedPane(SwingConstants.RIGHT);
mettoPane.setBackground(Color.blue);
mettoPane.setForeground(Color.white);
populateMettoPane();
populateMettoMenu();
mettoFrame.getContentPane().add(mettoPane);
mettoFrame.pack();
mettoFrame.setSize(750, 650);
mettoFrame.setBackground(Color.white);
mettoFrame.setVisible(true);
}
private void populateMettoPane()
{
mettoPane.addTab("Tryck här",
null,
new press1(),
"Det här va inte så svårt");
mettoPane.addTab("Eller här",
null,
new press2(),
"Inte det här häller");
}
private void populateMettoMenu()
{
JMenuBar mb = new JMenuBar();
JMenu menu = new JMenu("File");
JMenuItem item = new JMenuItem("Exit");
item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
menu.add(item);
mb.add(menu);
mettoFrame.setJMenuBar(mb);
}
public class press1 extends JPanel
{
}
public class press2 extends JPanel
{
}
}
Thx in advance for any help you guys can give me. Mohamed Haidar.
questions and a problem. I would be glad if someone can give me a
hand.
The questions :
1. How do i pack everything into i nice executable file for others
to run without the need to open a cmd prompt and typing java ... and
so on ?
2. How do you guys do when your looking for a command. Is there some
kind of registry online, or do you have books or do you just know it
all from the getgo ?
The problem is that, while the compailer doesn't complain, i still get
an error at runtime. The error staits
Exception in thread "main" java.lang.NullPointerException
at DiveLog.DiveLog.populateMettoMenu(DiveLog.java:76)
at DiveLog.DiveLog.<init>(DiveLog.java:38)
at DiveLog.DiveLog.main(DiveLog.java:15)
Press any key to continue . . .
and i cant get the program running.
The source looks like this
package DiveLog;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Metto
{
private JFrame mettoFrame;
private JTabbedPane mettoPane;
public static void main(String[] args)
{
Metto go = new Metto();
}
public Metto()
{
JFrame mettoFrame = new JFrame("Metto ligger långt efter");
mettoFrame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
mettoPane = new JTabbedPane(SwingConstants.RIGHT);
mettoPane.setBackground(Color.blue);
mettoPane.setForeground(Color.white);
populateMettoPane();
populateMettoMenu();
mettoFrame.getContentPane().add(mettoPane);
mettoFrame.pack();
mettoFrame.setSize(750, 650);
mettoFrame.setBackground(Color.white);
mettoFrame.setVisible(true);
}
private void populateMettoPane()
{
mettoPane.addTab("Tryck här",
null,
new press1(),
"Det här va inte så svårt");
mettoPane.addTab("Eller här",
null,
new press2(),
"Inte det här häller");
}
private void populateMettoMenu()
{
JMenuBar mb = new JMenuBar();
JMenu menu = new JMenu("File");
JMenuItem item = new JMenuItem("Exit");
item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
menu.add(item);
mb.add(menu);
mettoFrame.setJMenuBar(mb);
}
public class press1 extends JPanel
{
}
public class press2 extends JPanel
{
}
}
Thx in advance for any help you guys can give me. Mohamed Haidar.