This discussion is archived
4 Replies Latest reply: Dec 9, 2008 3:44 AM by 800557 RSS

org.netbeans.lib.awtextra does not exist

807581 Newbie
Currently Being Moderated
when I compile the following code using javac
I get, org.netbeans.lib.awtextra does not exist

I tried adding the library using the import statement,
and verified that org.netbeans.lib.awtextra exists within the sources folder in my C:\Sun\jstudio_04Q4\Ent04_Q4 directory

(btw, it doesn't work completely when I compile it within the studio, because of problems I am having with the connection wizard, within the GUI editor

here are my compile errors

C:\Documents and Settings\dale\Desktop\JFrame.java:29: package org.netbeans.lib.awtextra does not exist
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
^
C:\Documents and Settings\dale\Desktop\JFrame.java:43: package org.netbeans.lib.awtextra does not exist
getContentPane().add(jSlider1, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 180, -1, -1));
^
C:\Documents and Settings\dale\Desktop\JFrame.java:45: package org.netbeans.lib.awtextra does not exist
getContentPane().add(jProgressBar1, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 230, -1, -1));
^
Note: C:\Documents and Settings\dale\Desktop\JFrame.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors

Tool completed with exit code 1


HERE IS MY CODE
/*
 * JFrame.java
 *
 * Created on April 19, 2005, 6:09 PM
 */

/**
 *
 * @author  dale
 */


public class JFrame extends javax.swing.JFrame {

    /** Creates new form JFrame */
    public JFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {
        jSlider1 = new javax.swing.JSlider();
        jProgressBar1 = new javax.swing.JProgressBar();

        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        jSlider1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jSlider1PropertyChange(evt);
            }
        });

        getContentPane().add(jSlider1, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 180, -1, -1));

        getContentPane().add(jProgressBar1, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 230, -1, -1));

        pack();
    }

    private void jSlider1PropertyChange(java.beans.PropertyChangeEvent evt) {
        jProgressBar1.setValue(jSlider1.getValue());
    }

    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {
        System.exit(0);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        new JFrame().show();
    }

    // Variables declaration - do not modify
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JSlider jSlider1;
    // End of variables declaration

}
  • 1. Re: org.netbeans.lib.awtextra does not exist
    807581 Newbie
    Currently Being Moderated
    when I compile the following code using javac
    I get, org.netbeans.lib.awtextra does not exist
    I tried adding the library using the import
    statement,
    and verified that org.netbeans.lib.awtextra exists
    within the sources folder in my
    C:\Sun\jstudio_04Q4\Ent04_Q4 directory
    It isn't enough. When the compiler needs type information, it looks for a source file or class file which defines the type. So put libraries you need into classpath.
    Here is compiler's documentation:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/javac.html
  • 2. Re: org.netbeans.lib.awtextra does not exist
    807581 Newbie
    Currently Being Moderated
    My Code is,





    public class Login extends javax.swing.JFrame {


    public Login()
    {
    initComponents ();
    pack ();
    }

    private void initComponents ()
    {

    JButton jButton1;
    pane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    button = new JButton("Button 1");
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 0;
    pane.add(button, c);






    /* jButton1 = new javax.swing.JButton ();

    jLabel1 = new javax.swing.JLabel ();
    jLabel2 = new javax.swing.JLabel ();
         jLabel3 = new javax.swing.JLabel ();
    jTextField2 = new javax.swing.JTextField ();
    jPasswordField1 = new javax.swing.JPasswordField ();

    getContentPane ().setLayout (new org.netbeans.lib.awtextra.AbsoluteLayout ());
    */

    setTitle ("Login Page");
    setLocation(340,350);

    addWindowListener (new java.awt.event.WindowAdapter () {
    public void windowClosing (java.awt.event.WindowEvent evt) {
    exitForm (evt);
    }
    }
    );

    // jButton1.setToolTipText ("Login into Server Area");
    //
    // jButton1.setText ("login");

    // jButton1.addActionListener (new java.awt.event.ActionListener () {
    public void actionPerformed (java.awt.event.ActionEvent evt){
    jButton1ActionPerformed (evt);
    }
    }
    );

    // jLabel3.setIcon (new javax.swing.ImageIcon ("prospy1.jpg"));
    // getContentPane ().add (jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints (0, 0, 300, 28));

    // jLabel1.setText ("Login Name");
    // jLabel2.setText ("Password");
    //
    // getContentPane ().add (jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints (20, 30, 90, 30));

    // getContentPane ().add (jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints (20, 70, 80, 30));


    // getContentPane ().add (jTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints (120, 30, 170, 30));


    // getContentPane ().add (jPasswordField1, new org.netbeans.lib.awtextra.AbsoluteConstraints (120, 70, 170, 30));


    // getContentPane ().add (jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints (120, 110, 90, 30));

    }

    private void jButton1ActionPerformed (java.awt.event.ActionEvent evt)
    {
    String login_name=jTextField2.getText();
    String pass_word=new String(jPasswordField1.getPassword());
    try
    {
    if(login_name.equalsIgnoreCase("admin") && pass_word.equalsIgnoreCase("admin"))
    {
         
    dispose();mainobj=new XMLServer();
    }
         else
    javax.swing.JOptionPane.showMessageDialog(null,"Invalid Login ID/Password","Error",javax.swing.JOptionPane.WARNING_MESSAGE);
    }
    catch(Exception exp)
         {}
    }

    private void exitForm(java.awt.event.WindowEvent evt) {
    System.exit (0);
    }

    public static void main(String args[])
    {
    new Login().show();
    }


    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JPasswordField jPasswordField1;
    XMLServer mainobj;


    }





    when i compile this file i got the error as,





    ^ ��
    Login.java:51: package org.netbeans.lib.awtextra does not exist ��
    getContentPane ().add (jTextField2, new org.netbeans.lib.awtextra.Absolu
    teConstraints (120, 30, 170, 30)); ��



    Plz reply soon
  • 3. Re: org.netbeans.lib.awtextra does not exist
    807581 Newbie
    Currently Being Moderated
    org.netbeans.lib.awtextra is part of the AbsoluteLayout library. It should be added automatically by the ide whenever absolutelayout is used in the form. But if you switch to some other layout after using absolute layout, then the jar/library will be removed from the classpath and existing code making calls to the library will not compile.

    - If you would like to use absolute layout, then please include the library in the project. Select 'Libraries' node in the project, right-click and select 'Add Library' and select 'Absolute Layout' library from the list of available libraries.

    - If you do not wish to use absolute layout, then it is best to uncomment/remove code relying on the library and re-do the form design using the new layout.
  • 4. Re: org.netbeans.lib.awtextra does not exist
    800557 Newbie
    Currently Being Moderated
    This happened to me recently. I use netbeans at home and at work, but as I've sent a new project I've developed at home to work, all these AbsoluteLayout calls were underlined because it couldn't find the library. Netbeans adds it automatically when you choose that layout in the GUI builder so all you need to do is to choose it again on the container and everything should be fixed.