Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 463
  • Last Modified:

Exception in thread "AWT-EventQueue-

I got this error and i believe it is because the variable for the ClockPanel is not in the nitComponents. The problem i have is i am using NetBeans ans can't get it in there. Can someone help me with this?

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at my.reminder.ClockPanel.initComponents(ClockPanel.java:41)
        at my.reminder.ClockPanel.<init>(ClockPanel.java:31)
        at my.reminder.NewGuiPanel.<init>(NewGuiPanel.java:35)
        at my.reminder.NewGuiPanel$10.run(NewGuiPanel.java:334)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
0
Drop_of_Rain
Asked:
Drop_of_Rain
  • 4
  • 3
2 Solutions
 
objectsCommented:
you're referencing a null object, whats line 41
0
 
Drop_of_RainAuthor Commented:
I don't think these are being init, how do i get them into the init section of the code or what else needs to be done? What do i have to add to the GuiPanel to get the clock and date panel classes passed to it.


public class NewGuiPanel extends javax.swing.JFrame {
enum Mode {
CLOCK, ALARM, TIMER, DATE, AUDIO, REMINDERS, CUSTOM, SETUP
};

   private java.util.List<Mode> modes;
   private int modeIndex;
   private Mode currentMode;
   boolean alarmStarted = false;
   public String alarmTime;
   private javax.swing.JLabel timeDisplay;
   private ClockPanel clockPanel = new ClockPanel();
   private DatePanel datePanel = new DatePanel();
   
   /** Creates new form GuiPanel */
public NewGuiPanel() {
initComponents();

//initModes();
}
0
 
objectsCommented:
The error would be caused by  dateTimeDisplayPanel being null.
Make sure you create it before u use it
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Drop_of_RainAuthor Commented:
timeDisplayPanel = new javax.swing.JPanel(); This panel is in the GuiPanel  dateTimeDisplayPanel
Whar do we do about that, we need to get a reference of it or what?

dateTimeDisplayPanel.add(timeDisplayPanel);
0
 
objectsCommented:
not timeDisplayPanel, *dateTimeDisplayPanel* is not getting created.
0
 
Drop_of_RainAuthor Commented:
You know that 2 classes are being called into the GuiPanel class. In order for this to happen what needs to be done with code to all of the classes. Just tell me by showing me examples. In another profram i saw that called another panel into it, it called the contentPane into it like this:

        clockPanel = new ClockPanel();
        getContentPane().add(clockPanel, "Center");

Here is the code from the GuiPanel relating to dateTimeDisplayPanel


        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(dateTimeDisplayPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE)
                    .addComponent(PanelNamePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(modeDisplay, javax.swing.GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE)
                    .addComponent(buttonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(PanelNamePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dateTimeDisplayPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(modeDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
0
 
Drop_of_RainAuthor Commented:
I can't created that same panel twice, once for the ClockPanel class and once for the Datepanel class because that is what you are telling me to do. The error haven't gotten to the DatePanel class yet and the same thing is going to happen.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now