djdanjo82 0 Newbie Poster

Hi All!

This forum looks refreshing. This will be my first post and I am a new software guy working on a Java Gui issue. I recently built a java graph class and the graph works nice.

The Graph class was lineonly, and it extends JPanel. In the main function I created a JFrame and placed the lineonly object "line graph" inside the JFrame and it displayed great. Now I want this object or just the JPanel to go to my other larger gui or gui class to display the line graph in an emply JPanel slot. This new gui has multiple other JPanels nested together using NetBeans as well. Both Frames work well separately. The code gets a little messy since it was auto generated. I will display pieces of it.

//snippet of code from main that transfers JPanel to the Main Gui Class
public static void main(String[ ] args)
{
DmGui gui = new DmGui(); //create constructor from Main Gui
JFrame fram = jfrm(); //local JFrame created
JPanel lo = new JPanel(); //create line graph constuctor as JPanel
fram.add(lo); //place local line graph in local Frame
fram.setVisible(true); //Local line graph does work
gui.JPanel(lo); //send local JPanel to main gui class

//code snippet from the large gui class
//This method brings in the JPanel
lineonly lineonly = new lineonly();
public void JPanel(JPanel lo){
this.lo = lo;
initComponents(lo); //send the JPanel to the init method
} //The init method contains the layout
//code

//This is snippet of layout code
lo.setMaximumSize(new java.awt.Dimension(550, 350));
lo.setMinimumSize(new java.awt.Dimension(400, 200));
lo.setName("lo"); // NOI18N
lo.setPreferredSize(new java.awt.Dimension(550, 350));
lo.setRequestFocusEnabled(false);
lo.setVerifyInputWhenFocusTarget(false);

//This is snippet of my errors
Exception in thread "main" java.lang.NullPointerException
DmoGui.initComponents(DmoGui.java:582)
DmoGui.(DmoGui.java:100)
DmoDisplay.(DmoDisplay.java:22)
DmoMain.setupDisplay(DmoMain.java:208)
DmoMain.init(DmoMain.java:100)
DmoMain.(DmoMain.java:70)
DmoMain.main(DmoMain.java:258)

I think this in theory should work. For some reason no matter what I try
it just does not work. The NetBeans layout code makes it difficult to
customize as well. Any suggestions, comments, or solutions would be
appreciated.

Thanks a lot friends!

Dan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.