0

I created a new project in Netbeans IDE 7.0.1. In that project I created a new JFrame form. But that frame is not loading.

Then I tried to run the program anyway and it gave the following exceptions:

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: 
  Uncompilable source code - package org.jdesktop.layout does not exist
at login.initComponents(login.java:33)
at login.<init>(login.java:20)
at login$1.run(login.java:78)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

I am using Ubuntu 12.10

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
AM26
  • 241
  • 1
  • 8
  • 24

2 Answers2

0

Looks like you have to add the Swing Layout Extensions Library to your project, to do so go to the Projects explorer, do right-click on Libraries > Add Library... and select Swing Layout Extensions Library. Problem solved.

BTW this is a Duplicate from https://stackoverflow.com/questions/19304700/netbeans-jframes-do-not-work

Community
  • 1
  • 1
Pablo Recalde
  • 3,334
  • 1
  • 22
  • 47
-1

Example:

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class App {

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable(){
        public void run(){
            JFrame frame = new JFrame("Hello world");

            frame.setVisible(true);
            frame.setSize(600,500);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
    });
}

}

e.doroskevic
  • 2,129
  • 18
  • 25
  • @AndrewThompson where in the question does it say that it has to import it. The answer has been given to add clarity to the user who asked a question on how to run JFrame. Additionally the example above is for reference. – e.doroskevic Jan 16 '14 at 11:21
  • 1
    *"where in the question does it say that it has to import it."* Read the 2nd line of the output. It was the **first line** until I manually inserted a line break. See also my comment which was made a minute before yours.. – Andrew Thompson Jan 16 '14 at 11:26
  • I Followed your example ,and its working when I am running the codes..But the jframe is not loading in the design.. E.Doroskevic – AM26 Jan 16 '14 at 11:35
  • 1
    and frame.setVisible(true); should be last code line, after sizing is done – mKorbel Jan 16 '14 at 11:38
  • In NetBeans and under your project in question under your projects tab, right click on the folder named Libraries. Click on "Add Library" and then scroll to find "Swing Layout Extensions". Select "Swing Layout Extensions" and then click the "Add Library" button. The error should have gone away. @user3192893 – e.doroskevic Jan 16 '14 at 11:46