Please help me use this LookAndFeel in java.

I have downloaded quauqa-5.4.1.zip

I tried the following, but it's giving me exception in thread:-

package ch.randelshofer.quaqua;

class Account extends JFrame
{
   @SuppressWarnings("unchecked")

    public static void main (String [] fisd)
    {       
       Account acc=new Account();
       acc.setVisible(true);
       acc.setSize(900,600);

       java.awt.EventQueue.invokeLater(new Runnable()
       {
         public void run() {
             new Account().setVisible(true);
              try {
                System.setProperty(
                 "Quaqua.tabLayoutPolicy","wrap"
                         );
                  UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");
        }
             catch (Exception e)
        {
           System.err.println("Oops!  Something went wrong!");
        }
          }
       });
          }
}

Edited 3 Years Ago by Dani: Formatting fixed

What exception. Add a printStacktrace to that catch block and post that result.

I have a feeling, though, that's its a "classnotfound". Include the jarfile for that api on the classpath.

This Exception :(

C:\Users\User>java -cp quaqua.jar Account
Exception in thread "main" java.lang.NoClassDefFoundError: Account
Caused by: java.lang.ClassNotFoundException: Account
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Uhm, is Account (your class) supposed to be in the package "ch.randelshofer.quaqua"?

If it is, you need to call java from the directory that contains the "ch" directory (from the above package path) and use ch.randelshofer.quaqua.Account on the command line, not just Account.

You seemingly need to re-learn some of the basics (I can only assume you have been "learning" on an IDE, and so know next to nothing about how the JVM actually works).

Edited 6 Years Ago by masijade: n/a

Yes Account is class name. But is not in the package.
How to put Account in the package?

:( i know.. I'm not so good in java. It is my first time learning this. I have a school management project to submit by this month

Just need to give it a fresh look and unique look. I asked my java teacher to help me with this but he hasn't heard of quaqua.

I have less knowledge of this LookAndFeel. Just help me with this please.

This has nothing to do with "quaqua". It has to do with the fact that you declared that package in your class. If you don't want it in that package (and I'm fairly sure it shouldn't be), don't declare it as being in that package.

i did declare the package inside the class. It is giving that thread exception. let me show you the whole code for Account.java

/*
*@(#)Account.java
*
*Java Database Connectivity (JDBC)
*
*Description:Technologies maintained by the school like J2EE Technology,
*Open Source Technology, Networking Technology, Web Technology, etc.
*
*The Applet will allow the Administrator to Add, Delete, Modify and Update Account.
*

/*
sp_tables

CREATE TABLE LOGIN
(
    LOGIN_NAME NVARCHAR(10) UNIQUE NOT NULL,
    PASS NVARCHAR(6) NOT NULL,
    REPASS NVARCHAR(6) NOT NULL,
    LOGINID VARCHAR(20) NOT NULL
)

DROP TABLE LOGIN

SELECT * FROM login
*/

/*
 * @(#)Account.java
*/

package ch.randelshofer.quaqua;

//swing packages
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;

///import ch.randelshofer.quaqua.JSheet;
//import ch.randelshofer.quaqua.SheetEvent;
//import ch.randelshofer.quaqua.SheetListener;


//event packages
import java.awt.event.*;
import javax.swing.event.*;

//sql packages
import java.io.*;
import java.sql.*;


class Account extends JFrame implements ActionListener
{
    //OBJECT DECLARATION
    JPanel centerPanel,northPanel,southPanel,AccPanel,picturePanel,PanelOne;
    JLabel lbl,Title,User,error,error2,Password,Re_Password,User_Type,picture,ans,qn;
    JTextField txtUser,user;
    JToolBar tb;
    JPasswordField Pass,Re_Pass,txtAns,txt;
    JComboBox cmbUser_Type,cmbQn;
    JButton New,Save, Delete, Modify, Update, Fetch, Cancel, btn, btn2;

    //SQL OBJECTS

    Connection cn; //***** To establish database connection. *****//
    Statement st,st2; //***** To INSERT, UPDATE and DELETE. *****//
    ResultSet rs,rs2,rs3; //***** To perform SELECT. *****//
    boolean flag; //***** Returns true if SQL Connection has been established. *****//

    //SQL CONNECTION
    private boolean SqlConnect()
    {
        flag=false;
        try
        {
            //-----Register the driver for database connectivity-----//
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            System.out.println("Driver Registered Successfully!!");

            //------Initialize the connection class object------//
            cn=DriverManager.getConnection("Jdbc:Odbc:Fisd","sa","");
            System.out.println("Connection Established");

            //------Initialize the statement object--------//
            st=cn.createStatement();
            st2=cn.createStatement();
            System.out.println("Statement Created");

            flag=true;

            //To set LookAndFeel of Applet (Theme)
            //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
              //UIManager.setLookAndFeel(
              //    ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel()
              //);

              //UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");

             //UIManager.setLookAndFeel(QuaquaManager.getLookAndFeelClassName());

        }
        catch(Exception ex1)
        {
            flag=false;
        }
        return flag;
    }

    //BUSINESS LOGIC

    //Used to Enable or Disable Controls.
    private void EnableDisableControls(boolean flag)
    {
        Pass.setEditable(flag);
        Re_Pass.setEditable(flag);
        txtAns.setEditable(flag);
        //txtUser.setEditable(flag);
    }

    //Used to Clear Controls.
    private void ClearControls()
    {
        txtUser.setText("");
        Pass.setText("");
        Re_Pass.setText("");
        txtAns.setText("");
        cmbUser_Type.setSelectedItem("");
        cmbQn.setSelectedItem("");
    }

    //INIT FUNCTION
    Account()
    {
        add(getcenterPanel(),BorderLayout.CENTER);
        //add(getnorthPanel(),BorderLayout.NORTH);
        //add(getsouthPanel(),BorderLayout.SOUTH);
    }

    //NORTH PANEL

    /*JPanel getnorthPanel()
    {
        northPanel = new JPanel();

        Border br=BorderFactory.createLineBorder(Color.black,5);
        Border br2=BorderFactory.createTitledBorder(br,"");
        northPanel.setBorder(br2);

        northPanel.setBackground(new Color(0,0,204));

        //northPanel.add(getTitle());

        return northPanel;
    }*/

    //HEADER
    /*JLabel getTitle()
    {
        Title=new JLabel("ACCOUNT SETTINGS");

        Title.setFont(new Font("Footlight MT Light",Font.BOLD,30));
        Title.setForeground(Color.yellow);

        return Title;
    }*/

    //CENTER PANEL

    JPanel getcenterPanel()
    {
        centerPanel = new JPanel();

        Border br3=BorderFactory.createLineBorder(Color.black,5);
        Border br4=BorderFactory.createTitledBorder(br3,"");
        centerPanel.setBorder(br4);

        centerPanel.setBackground(new Color(255,255,153));

        centerPanel.setLayout(new BorderLayout());

        centerPanel.add(gettb(),BorderLayout.NORTH);
        centerPanel.add(getAccPanel(),BorderLayout.CENTER);
        centerPanel.add(getsouthPanel(),BorderLayout.SOUTH);
        //centerPanel.add(getpicturePanel(),BorderLayout.SOUTH);

        return centerPanel;
    }

    //PICTURE PANEL
    JPanel getpicturePanel()
    {
        picturePanel=new JPanel();

        picturePanel.setBackground(new Color(255,255,153));

        picturePanel.setLayout(new GridBagLayout());

        //ROW 1 ----------> PICTURE

        GridBagConstraints gbcpicture=new GridBagConstraints();
        gbcpicture.insets=new Insets(10,10,10,10);
        gbcpicture.gridx=1;
        gbcpicture.gridy=2;
        picturePanel.add(getpicture(), gbcpicture);

        return picturePanel;
    }

    //ROW 1
    JLabel getpicture()
    {
        picture=new JLabel("");
        //picture=new JLabel(new ImageIcon("loogin.png"));
        //picture=new JLabel(new ImageIcon("login.gif"));
        return picture;
    }

    //TOOLBAR
    JToolBar gettb()
    {
        tb=new JToolBar();

        //setRollover(boolean) is used to to make the edge of buttoons invisible, except the one under mouse pointer.
        tb.setRollover(true);
        tb.setBackground(new Color(255,255,153));
        tb.setLayout(new FlowLayout());

        tb.setBorderPainted(true);
        //tb.setFloatable(false);
        //tb.setOrientation(JToolBar.VERTICAL);

        // addSeparator() is used to create space between one or more icons.
        tb.addSeparator();
        tb.addSeparator();

        tb.add(getNew());
        tb.addSeparator();
        tb.addSeparator();

        tb.add(getSave());
        tb.addSeparator();
        tb.addSeparator();

        tb.add(getModify());
        tb.addSeparator();
        tb.addSeparator();

        tb.add(getUpdate());
        tb.addSeparator();
        tb.addSeparator();

        tb.add(getDelete());
        tb.addSeparator();
        tb.addSeparator();

        tb.add(getCancel());
        tb.addSeparator();
        tb.addSeparator();

        return tb;
    }

    JButton getNew()
    {
        New=new JButton(new ImageIcon("new.png"));
        New.setToolTipText("<html> <center> <font color=blue size=+1> New Account </font> </center> </html>");
        New.addActionListener(this);
        return New;
    }

    JButton getModify()
    {
        Modify=new JButton(new ImageIcon("modify.png"));
        Modify.setToolTipText("<html> <center> <font color=blue size=+1> Modify Account </font> </center> </html>");
        Modify.addActionListener(this);
        return Modify;
    }

    JButton getUpdate()
    {
        Update=new JButton(new ImageIcon("update.png"));
        Update.setToolTipText("<html> <center> <font color=blue size=+1> Update Account </font> </center> </html>");
        Update.addActionListener(this);
        return Update;
    }

    JButton getDelete()
    {
        Delete=new JButton(new ImageIcon("delete.png"));
        Delete.setToolTipText("<html> <center> <font color=blue size=+1> Delete Account </font> </center> </html>");
        Delete.addActionListener(this);
        return Delete;
    }

    JButton getSave()
    {
        Save=new JButton(new ImageIcon("save.png"));
        Save.setToolTipText("<html> <center> <font color=blue size=+1> Save Account </font> </center> </html>");
        Save.addActionListener(this);
        return Save;
    }

    JButton getCancel()
    {
        Cancel=new JButton(new ImageIcon("cancel.png"));
        Cancel.setToolTipText("<html> <center> <font color=blue size=+1> Cancel </font> </center> </html>");
        Cancel.addActionListener(this);
        return Cancel;
    }

    //ACCOUNT PANEL
    JPanel getAccPanel()
    {
        AccPanel=new JPanel();

        AccPanel.setBackground(new Color(255,255,153));

        AccPanel.setLayout(new GridBagLayout());

        //ROW 1 ----------> USERNAME

        GridBagConstraints gbcUser=new GridBagConstraints();
        gbcUser.insets=new Insets(0,0,15,15);
        gbcUser.gridx=1;
        gbcUser.gridy=1;
        gbcUser.fill=GridBagConstraints.BOTH;
        AccPanel.add(getUser(), gbcUser);

        GridBagConstraints gbctxtUser=new GridBagConstraints();
        gbctxtUser.insets=new Insets(0,0,15,15);
        gbctxtUser.gridx=2;
        gbctxtUser.gridy=1;
        gbctxtUser.fill=GridBagConstraints.BOTH;
        AccPanel.add(gettxtUser(), gbctxtUser);

        GridBagConstraints gbcbtn=new GridBagConstraints();
        gbcbtn.insets=new Insets(0,0,15,15);
        gbcbtn.gridx=3;
        gbcbtn.gridy=1;
        gbcbtn.fill=GridBagConstraints.BOTH;
        AccPanel.add(getbtn(), gbcbtn);

        GridBagConstraints gbcbtn2=new GridBagConstraints();
        gbcbtn2.insets=new Insets(0,0,15,15);
        gbcbtn2.gridx=3;
        gbcbtn2.gridy=1;
        gbcbtn2.fill=GridBagConstraints.BOTH;
        AccPanel.add(getbtn2(), gbcbtn2);

        //ROW 2 ------------> PASSWORD

        GridBagConstraints gbcPassword=new GridBagConstraints();
        gbcPassword.insets=new Insets(0,0,15,15);
        gbcPassword.gridx=1;
        gbcPassword.gridy=2;
        gbcPassword.fill=GridBagConstraints.BOTH;
        AccPanel.add(getPassword(), gbcPassword);

        GridBagConstraints gbcPass=new GridBagConstraints();
        gbcPass.insets=new Insets(0,0,15,15);
        gbcPass.gridx=2;
        gbcPass.gridy=2;
        gbcPass.fill=GridBagConstraints.BOTH;
        AccPanel.add(getPass(), gbcPass);

        //ROW 3 ----------------------- ERROR MESSAGE

        GridBagConstraints gbcerror=new GridBagConstraints();
        gbcerror.insets=new Insets(0,0,15,15);
        gbcerror.gridx=2;
        gbcerror.gridy=3;
        AccPanel.add(geterror(), gbcerror);

        //ROW 4 ----------------> RE-ENTER PASSWORD

        GridBagConstraints gbcRe_Password=new GridBagConstraints();
        gbcRe_Password.insets=new Insets(0,0,15,15);
        gbcRe_Password.gridx=1;
        gbcRe_Password.gridy=4;
        gbcRe_Password.fill=GridBagConstraints.BOTH;
        AccPanel.add(getRe_Password(), gbcRe_Password);

        GridBagConstraints gbcRe_Pass=new GridBagConstraints();
        gbcRe_Pass.insets=new Insets(0,0,15,15);
        gbcRe_Pass.gridx=2;
        gbcRe_Pass.gridy=4;
        gbcRe_Pass.fill=GridBagConstraints.BOTH;
        AccPanel.add(getRe_Pass(), gbcRe_Pass);

        //ROW 5 ----------------------- ERROR MESSAGE

        GridBagConstraints gbcerror2=new GridBagConstraints();
        gbcerror2.insets=new Insets(0,0,15,15);
        gbcerror2.gridx=2;
        gbcerror2.gridy=5;
        AccPanel.add(geterror2(), gbcerror2);

        //ROW 6 --------------> LOGIN TYPE (ADMINISTRATOR OR USER).

        GridBagConstraints gbcUser_Type=new GridBagConstraints();
        gbcUser_Type.insets=new Insets(0,0,15,15);
        gbcUser_Type.gridx=1;
        gbcUser_Type.gridy=6;
        gbcUser_Type.fill=GridBagConstraints.BOTH;
        AccPanel.add(getUser_Type(), gbcUser_Type);

        GridBagConstraints gbccmbUser_Type=new GridBagConstraints();
        gbccmbUser_Type.insets=new Insets(0,0,15,15);
        gbccmbUser_Type.gridx=2;
        gbccmbUser_Type.gridy=6;
        gbccmbUser_Type.fill=GridBagConstraints.BOTH;
        AccPanel.add(getcmbUser_Type(), gbccmbUser_Type);

        //ROW 7 -----------------------------> SECURITY QUESTION

        GridBagConstraints gbcqn=new GridBagConstraints();
        gbcqn.insets=new Insets(0,0,15,15);
        gbcqn.gridx=1;
        gbcqn.gridy=7;
        gbcqn.fill=GridBagConstraints.BOTH;
        AccPanel.add(getqn(), gbcqn);

        GridBagConstraints gbccmbQn=new GridBagConstraints();
        gbccmbQn.insets=new Insets(0,0,15,15);
        gbccmbQn.gridx=2;
        gbccmbQn.gridy=7;
        gbccmbQn.fill=GridBagConstraints.BOTH;
        AccPanel.add(getcmbQn(), gbccmbQn);

        //ROW 8 -----------------------------> SECURITY ANSWER

        GridBagConstraints gbcans=new GridBagConstraints();
        gbcans.insets=new Insets(0,0,15,15);
        gbcans.gridx=1;
        gbcans.gridy=8;
        gbcans.fill=GridBagConstraints.BOTH;
        AccPanel.add(getans(), gbcans);

        GridBagConstraints gbctxtAns=new GridBagConstraints();
        gbctxtAns.insets=new Insets(0,0,15,15);
        gbctxtAns.gridx=2;
        gbctxtAns.gridy=8;
        gbctxtAns.fill=GridBagConstraints.BOTH;
        AccPanel.add(gettxtAns(), gbctxtAns);

        AccPanel.setVisible(false);

        return AccPanel;
    }

    //ROW 1
    JLabel getUser()
    {
        User=new JLabel("User Name:   ");

        Font font=new Font("Cambria",Font.BOLD,18);
        User.setFont(font);
        User.setForeground(new Color(255,0,0));

        return User;
    }

    JTextField gettxtUser()
    {
        txtUser=new JTextField(25);

        txtUser.setFont(new Font("Arial",Font.BOLD,16));
        txtUser.setForeground(Color.blue);

        txtUser.setEditable(true);
        txtUser.addActionListener(this);

        return txtUser;
    }

    //ROW 2
    JLabel getPassword()
    {
        Password=new JLabel("Password:   ");

        Font fnt=new Font("Cambria",Font.BOLD,18);
        Password.setFont(fnt);
        Password.setForeground(new Color(255,0,0));

        return Password;
    }

    JPasswordField getPass()
    {
        Pass=new JPasswordField(25);

        Pass.setEchoChar('*');

        Pass.setEditable(false);

        Pass.setFont(new Font("Arial",Font.BOLD,16));
        Pass.setForeground(Color.blue);

        return Pass;
    }

    //ROW 3

    JLabel geterror()
    {
        error=new JLabel("* Password should be 6 characters");

        error.setFont(new Font("Cambria",Font.BOLD,18));
        error.setForeground(new Color(255,0,0));

        error.setVisible(false);

        return error;
    }

    //ROW 4

    JLabel getRe_Password()
    {
        Re_Password=new JLabel("Re-enter Password:  ");

        Re_Password.setFont(new Font("Cambria",Font.BOLD,18));
        Re_Password.setForeground(new Color(255,0,0));

        return Re_Password;
    }

    JPasswordField getRe_Pass()
    {
        Re_Pass=new JPasswordField(25);

        Re_Pass.setEchoChar('*');

        Re_Pass.setEditable(false);

        Re_Pass.setFont(new Font("Arial",Font.BOLD,16));
        Re_Pass.setForeground(Color.blue);

        return Re_Pass;
    }

    //ROW 5
    JLabel geterror2()
    {
        error2=new JLabel("* Password doesn't match!");

        error2.setFont(new Font("Cambria",Font.BOLD,18));
        error2.setForeground(new Color(255,0,0));

        error2.setVisible(false);

        return error2;
    }

    //ROW 6
    JLabel getUser_Type()
    {
        User_Type=new JLabel("User Type: ");

        User_Type.setFont(new Font("Cambria",Font.BOLD,18));
        User_Type.setForeground(new Color(255,0,0));

        return User_Type;
    }

    JComboBox getcmbUser_Type()
    {
        cmbUser_Type=new JComboBox();

        cmbUser_Type.addItem("");
        cmbUser_Type.addItem("ADMINISTRATOR");
        cmbUser_Type.addItem("USER");

        cmbUser_Type.setEditable(false);

        return cmbUser_Type;
    }

    JLabel getqn()
    {
        qn=new JLabel("Select a Security Question");

        qn.setFont(new Font("Cambria",Font.BOLD,18));
        qn.setForeground(new Color(255,0,0));

        return qn;
    }

    JComboBox getcmbQn()
    {
        cmbQn=new JComboBox();

        cmbQn.addItem("");
        cmbQn.addItem("Who was your childhood friend?");
        cmbQn.addItem("What is your neighbour's name?");
        cmbQn.addItem("What is your pet name?");
        cmbQn.addItem("Where is your hometown?");
        cmbQn.addItem("What is your boyfriend/girlfriend's name?");
        cmbQn.addItem("Who is your favourite author?");

        return cmbQn;
    }

    JLabel getans()
    {
        ans=new JLabel("Security Answer: ");

        ans.setFont(new Font("Cambria",Font.BOLD,18));
        ans.setForeground(new Color(255,0,0));

        return ans;
    }

    JPasswordField gettxtAns()
    {
        txtAns=new JPasswordField(10);

        txtAns.setEchoChar('×');

        txtAns.setFont(new Font("Arial",Font.BOLD,16));
        txtAns.setForeground(Color.blue);

        return txtAns;
    }

    JPasswordField gettxt()
    {
        txt=new JPasswordField(10);

        txt.setEchoChar('×');

        txt.setFont(new Font("Arial",Font.BOLD,16));
        txt.setForeground(Color.blue);

        return txt;
    }

    JTextField getuser()
    {
        user=new JTextField(10);

        user.setFont(new Font("Arial",Font.BOLD,16));
        user.setForeground(Color.blue);

        return user;
    }

    JButton getbtn()
    {
        btn=new JButton("Modify");

        btn.setBackground(new Color(0,153,255));
        btn.setFont(new Font("Footlight MT Light",Font.BOLD,18));

        btn.setVisible(false);

        btn.addActionListener(this);

        return btn;
    }

    JButton getbtn2()
    {
        btn2=new JButton("Delete");

        btn2.setBackground(new Color(0,153,255));
        btn2.setFont(new Font("Footlight MT Light",Font.BOLD,18));

        btn2.setVisible(false);

        btn2.addActionListener(this);

        return btn2;
    }

    //PIC PANEL

    JPanel getsouthPanel()
    {
        southPanel = new JPanel();

        southPanel.setBackground(new Color(255,255,153));

        //southPanel.setVisible(true);

        southPanel.add(getlbl());

        return southPanel;
    }

    //FOOTER
    JLabel getlbl()
    {
        lbl=new JLabel(new ImageIcon("login.png"));
        return lbl;
    }

    //ACTIONLISTENER
    public void actionPerformed(ActionEvent ex)
    {
        // To add new account
        if(ex.getSource()==New)
        {
            AccPanel.setVisible(true);
            southPanel.setVisible(false);
            btn.setVisible(false);
            btn2.setVisible(false);
            Save.setEnabled(true);

            try
            {
                if(SqlConnect()==true)
                {
                    EnableDisableControls(true);
                    txtUser.requestFocus();
                }
            }
            catch(Exception yh)
            {
                yh.printStackTrace();
            }
        }

        // To cancel all controls
        if(ex.getSource()==Cancel)
        {
            ClearControls();
            txtUser.requestFocus();
            Save.setEnabled(true);
            error.setVisible(false);
            error2.setVisible(false);
            btn.setVisible(false);
            btn2.setVisible(false);
        }

        // To alter password.
        if(ex.getSource()==Modify)
        {
            if(SqlConnect()==true)
            {
                btn.setVisible(true);
                AccPanel.setVisible(true);
                southPanel.setVisible(false);
                Save.setEnabled(false);
                EnableDisableControls(false);
                btn2.setVisible(false);
            }
        }

        else    if(ex.getSource()==btn)
        {
            try
            {
                String username=txtUser.getText();

                if(username.length() == 0)
                {
                    JOptionPane.showMessageDialog(null,"Username should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                    txtUser.requestFocus();
                }

                rs=st.executeQuery("SELECT * FROM login WHERE  LOGIN_NAME='"+txtUser.getText()+"'");

                boolean r=false;
                while(rs.next())
                {
                    r=true;
                }

                if(r==false)
                {
                    JOptionPane.showMessageDialog(null,"Invalid Username!","Login",JOptionPane.WARNING_MESSAGE);
                    EnableDisableControls(false);
                }

                else
                {
                    Object[]obj={"Who was your childhood friend?","What is your neighbour's name?","What is your pet name?",
                    "Where is your hometown?","What is your boyfriend/girlfriend's name","Who is your favourite author?"};

                    String s=(String)JOptionPane.showInputDialog(this,"Select your Security Question","Account Modifications",JOptionPane.PLAIN_MESSAGE,null,obj,getuser());
                    JOptionPane.showMessageDialog(null,gettxt(),"Account Modifications",JOptionPane.INFORMATION_MESSAGE);

                    rs=st.executeQuery("SELECT * FROM login WHERE  ANS='"+txt.getText()+"'");

                    boolean d=false;
                    while(rs.next())
                    {
                        d=true;
                    }

                    if(d==true)
                    {
                        JOptionPane.showMessageDialog(null,"Valid!","Field In Software Development",JOptionPane.INFORMATION_MESSAGE);
                        EnableDisableControls(true);
                        return;
                    }

                    else
                    {
                        JOptionPane.showMessageDialog(null,"Invalid!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                        EnableDisableControls(false);
                    }
                }
            }
            catch(Exception w)
            {
                w.printStackTrace();
            }
        }



        // To update changes.
        if(ex.getSource()==Update)
        {
            if(SqlConnect()==true)
            {
                try
                {
                    rs=st.executeQuery("SELECT * FROM login WHERE  LOGIN_NAME='"+txtUser.getText()+"'");

                    boolean x=false;
                    while(rs.next())
                    {
                        x=true;
                    }

                    if(x==false)
                    {
                        JOptionPane.showMessageDialog(null,"Username not found!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                    }

                    else
                    {
                        String use=txtUser.getText();
                        String pas=Pass.getText();
                        String repas=Re_Pass.getText();
                        String answe=txtAns.getText();
                        String typ=String.valueOf(cmbUser_Type.getSelectedItem());
                        String cmbq=String.valueOf(cmbQn.getSelectedItem());

                        if(use.length() == 0)
                        {
                            JOptionPane.showMessageDialog(null,"Username should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                            txtUser.requestFocus();
                        }

                        else if(use.length() > 10)
                        {
                            JOptionPane.showMessageDialog(null,"Username should NOT exceed 10 characters!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                            txtUser.requestFocus();
                        }

                        else if(pas.length() == 0)
                        {
                            JOptionPane.showMessageDialog(null,"Password should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                            Pass.requestFocus();
                        }

                        else if(repas.length() == 0)
                        {
                            JOptionPane.showMessageDialog(null,"Password should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                            Re_Pass.requestFocus();
                        }

                        else if(answe.length() == 0)
                        {
                            JOptionPane.showMessageDialog(null,"Password should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                            txtAns.requestFocus();
                        }

                        else if(pas.length() <=5 || pas.length() >6)
                        {
                            error.setVisible(true);
                        }

                        else if(repas.length() <=5 || repas.length() >6)
                        {
                            error.setVisible(true);
                        }

                        else if(repas!=pas)
                        {
                            if(typ.equals("") == true)
                            {
                                JOptionPane.showMessageDialog(null,"Please select User Type!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                                cmbUser_Type.requestFocus();
                            }

                            else if(cmbq.equals("") == true)
                            {
                                JOptionPane.showMessageDialog(null,"Please select User Type!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                                cmbQn.requestFocus();
                            }

                            else if(repas.equals(pas) || pas.equals(repas))
                            {
                                try
                                {
                                    Save.setEnabled(true);
                                    st.executeUpdate("update LOGIN set PASS='"+Pass.getText()+"'where LOGIN_NAME='"+txtUser.getText()+"'");
                                    st.executeUpdate("update LOGIN set REPASS='"+Re_Pass.getText()+"'where LOGIN_NAME='"+txtUser.getText()+"'");
                                    st.executeUpdate("update LOGIN set LOGINID='"+cmbUser_Type.getSelectedItem()+"'where LOGIN_NAME='"+txtUser.getText()+"'");
                                    st.executeUpdate("update LOGIN set QN='"+cmbQn.getSelectedItem()+"'where LOGIN_NAME='"+txtUser.getText()+"'");
                                    st.executeUpdate("update LOGIN set ANS='"+txtAns.getText()+"'where LOGIN_NAME='"+txtUser.getText()+"'");
                                    JOptionPane.showMessageDialog(null,"Account Updated!","Field In Software Development",JOptionPane.INFORMATION_MESSAGE);
                                    error2.setVisible(false);
                                    error.setVisible(false);
                                    ClearControls();
                                }
                                catch(Exception sa)
                                {
                                    JOptionPane.showMessageDialog(null,"Updating Failed!","Field In Software Development",JOptionPane.WARNING_MESSAGE);
                                }
                            }

                            else
                            {
                                error2.setVisible(true);
                                Pass.requestFocus();
                            }
                        }
                    }
                }
                catch(Exception jk)
                {
                    jk.printStackTrace();
                }
            }
        }

        // To remove account
        if(ex.getSource()==Delete)
        {
            if(SqlConnect()==true)
            {
                AccPanel.setVisible(true);
                southPanel.setVisible(false);
                btn2.setVisible(true);
                btn.setVisible(false);
                EnableDisableControls(false);
            }
        }

        else    if(ex.getSource()==btn2)
        {
            try
            {
                String usernam=txtUser.getText();

                if(usernam.length() == 0)
                {
                    JOptionPane.showMessageDialog(null,"Username should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                    txtUser.requestFocus();
                }

                rs=st.executeQuery("SELECT * FROM login WHERE  LOGIN_NAME='"+txtUser.getText()+"'");

                boolean q=false;
                while(rs.next())
                {
                    q=true;
                }

                if(q==false)
                {
                    JOptionPane.showMessageDialog(null,"Invalid Username!","Login",JOptionPane.WARNING_MESSAGE);
                    EnableDisableControls(false);
                }

                else
                {
                    Object[]obj={"Who was your childhood friend?","What is your neighbour's name?","What is your pet name?",
                    "Where is your hometown?","What is your boyfriend/girlfriend's name","Who is your favourite author?"};

                    String s=(String)JOptionPane.showInputDialog(this,"Select your Security Question","Account Modifications",JOptionPane.PLAIN_MESSAGE,null,obj,getuser());
                    JOptionPane.showMessageDialog(null,gettxt(),"Account Modifications",JOptionPane.INFORMATION_MESSAGE);

                    rs=st.executeQuery("SELECT ANS FROM LOGIN WHERE ANS=('"+txt.getText()+"')");

                    boolean h=false;
                    while(rs.next())
                    {
                        h=true;
                    }

                    if(h==true)
                    {
                        JOptionPane.showMessageDialog(null,"Valid!","Field In Software Development",JOptionPane.INFORMATION_MESSAGE);
                        st.executeUpdate("DELETE from LOGIN where LOGIN_NAME=('"+txtUser.getText()+"')");
                        JOptionPane.showMessageDialog(null,"Account Deleted!","Field In Software Development",JOptionPane.INFORMATION_MESSAGE);
                        ClearControls();
                    }

                    else
                    {
                        JOptionPane.showMessageDialog(null,"Invalid!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                        EnableDisableControls(false);
                    }
                }
            }
            catch(Exception u)
            {
                u.printStackTrace();
            }
        }

        // To add new account
        else if(ex.getSource()==Save)
        {
            if(SqlConnect()==true)
            {
                String user=txtUser.getText();
                String pass=Pass.getText();
                String repass=Re_Pass.getText();
                String answer=txtAns.getText();
                String type=String.valueOf(cmbUser_Type.getSelectedItem());
                String cmbqn=String.valueOf(cmbQn.getSelectedItem());

                if(user.length() == 0)
                {
                    JOptionPane.showMessageDialog(null,"Username should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                    txtUser.requestFocus();
                }

                else if(user.length() > 10)
                {
                    JOptionPane.showMessageDialog(null,"Username should NOT exceed 10 characters!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                    txtUser.requestFocus();
                }

                else if(pass.length() == 0)
                {
                    JOptionPane.showMessageDialog(null,"Password should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                    Pass.requestFocus();
                }

                else if(repass.length() == 0)
                {
                    JOptionPane.showMessageDialog(null,"Password should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                    Re_Pass.requestFocus();
                }

                else if(answer.length() == 0)
                {
                    JOptionPane.showMessageDialog(null,"Security Answer should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                    txtAns.requestFocus();
                }

                else if(pass.length() <=5 || pass.length() >6)
                {
                    error.setVisible(true);
                }

                else if(repass.length() <=5 || repass.length() >6)
                {
                    error.setVisible(true);
                }

                else if(repass!=pass)
                {
                    if(type.equals("") == true)
                    {
                        JOptionPane.showMessageDialog(null,"Please select User Type!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                        cmbUser_Type.requestFocus();
                    }

                    if(cmbqn.equals("") == true)
                    {
                        JOptionPane.showMessageDialog(null,"Please select User Type!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
                        cmbQn.requestFocus();
                    }

                    else if(repass.equals(pass) || pass.equals(repass))
                    {
                        try
                        {
                            st.executeUpdate("insert into LOGIN values('"+txtUser.getText()+ "','"+Pass.getText()+"' ,'"+Re_Pass.getText()+"' ,'"+String.valueOf(cmbUser_Type.getSelectedItem())+"','"+String.valueOf(cmbQn.getSelectedItem())+"','"+txtAns.getText()+"')");
                            JOptionPane.showMessageDialog(null,"Record added","Field In Software Development",JOptionPane.INFORMATION_MESSAGE);
                            error.setVisible(false);
                            error2.setVisible(false);
                            AccPanel.setVisible(false);
                            southPanel.setVisible(true);
                            EnableDisableControls(false);
                            ClearControls();
                        }
                        catch(Exception es)
                        {
                            es.printStackTrace();
                        }
                    }
                    else
                    {
                        error2.setVisible(true);
                        Pass.requestFocus();
                    }
                }
            }
        }
    }

    @SuppressWarnings("unchecked")

    public static void main (String [] fisd)
    {
        Account acc=new Account();
        acc.setVisible(true);
        acc.setSize(900,600);

        java.awt.EventQueue.invokeLater(new Runnable()
        {
            public void run() {
                new Account().setVisible(true);
              try {
                    System.setProperty(
                    "Quaqua.tabLayoutPolicy","wrap"
                    );
                    UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");
                    //UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");
                    //UIManager.setLookAndFeel("org.fife.plaf.OfficeXP.OfficeXPLookAndFeel");
                    //UIManager.setLookAndFeel("org.fife.plaf.VisualStudio2005.VisualStudio2005LookAndFeel");
                    }
                    catch (Exception e)
                    {
                         System.err.println("Oops!  Something went wrong!");
                    }
                }
            });
        }



        //System.setProperty(
        //    "Quaqua.tabLayoutPolicy","Leopard"
        //);

        //try
        //{
        //  UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");
        //}

        //catch(Exception g)
        //{
        //  g.printStackTrace();
        //}
    }

Edited 3 Years Ago by Dani: Formatting fixed

Please post your code inside of code tags.Use the icon above to right. Info here: http://www.java-forums.org/misc.php?do=bbcode#code

Your command line needs to include the current directory indicated by a .
C:\Users\User>java -cp .;quaqua.jar Account

Since your class is in a package, you also need to include the package path to the class file:
C:\Users\User>java -cp .;uaqua.jar ch.randelshofer.quaqua.Account

The package path folders must be in the current directory.

Edited 6 Years Ago by NormR1: n/a

/*
*@(#)Account.java
*
/*
sp_tables

CREATE TABLE LOGIN
(
	LOGIN_NAME NVARCHAR(10) UNIQUE NOT NULL,
	PASS NVARCHAR(6) NOT NULL,
	REPASS NVARCHAR(6) NOT NULL,
	LOGINID VARCHAR(20) NOT NULL
	QN VARCHAR (50) NOT NULL,
	ANS VARCHAR (30) NOT NULL
)

DROP TABLE LOGIN

SELECT * FROM login
*/

/*
 * @(#)Account.java
*/

package ch.randelshofer.quaqua;

//swing packages
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;

///import ch.randelshofer.quaqua.JSheet;
//import ch.randelshofer.quaqua.SheetEvent;
//import ch.randelshofer.quaqua.SheetListener;


//event packages
import java.awt.event.*;
import javax.swing.event.*;

//sql packages
import java.io.*;
import java.sql.*;


class Account extends JFrame implements ActionListener
{
	//OBJECT DECLARATION
	JPanel centerPanel,northPanel,southPanel,AccPanel,picturePanel,PanelOne;
	JLabel lbl,Title,User,error,error2,Password,Re_Password,User_Type,picture,ans,qn;
	JTextField txtUser,user;
	JToolBar tb;
	JPasswordField Pass,Re_Pass,txtAns,txt;
	JComboBox cmbUser_Type,cmbQn;
	JButton New,Save, Delete, Modify, Update, Fetch, Cancel, btn, btn2;

	//SQL OBJECTS

	Connection cn; //***** To establish database connection. *****//
	Statement st,st2; //***** To INSERT, UPDATE and DELETE. *****//
	ResultSet rs,rs2,rs3; //***** To perform SELECT. *****//
	boolean flag; //***** Returns true if SQL Connection has been established. *****//

	//SQL CONNECTION
	private boolean SqlConnect()
	{
		flag=false;
		try
		{
			//-----Register the driver for database connectivity-----//
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			System.out.println("Driver Registered Successfully!!");

			//------Initialize the connection class object------//
			cn=DriverManager.getConnection("Jdbc:Odbc:Fisd","sa","");
			System.out.println("Connection Established");

			//------Initialize the statement object--------//
			st=cn.createStatement();
			st2=cn.createStatement();
			System.out.println("Statement Created");

			flag=true;

			//To set LookAndFeel
			//UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
              //UIManager.setLookAndFeel(
              //    ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel()
              //);

              //UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");

             //UIManager.setLookAndFeel(QuaquaManager.getLookAndFeelClassName());

		}
		catch(Exception ex1)
		{
			flag=false;
		}
		return flag;
	}

	//BUSINESS LOGIC

	//Used to Enable or Disable Controls.
	private void EnableDisableControls(boolean flag)
	{
		Pass.setEditable(flag);
		Re_Pass.setEditable(flag);
		txtAns.setEditable(flag);
		//txtUser.setEditable(flag);
	}

	//Used to Clear Controls.
	private void ClearControls()
	{
		txtUser.setText("");
		Pass.setText("");
		Re_Pass.setText("");
		txtAns.setText("");
		cmbUser_Type.setSelectedItem("");
		cmbQn.setSelectedItem("");
	}

	//CONSTRUCTOR
	Account()
	{
		add(getcenterPanel(),BorderLayout.CENTER);
	}

	//CENTER PANEL

	JPanel getcenterPanel()
	{
		centerPanel = new JPanel();

		Border br3=BorderFactory.createLineBorder(Color.black,5);
		Border br4=BorderFactory.createTitledBorder(br3,"");
		centerPanel.setBorder(br4);

		centerPanel.setBackground(new Color(255,255,153));

		centerPanel.setLayout(new BorderLayout());

		centerPanel.add(gettb(),BorderLayout.NORTH);
		centerPanel.add(getAccPanel(),BorderLayout.CENTER);
		centerPanel.add(getsouthPanel(),BorderLayout.SOUTH);

		return centerPanel;
	}

	//TOOLBAR
	JToolBar gettb()
	{
		tb=new JToolBar();

		//setRollover(boolean) is used to to make the edge of buttoons invisible, except the one under mouse pointer.
		tb.setRollover(true);
		tb.setBackground(new Color(255,255,153));
		tb.setLayout(new FlowLayout());

		tb.setBorderPainted(true);
		//tb.setFloatable(false);
		//tb.setOrientation(JToolBar.VERTICAL);

		// addSeparator() is used to create space between one or more icons.
		tb.addSeparator();
		tb.addSeparator();

		tb.add(getNew());
		tb.addSeparator();
		tb.addSeparator();

		tb.add(getSave());
		tb.addSeparator();
		tb.addSeparator();

		tb.add(getModify());
		tb.addSeparator();
		tb.addSeparator();

		tb.add(getUpdate());
		tb.addSeparator();
		tb.addSeparator();

		tb.add(getDelete());
		tb.addSeparator();
		tb.addSeparator();

		tb.add(getCancel());
		tb.addSeparator();
		tb.addSeparator();

		return tb;
	}

	JButton getNew()
	{
		New=new JButton(new ImageIcon("new.png"));
		New.setToolTipText("<html> <center> <font color=blue size=+1> New Account </font> </center> </html>");
		New.addActionListener(this);
		return New;
	}

	JButton getModify()
	{
		Modify=new JButton(new ImageIcon("modify.png"));
		Modify.setToolTipText("<html> <center> <font color=blue size=+1> Modify Account </font> </center> </html>");
		Modify.addActionListener(this);
		return Modify;
	}

	JButton getUpdate()
	{
		Update=new JButton(new ImageIcon("update.png"));
		Update.setToolTipText("<html> <center> <font color=blue size=+1> Update Account </font> </center> </html>");
		Update.addActionListener(this);
		return Update;
	}

	JButton getDelete()
	{
		Delete=new JButton(new ImageIcon("delete.png"));
		Delete.setToolTipText("<html> <center> <font color=blue size=+1> Delete Account </font> </center> </html>");
		Delete.addActionListener(this);
		return Delete;
	}

	JButton getSave()
	{
		Save=new JButton(new ImageIcon("save.png"));
		Save.setToolTipText("<html> <center> <font color=blue size=+1> Save Account </font> </center> </html>");
		Save.addActionListener(this);
		return Save;
	}

	JButton getCancel()
	{
		Cancel=new JButton(new ImageIcon("cancel.png"));
		Cancel.setToolTipText("<html> <center> <font color=blue size=+1> Cancel </font> </center> </html>");
		Cancel.addActionListener(this);
		return Cancel;
	}

	//ACCOUNT PANEL
	JPanel getAccPanel()
	{
		AccPanel=new JPanel();

		AccPanel.setBackground(new Color(255,255,153));

		AccPanel.setLayout(new GridBagLayout());

		//ROW 1 ----------> USERNAME

		GridBagConstraints gbcUser=new GridBagConstraints();
		gbcUser.insets=new Insets(0,0,15,15);
		gbcUser.gridx=1;
		gbcUser.gridy=1;
		gbcUser.fill=GridBagConstraints.BOTH;
		AccPanel.add(getUser(), gbcUser);

		GridBagConstraints gbctxtUser=new GridBagConstraints();
		gbctxtUser.insets=new Insets(0,0,15,15);
		gbctxtUser.gridx=2;
		gbctxtUser.gridy=1;
		gbctxtUser.fill=GridBagConstraints.BOTH;
		AccPanel.add(gettxtUser(), gbctxtUser);

		GridBagConstraints gbcbtn=new GridBagConstraints();
		gbcbtn.insets=new Insets(0,0,15,15);
		gbcbtn.gridx=3;
		gbcbtn.gridy=1;
		gbcbtn.fill=GridBagConstraints.BOTH;
		AccPanel.add(getbtn(), gbcbtn);

		GridBagConstraints gbcbtn2=new GridBagConstraints();
		gbcbtn2.insets=new Insets(0,0,15,15);
		gbcbtn2.gridx=3;
		gbcbtn2.gridy=1;
		gbcbtn2.fill=GridBagConstraints.BOTH;
		AccPanel.add(getbtn2(), gbcbtn2);

		//ROW 2 ------------> PASSWORD

		GridBagConstraints gbcPassword=new GridBagConstraints();
		gbcPassword.insets=new Insets(0,0,15,15);
		gbcPassword.gridx=1;
		gbcPassword.gridy=2;
		gbcPassword.fill=GridBagConstraints.BOTH;
		AccPanel.add(getPassword(), gbcPassword);

		GridBagConstraints gbcPass=new GridBagConstraints();
		gbcPass.insets=new Insets(0,0,15,15);
		gbcPass.gridx=2;
		gbcPass.gridy=2;
		gbcPass.fill=GridBagConstraints.BOTH;
		AccPanel.add(getPass(), gbcPass);

		//ROW 3 ----------------------- ERROR MESSAGE

		GridBagConstraints gbcerror=new GridBagConstraints();
		gbcerror.insets=new Insets(0,0,15,15);
		gbcerror.gridx=2;
		gbcerror.gridy=3;
		AccPanel.add(geterror(), gbcerror);

		//ROW 4 ----------------> RE-ENTER PASSWORD

		GridBagConstraints gbcRe_Password=new GridBagConstraints();
		gbcRe_Password.insets=new Insets(0,0,15,15);
		gbcRe_Password.gridx=1;
		gbcRe_Password.gridy=4;
		gbcRe_Password.fill=GridBagConstraints.BOTH;
		AccPanel.add(getRe_Password(), gbcRe_Password);

		GridBagConstraints gbcRe_Pass=new GridBagConstraints();
		gbcRe_Pass.insets=new Insets(0,0,15,15);
		gbcRe_Pass.gridx=2;
		gbcRe_Pass.gridy=4;
		gbcRe_Pass.fill=GridBagConstraints.BOTH;
		AccPanel.add(getRe_Pass(), gbcRe_Pass);

		//ROW 5 ----------------------- ERROR MESSAGE

		GridBagConstraints gbcerror2=new GridBagConstraints();
		gbcerror2.insets=new Insets(0,0,15,15);
		gbcerror2.gridx=2;
		gbcerror2.gridy=5;
		AccPanel.add(geterror2(), gbcerror2);

		//ROW 6 --------------> LOGIN TYPE (ADMINISTRATOR OR USER).

		GridBagConstraints gbcUser_Type=new GridBagConstraints();
		gbcUser_Type.insets=new Insets(0,0,15,15);
		gbcUser_Type.gridx=1;
		gbcUser_Type.gridy=6;
		gbcUser_Type.fill=GridBagConstraints.BOTH;
		AccPanel.add(getUser_Type(), gbcUser_Type);

		GridBagConstraints gbccmbUser_Type=new GridBagConstraints();
		gbccmbUser_Type.insets=new Insets(0,0,15,15);
		gbccmbUser_Type.gridx=2;
		gbccmbUser_Type.gridy=6;
		gbccmbUser_Type.fill=GridBagConstraints.BOTH;
		AccPanel.add(getcmbUser_Type(), gbccmbUser_Type);

		//ROW 7 -----------------------------> SECURITY QUESTION

		GridBagConstraints gbcqn=new GridBagConstraints();
		gbcqn.insets=new Insets(0,0,15,15);
		gbcqn.gridx=1;
		gbcqn.gridy=7;
		gbcqn.fill=GridBagConstraints.BOTH;
		AccPanel.add(getqn(), gbcqn);

		GridBagConstraints gbccmbQn=new GridBagConstraints();
		gbccmbQn.insets=new Insets(0,0,15,15);
		gbccmbQn.gridx=2;
		gbccmbQn.gridy=7;
		gbccmbQn.fill=GridBagConstraints.BOTH;
		AccPanel.add(getcmbQn(), gbccmbQn);

		//ROW 8 -----------------------------> SECURITY ANSWER

		GridBagConstraints gbcans=new GridBagConstraints();
		gbcans.insets=new Insets(0,0,15,15);
		gbcans.gridx=1;
		gbcans.gridy=8;
		gbcans.fill=GridBagConstraints.BOTH;
		AccPanel.add(getans(), gbcans);

		GridBagConstraints gbctxtAns=new GridBagConstraints();
		gbctxtAns.insets=new Insets(0,0,15,15);
		gbctxtAns.gridx=2;
		gbctxtAns.gridy=8;
		gbctxtAns.fill=GridBagConstraints.BOTH;
		AccPanel.add(gettxtAns(), gbctxtAns);

		AccPanel.setVisible(false);

		return AccPanel;
	}

	//ROW 1
	JLabel getUser()
	{
		User=new JLabel("User Name:   ");

		Font font=new Font("Cambria",Font.BOLD,18);
		User.setFont(font);
		User.setForeground(new Color(255,0,0));

		return User;
	}

	JTextField gettxtUser()
	{
		txtUser=new JTextField(25);

		txtUser.setFont(new Font("Arial",Font.BOLD,16));
		txtUser.setForeground(Color.blue);

		txtUser.setEditable(true);
		txtUser.addActionListener(this);

		return txtUser;
	}

	//ROW 2
	JLabel getPassword()
	{
		Password=new JLabel("Password:   ");

		Font fnt=new Font("Cambria",Font.BOLD,18);
		Password.setFont(fnt);
		Password.setForeground(new Color(255,0,0));

		return Password;
	}

	JPasswordField getPass()
	{
		Pass=new JPasswordField(25);

		Pass.setEchoChar('*');

		Pass.setEditable(false);

		Pass.setFont(new Font("Arial",Font.BOLD,16));
		Pass.setForeground(Color.blue);

		return Pass;
	}

	//ROW 3

	JLabel geterror()
	{
		error=new JLabel("* Password should be 6 characters");

		error.setFont(new Font("Cambria",Font.BOLD,18));
		error.setForeground(new Color(255,0,0));

		error.setVisible(false);

		return error;
	}

	//ROW 4

	JLabel getRe_Password()
	{
		Re_Password=new JLabel("Re-enter Password:  ");

		Re_Password.setFont(new Font("Cambria",Font.BOLD,18));
		Re_Password.setForeground(new Color(255,0,0));

		return Re_Password;
	}

	JPasswordField getRe_Pass()
	{
		Re_Pass=new JPasswordField(25);

		Re_Pass.setEchoChar('*');

		Re_Pass.setEditable(false);

		Re_Pass.setFont(new Font("Arial",Font.BOLD,16));
		Re_Pass.setForeground(Color.blue);

		return Re_Pass;
	}

	//ROW 5
	JLabel geterror2()
	{
		error2=new JLabel("* Password doesn't match!");

		error2.setFont(new Font("Cambria",Font.BOLD,18));
		error2.setForeground(new Color(255,0,0));

		error2.setVisible(false);

		return error2;
	}

	//ROW 6
	JLabel getUser_Type()
	{
		User_Type=new JLabel("User Type: ");

		User_Type.setFont(new Font("Cambria",Font.BOLD,18));
		User_Type.setForeground(new Color(255,0,0));

		return User_Type;
	}

	JComboBox getcmbUser_Type()
	{
		cmbUser_Type=new JComboBox();

		cmbUser_Type.addItem("");
		cmbUser_Type.addItem("ADMINISTRATOR");
		cmbUser_Type.addItem("USER");

		cmbUser_Type.setEditable(false);

		return cmbUser_Type;
	}

	JLabel getqn()
	{
		qn=new JLabel("Select a Security Question");

		qn.setFont(new Font("Cambria",Font.BOLD,18));
		qn.setForeground(new Color(255,0,0));

		return qn;
	}

	JComboBox getcmbQn()
	{
		cmbQn=new JComboBox();

		cmbQn.addItem("");
		cmbQn.addItem("Who was your childhood friend?");
		cmbQn.addItem("What is your neighbour's name?");
		cmbQn.addItem("What is your pet name?");
		cmbQn.addItem("Where is your hometown?");
		cmbQn.addItem("What is your boyfriend/girlfriend's name?");
		cmbQn.addItem("Who is your favourite author?");

		return cmbQn;
	}

	JLabel getans()
	{
		ans=new JLabel("Security Answer: ");

		ans.setFont(new Font("Cambria",Font.BOLD,18));
		ans.setForeground(new Color(255,0,0));

		return ans;
	}

	JPasswordField gettxtAns()
	{
		txtAns=new JPasswordField(10);

		txtAns.setEchoChar('×');

		txtAns.setFont(new Font("Arial",Font.BOLD,16));
		txtAns.setForeground(Color.blue);

		return txtAns;
	}

	JPasswordField gettxt()
	{
		txt=new JPasswordField(10);

		txt.setEchoChar('×');

		txt.setFont(new Font("Arial",Font.BOLD,16));
		txt.setForeground(Color.blue);

		return txt;
	}

	JTextField getuser()
	{
		user=new JTextField(10);

		user.setFont(new Font("Arial",Font.BOLD,16));
		user.setForeground(Color.blue);

		return user;
	}

	JButton getbtn()
	{
		btn=new JButton("Modify");

		btn.setBackground(new Color(0,153,255));
		btn.setFont(new Font("Footlight MT Light",Font.BOLD,18));

		btn.setVisible(false);

		btn.addActionListener(this);

		return btn;
	}

	JButton getbtn2()
	{
		btn2=new JButton("Delete");

		btn2.setBackground(new Color(0,153,255));
		btn2.setFont(new Font("Footlight MT Light",Font.BOLD,18));

		btn2.setVisible(false);

		btn2.addActionListener(this);

		return btn2;
	}

	//PIC PANEL

	JPanel getsouthPanel()
	{
		southPanel = new JPanel();

		southPanel.setBackground(new Color(255,255,153));

		//southPanel.setVisible(true);

		southPanel.add(getlbl());

		return southPanel;
	}

	//FOOTER
	JLabel getlbl()
	{
		lbl=new JLabel(new ImageIcon("login.png"));
		return lbl;
	}

	//ACTIONLISTENER
	public void actionPerformed(ActionEvent ex)
	{
		// To add new account
		if(ex.getSource()==New)
		{
			AccPanel.setVisible(true);
			southPanel.setVisible(false);
			btn.setVisible(false);
			btn2.setVisible(false);
			Save.setEnabled(true);

			try
			{
				if(SqlConnect()==true)
				{
					EnableDisableControls(true);
					txtUser.requestFocus();
				}
			}
			catch(Exception yh)
			{
				yh.printStackTrace();
			}
		}

		// To cancel all controls
		if(ex.getSource()==Cancel)
		{
			ClearControls();
			txtUser.requestFocus();
			Save.setEnabled(true);
			error.setVisible(false);
			error2.setVisible(false);
			btn.setVisible(false);
			btn2.setVisible(false);
		}

		// To alter password.
		if(ex.getSource()==Modify)
		{
			if(SqlConnect()==true)
			{
				btn.setVisible(true);
				AccPanel.setVisible(true);
				southPanel.setVisible(false);
				Save.setEnabled(false);
				EnableDisableControls(false);
				btn2.setVisible(false);
			}
		}

		else	if(ex.getSource()==btn)
		{
			try
			{
				String username=txtUser.getText();

				if(username.length() == 0)
				{
					JOptionPane.showMessageDialog(null,"Username should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
					txtUser.requestFocus();
				}

				rs=st.executeQuery("SELECT * FROM login WHERE  LOGIN_NAME='"+txtUser.getText()+"'");

				boolean r=false;
				while(rs.next())
				{
					r=true;
				}

				if(r==false)
				{
					JOptionPane.showMessageDialog(null,"Invalid Username!","Login",JOptionPane.WARNING_MESSAGE);
					EnableDisableControls(false);
				}

				else
				{
					Object[]obj={"Who was your childhood friend?","What is your neighbour's name?","What is your pet name?",
					"Where is your hometown?","What is your boyfriend/girlfriend's name","Who is your favourite author?"};

					String s=(String)JOptionPane.showInputDialog(this,"Select your Security Question","Account Modifications",JOptionPane.PLAIN_MESSAGE,null,obj,getuser());
					JOptionPane.showMessageDialog(null,gettxt(),"Account Modifications",JOptionPane.INFORMATION_MESSAGE);

					rs=st.executeQuery("SELECT * FROM login WHERE  ANS='"+txt.getText()+"'");

					boolean d=false;
					while(rs.next())
					{
						d=true;
					}

					if(d==true)
					{
						JOptionPane.showMessageDialog(null,"Valid!","Field In Software Development",JOptionPane.INFORMATION_MESSAGE);
						EnableDisableControls(true);
						return;
					}

					else
					{
						JOptionPane.showMessageDialog(null,"Invalid!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
						EnableDisableControls(false);
					}
				}
			}
			catch(Exception w)
			{
				w.printStackTrace();
			}
		}



		// To update changes.
		if(ex.getSource()==Update)
		{
			if(SqlConnect()==true)
			{
				try
				{
					rs=st.executeQuery("SELECT * FROM login WHERE  LOGIN_NAME='"+txtUser.getText()+"'");

					boolean x=false;
					while(rs.next())
					{
						x=true;
					}

					if(x==false)
					{
						JOptionPane.showMessageDialog(null,"Username not found!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
					}

					else
					{
						String use=txtUser.getText();
						String pas=Pass.getText();
						String repas=Re_Pass.getText();
						String answe=txtAns.getText();
						String typ=String.valueOf(cmbUser_Type.getSelectedItem());
						String cmbq=String.valueOf(cmbQn.getSelectedItem());

						if(use.length() == 0)
						{
							JOptionPane.showMessageDialog(null,"Username should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
							txtUser.requestFocus();
						}

						else if(use.length() > 10)
						{
							JOptionPane.showMessageDialog(null,"Username should NOT exceed 10 characters!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
							txtUser.requestFocus();
						}

						else if(pas.length() == 0)
						{
							JOptionPane.showMessageDialog(null,"Password should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
							Pass.requestFocus();
						}

						else if(repas.length() == 0)
						{
							JOptionPane.showMessageDialog(null,"Password should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
							Re_Pass.requestFocus();
						}

						else if(answe.length() == 0)
						{
							JOptionPane.showMessageDialog(null,"Password should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
							txtAns.requestFocus();
						}

						else if(pas.length() <=5 || pas.length() >6)
						{
							error.setVisible(true);
						}

						else if(repas.length() <=5 || repas.length() >6)
						{
							error.setVisible(true);
						}

						else if(repas!=pas)
						{
							if(typ.equals("") == true)
							{
								JOptionPane.showMessageDialog(null,"Please select User Type!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
								cmbUser_Type.requestFocus();
							}

							else if(cmbq.equals("") == true)
							{
								JOptionPane.showMessageDialog(null,"Please select User Type!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
								cmbQn.requestFocus();
							}

							else if(repas.equals(pas) || pas.equals(repas))
							{
								try
								{
									Save.setEnabled(true);
									st.executeUpdate("update LOGIN set PASS='"+Pass.getText()+"'where LOGIN_NAME='"+txtUser.getText()+"'");
									st.executeUpdate("update LOGIN set REPASS='"+Re_Pass.getText()+"'where LOGIN_NAME='"+txtUser.getText()+"'");
									st.executeUpdate("update LOGIN set LOGINID='"+cmbUser_Type.getSelectedItem()+"'where LOGIN_NAME='"+txtUser.getText()+"'");
									st.executeUpdate("update LOGIN set QN='"+cmbQn.getSelectedItem()+"'where LOGIN_NAME='"+txtUser.getText()+"'");
									st.executeUpdate("update LOGIN set ANS='"+txtAns.getText()+"'where LOGIN_NAME='"+txtUser.getText()+"'");
									JOptionPane.showMessageDialog(null,"Account Updated!","Field In Software Development",JOptionPane.INFORMATION_MESSAGE);
									error2.setVisible(false);
									error.setVisible(false);
									ClearControls();
								}
								catch(Exception sa)
								{
									JOptionPane.showMessageDialog(null,"Updating Failed!","Field In Software Development",JOptionPane.WARNING_MESSAGE);
								}
							}

							else
							{
								error2.setVisible(true);
								Pass.requestFocus();
							}
						}
					}
				}
				catch(Exception jk)
				{
					jk.printStackTrace();
				}
			}
		}

		// To remove account
		if(ex.getSource()==Delete)
		{
			if(SqlConnect()==true)
			{
				AccPanel.setVisible(true);
				southPanel.setVisible(false);
				btn2.setVisible(true);
				btn.setVisible(false);
				EnableDisableControls(false);
			}
		}

		else	if(ex.getSource()==btn2)
		{
			try
			{
				String usernam=txtUser.getText();

				if(usernam.length() == 0)
				{
					JOptionPane.showMessageDialog(null,"Username should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
					txtUser.requestFocus();
				}

				rs=st.executeQuery("SELECT * FROM login WHERE  LOGIN_NAME='"+txtUser.getText()+"'");

				boolean q=false;
				while(rs.next())
				{
					q=true;
				}

				if(q==false)
				{
					JOptionPane.showMessageDialog(null,"Invalid Username!","Login",JOptionPane.WARNING_MESSAGE);
					EnableDisableControls(false);
				}

				else
				{
					Object[]obj={"Who was your childhood friend?","What is your neighbour's name?","What is your pet name?",
					"Where is your hometown?","What is your boyfriend/girlfriend's name","Who is your favourite author?"};

					String s=(String)JOptionPane.showInputDialog(this,"Select your Security Question","Account Modifications",JOptionPane.PLAIN_MESSAGE,null,obj,getuser());
					JOptionPane.showMessageDialog(null,gettxt(),"Account Modifications",JOptionPane.INFORMATION_MESSAGE);

					rs=st.executeQuery("SELECT ANS FROM LOGIN WHERE ANS=('"+txt.getText()+"')");

					boolean h=false;
					while(rs.next())
					{
						h=true;
					}

					if(h==true)
					{
						JOptionPane.showMessageDialog(null,"Valid!","Field In Software Development",JOptionPane.INFORMATION_MESSAGE);
						st.executeUpdate("DELETE from LOGIN where LOGIN_NAME=('"+txtUser.getText()+"')");
						JOptionPane.showMessageDialog(null,"Account Deleted!","Field In Software Development",JOptionPane.INFORMATION_MESSAGE);
						ClearControls();
					}

					else
					{
						JOptionPane.showMessageDialog(null,"Invalid!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
						EnableDisableControls(false);
					}
				}
			}
			catch(Exception u)
			{
				u.printStackTrace();
			}
		}

		// To add new account
		else if(ex.getSource()==Save)
		{
			if(SqlConnect()==true)
			{
				String user=txtUser.getText();
				String pass=Pass.getText();
				String repass=Re_Pass.getText();
				String answer=txtAns.getText();
				String type=String.valueOf(cmbUser_Type.getSelectedItem());
				String cmbqn=String.valueOf(cmbQn.getSelectedItem());

				if(user.length() == 0)
				{
					JOptionPane.showMessageDialog(null,"Username should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
					txtUser.requestFocus();
				}

				else if(user.length() > 10)
				{
					JOptionPane.showMessageDialog(null,"Username should NOT exceed 10 characters!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
					txtUser.requestFocus();
				}

				else if(pass.length() == 0)
				{
					JOptionPane.showMessageDialog(null,"Password should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
					Pass.requestFocus();
				}

				else if(repass.length() == 0)
				{
					JOptionPane.showMessageDialog(null,"Password should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
					Re_Pass.requestFocus();
				}

				else if(answer.length() == 0)
				{
					JOptionPane.showMessageDialog(null,"Security Answer should NOT be left blank!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
					txtAns.requestFocus();
				}

				else if(pass.length() <=5 || pass.length() >6)
				{
					error.setVisible(true);
				}

				else if(repass.length() <=5 || repass.length() >6)
				{
					error.setVisible(true);
				}

				else if(repass!=pass)
				{
					if(type.equals("") == true)
					{
						JOptionPane.showMessageDialog(null,"Please select User Type!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
						cmbUser_Type.requestFocus();
					}

					if(cmbqn.equals("") == true)
					{
						JOptionPane.showMessageDialog(null,"Please select User Type!","Field In Software Development",JOptionPane.ERROR_MESSAGE);
						cmbQn.requestFocus();
					}

					else if(repass.equals(pass) || pass.equals(repass))
					{
						try
						{
							st.executeUpdate("insert into LOGIN values('"+txtUser.getText()+ "','"+Pass.getText()+"' ,'"+Re_Pass.getText()+"' ,'"+String.valueOf(cmbUser_Type.getSelectedItem())+"','"+String.valueOf(cmbQn.getSelectedItem())+"','"+txtAns.getText()+"')");
							JOptionPane.showMessageDialog(null,"Record added","Field In Software Development",JOptionPane.INFORMATION_MESSAGE);
							error.setVisible(false);
							error2.setVisible(false);
							AccPanel.setVisible(false);
							southPanel.setVisible(true);
							EnableDisableControls(false);
							ClearControls();
						}
						catch(Exception es)
						{
							es.printStackTrace();
						}
					}
					else
					{
						error2.setVisible(true);
						Pass.requestFocus();
					}
				}
			}
		}
	}

	@SuppressWarnings("unchecked")

	public static void main (String [] fisd)
	{
		Account acc=new Account();
		acc.setVisible(true);
		acc.setSize(900,600);

  		java.awt.EventQueue.invokeLater(new Runnable()
  		{
            public void run() {
                new Account().setVisible(true);
              try {
	    		    System.setProperty(
	    	        "Quaqua.tabLayoutPolicy","wrap"
        			);
    				UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");
   					//UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");
   					//UIManager.setLookAndFeel("org.fife.plaf.OfficeXP.OfficeXPLookAndFeel");
   					//UIManager.setLookAndFeel("org.fife.plaf.VisualStudio2005.VisualStudio2005LookAndFeel");
					}
					catch (Exception e)
					{
  						 System.err.println("Oops!  Something went wrong!");
					}
	            }
	        });
	    }



        //System.setProperty(
        //    "Quaqua.tabLayoutPolicy","Leopard"
        //);

        //try
        //{
		//	UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");
		//}

		//catch(Exception g)
		//{
		//	g.printStackTrace();
		//}
	}

yes i read. I typed in cmd. It gave the same exception about thread -- ClassNotFound :(

Please copy the full contents of the command prompt screen for when you get the error and paste it here.

What is the full path to the Account.class file?

C:\Users\User>java -cp quaqua.jar ch.randelshofer.Account
Exception in thread "main" java.lang.NoClassDefFoundError: ch/randelshofer/Accou
nt
Caused by: java.lang.ClassNotFoundException: ch.randelshofer.Account
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: ch.randelshofer.Account. Program will exit.

Please go back and read my post about using the -cp option. You need to specify the current directory with a .

What is the full path to the Account.class file?

Edited 6 Years Ago by NormR1: n/a

That's not going to work. But you show the .java file, not the .class file??
The path to the Account.class file MUST match the package path. EXACTLY.

i dont get it. Listen, just see Account.java codes and check whether i have imported the quaqua package accordingly or not. Also check main function. And umm... how do i actually use quaqua in Account.java?

Edited 6 Years Ago by pinkygirl: n/a

Sorry, I know nothing about quaqua.
I was trying to correct the comandline so you could start the execution of the Account class.

Are you able to compile the Account.java file and get a Account.class file?
You can NOT execute the Account.java file. You must create an Account.class file.

Yes it is compiling and there is .class file
This was before i imported quaqua so that's why .class file is there
Anyway, just forget about this quaqua. It keeps giving me that thread exception. It's totally hopeless, won't work.
I guess i've to just use WindowsLookAndFeel.

Thanks for your help, I appreciate it alot

Yes it is compiling and there is .class file
This was before i imported quaqua so that's why .class file is there
Anyway, just forget about this quaqua. It keeps giving me that thread exception. It's totally hopeless, won't work.
I guess i've to just use WindowsLookAndFeel.

Thanks for your help, I appreciate it alot

As you've already been told, this has nothing to do with "quaqua". This has to do with the package you've given to your class (which it shouldn't have if that is a package in quaqua, which I can only assume it is), with the way you're defining your classpath, and with the way you are designating your main class, which has already been said.

Uhm, is Account (your class) supposed to be in the package "ch.randelshofer.quaqua"?

If it is, you need to call java from the directory that contains the "ch" directory (from the above package path) and use ch.randelshofer.quaqua.Account on the command line, not just Account.

You seemingly need to re-learn some of the basics (I can only assume you have been "learning" on an IDE, and so know next to nothing about how the JVM actually works).

hey i just wanted to give it this:-

UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");

or this:-

UIManager.setLookAndFeel(QuaquaManager.getLookAndFeelClassName());

and this in main function:-

//@SuppressWarnings("unchecked")

	public static void main (String [] fisd)
	{
		//Account acc=new Account();
		//acc.setVisible(true);
		//acc.setSize(900,600);

  		java.awt.EventQueue.invokeLater(new Runnable()
  		{
            public void run() {
                new Account().setVisible(true);
              try {
	    		    System.setProperty(
	    	        "Quaqua.tabLayoutPolicy","wrap"
        			);
    				UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");
   					}
					catch (Exception e)
					{
                                                e.printStackTrace()
  					}
	            }
	        });
	    }

if you know the correct methods then please tell me. All i want is that my frames should have quaqua theme.

I tried the above codes and it aint working. See Account.java in page 1 for brief description.

You have been told what's causing the error you're getting multiple times and, as yet, it has nothing to do with any of the code just posted. Since you simply can't seem to understand what you're being told I'm going to stop trying to tell you.

Edited 6 Years Ago by masijade: n/a

:'( you are so rude. Just beacuse I don't understand doesn't mean you turn your back.
I hope I figure it out by myself as soon as possible. Im sorry for distubing you. I'll make sure it wont happen again.

No, I am not rude, I am honest. And, when I tell someone the same thing four or five times (and say it clearly) and they still don't understand (or at least act as if they don't), then I stop telling them as it is not doing either of us any good and is only going to lead to frustation on both parts and bad feelings on their part.

This article has been dead for over six months. Start a new discussion instead.