Before I "left" I wasn't THAT good either, but still:P
Ok so here is the deal
This is not homework, but it's an assignment I'm making for school.(I created the idea myself)
Here is what I'm trying to make:
I'm trying to make a Family Tree program, the user will be able to save the tree in a database.
Here some kind of graphical explanation:

New Family Button:
So once the user runs the program he will have an empty screen, once he presses the NEW FAMILY button, the pop up window will appear, and there the user will be able to fill in some things.
Once the user presses OK, a tree will be created (Graphically).
Each persons window will have the button to modify and to create a child, and the children will have the same buttons.
Save tree button:
The tree will be saved in a database(Somehow....)
Load tree button:
The tree will be retrieved from the database (somehow...)
Message window
The message window will show some messages(Not really important, but more user friendly.
Since I'm a "noob" at Java/Programming I tried to keep it as simple as possible.
But of course, if anyone has some ideas/remarks, they are all welcome to shed some light.
So I guess that is about it.
I only gave the description of my work in the first post, I will start with the problem(s) in the next post(s).
That way there is a better overview in my opinion.
I guess the problem should be really easy to solve.
I'm having trouble with the content pane.
package familytree;
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class MainWindow {
private Container contentPane;
private JTextField messageField;
private JButton newFamily, saveTree, loadTree;
public MainWindow() {
}
public void createPane() {
contentPane = new Container();
contentPane.setSize(200, 700);
contentPane.setLocation(600, 0);
messageField = new JTextField();
messageField.setEditable(false);
messageField.setBounds(25, 550, 150, 150);
messageField.setVisible(false);
contentPane.add(messageField);
newFamily = new JButton();
newFamily.setName("New Tree");
newFamily.setBounds(100, 100, 50, 25);
newFamily.setVisible(false);
contentPane.add(newFamily);
saveTree = new JButton();
saveTree.setName("Save");
saveTree.setBounds(100, 225, 50, 25);
saveTree.setVisible(true);
contentPane.add(saveTree);
loadTree = new JButton();
loadTree.setName("Load");
loadTree.setBounds(100, 350, 50, 25);
loadTree.setVisible(true);
contentPane.add(loadTree);
}
public void createFrame() {
JFrame frame = new JFrame();
frame.setTitle("Family Tree");
frame.setSize(800, 800);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setVisible(true);
frame.getContentPane();
contentPane.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
MainWindow run = new MainWindow();
run.createFrame();
}
});
}
}
Error
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at familytree.Mainwindow.createFrame(Mainwindow.java:56)
at familytree.MainWindow$1.run(Mainwindow.java:64)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
BUILD SUCCESSFUL (total time: 2 seconds)
Note that any remarks about the code are also very welcome.
Always trying to learn the "best" ways of coding.

New Topic/Question
Reply




MultiQuote











|