0

Hello EveryOne
I need Help here ,i have been trying to view this GUI but it keeps showing me this erroe NoClassDefFounderError.
Anyones help would be appreciated.

import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.*;



public class HeartLandHomeFinance2 extends JFrame
{


JPanel  Panel;
JLabel  lb1, lb2, lb3 ,lb4 ,lb5 ,lb6,lb7,lb8,lb9,lb10,lb11,lb12,lb13,lb14,
lb15,lb16,lb17,lb18,lb19,lb20,lb21,lb22,lb23, heading,lb24;
JTextField  jt1,jt2,jt3,jt4,jt5,jt6,jt7,jt8,jt9,jt10,jt11,jt12,jt13,jt14,jt15,jt16,jt18,jt17;
JButton  bt1,bt2;
GridBagLayout gb;
JScrollPane jscrollpane;
GridBagConstraints gbc;
JComboBox combo1,combo2,combo3,combo4,combo5,combo6;
Connection con;
PreparedStatement stat;
Statement stmt;
ResultSet rs;
Font f;


public void HeartLandHomeFinance2()
{
JFrame frame = new JFrame("Heart Land Home Finance");
JFrame.setDefaultLookAndFeelDecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);



frame.pack();
frame.setSize(600, 300);
frame.setVisible(true);
createAndShowGUI();
}



public void createAndShowGUI()
{


Panel =new JPanel();


Panel.setLayout(gb);
Panel.setBackground(Color.RED);



Container contentPane = getContentPane();
gb = new GridBagLayout();
gbc =  new GridBagConstraints();


f = new Font("Monospaced", Font.BOLD, 24);
gbc.gridx = 1;
gbc.gridy = 0;
gbc.gridwidth = 3;


heading = new JLabel("Heart Land Home Finance");
heading.setForeground(Color.black);
heading.setFont(f);
Panel.add( heading, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
gbc.gridwidth = 5;


lb1 =new JLabel("Please Fill All The Fields in CAPITAL LETTERS");
lb1.setFont(f);
lb1.setForeground(Color.black);
gbc.ipady = 2;
gbc.ipadx = 2;
gbc.gridx = 2;
gbc.gridy = 3;
gb.setConstraints(lb1, gbc);
Panel.add(lb1);


lb2 =new JLabel("Name:");
gbc.ipady = 2;
gbc.ipadx = 2;
gbc.gridx = 2;
gbc.gridy = 3;
gb.setConstraints(lb2, gbc);
Panel.add(lb2);
jt1 = new JTextField(30);
gbc.ipady = 2;
gbc.ipadx = 2;
gbc.gridx = 1;
gbc.gridy = 7;
gb.setConstraints(jt1, gbc);
Panel.add(jt1);


}
public static void main(String args[])
{
HeartLandHomeFinance2 h = new HeartLandHomeFinance2();
h.Show();
}
}

grts
tactfulsaint.

Edited by happygeek: fixed formatting

5
Contributors
7
Replies
8
Views
9 Years
Discussion Span
Last Post by Ezzaral
Featured Replies
  • 1
    Ezzaral 2,714   8 Years Ago

    See comments in the code[code=java] import java.awt.*; import java.awt.event.*; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import javax.swing.*; public class HeartLandHomeFinance2 extends JFrame { JPanel Panel; JLabel lb1, lb2, lb3, lb4, lb5, lb6, lb7, lb8, lb9, lb10, lb11, lb12, lb13, lb14, lb15, lb16, lb17, lb18, lb19, lb20, lb21, lb22, … Read More

0

classpath problem. Only thing that can lead to that error.

how to solve it. I'm getting the same prob while executing programs. I tried doing the following
set classpath.;%classpath% Is it correct cuz it didn't work for me, it says syntax error.

0

classpath problem. Only thing that can lead to that error.

Thanks Alot that problem is solved,
Could you please also help me with this problem

My Frame Does Display after i have javac and try to display its blank and does not show the buttons and labels i dont know why..
Thanks

0

This code snipet does not display the buttons and labels
Need help me from anyone..


import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.*;


public class HeartLandHomeFinance2 extends JFrame
{

JPanel Panel;
JLabel lb1, lb2, lb3 ,lb4 ,lb5 ,lb6,lb7,lb8,lb9,lb10,lb11,lb12,lb13,lb14,
lb15,lb16,lb17,lb18,lb19,lb20,lb21,lb22,lb23, heading,lb24;
JTextField jt1,jt2,jt3,jt4,jt5,jt6,jt7,jt8,jt9,jt10,jt11,jt12,jt13,jt14,jt15,jt16,jt18,jt17;
JButton bt1,bt2;
GridBagLayout gb;
JScrollPane jscrollpane;
GridBagConstraints gbc;
JComboBox combo1,combo2,combo3,combo4,combo5,combo6;
Connection con;
PreparedStatement stat;
Statement stmt;
ResultSet rs;
Font f;

public void HeartLandHomeFinance2()
{
JFrame frame = new JFrame("Heart Land Home Finance");
JFrame.setDefaultLookAndFeelDecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setSize(600, 300);
frame.setVisible(true);
createAndShowGUI();
}


public void createAndShowGUI()
{

Panel =new JPanel();

Panel.setLayout(gb);
Panel.setBackground(Color.RED);


Container contentPane = getContentPane();
gb = new GridBagLayout();
gbc = new GridBagConstraints();

f = new Font("Monospaced", Font.BOLD, 24);
gbc.gridx = 1;
gbc.gridy = 0;
gbc.gridwidth = 3;

heading = new JLabel("Heart Land Home Finance");
heading.setForeground(Color.black);
heading.setFont(f);
Panel.add( heading, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
gbc.gridwidth = 5;

lb1 =new JLabel("Please Fill All The Fields in CAPITAL LETTERS");
lb1.setFont(f);
lb1.setForeground(Color.black);
gbc.ipady = 2;
gbc.ipadx = 2;
gbc.gridx = 2;
gbc.gridy = 3;
gb.setConstraints(lb1, gbc);
Panel.add(lb1);

lb2 =new JLabel("Name:");
gbc.ipady = 2;
gbc.ipadx = 2;
gbc.gridx = 2;
gbc.gridy = 3;
gb.setConstraints(lb2, gbc);
Panel.add(lb2);
jt1 = new JTextField(30);
gbc.ipady = 2;
gbc.ipadx = 2;
gbc.gridx = 1;
gbc.gridy = 7;
gb.setConstraints(jt1, gbc);
Panel.add(jt1);

}
public static void main(String args[])
{
HeartLandHomeFinance2 h = new HeartLandHomeFinance2();
h.Show();
}
}

1

See comments in the code

import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.*;

public class HeartLandHomeFinance2 extends JFrame {

    JPanel Panel;
    JLabel lb1, lb2, lb3, lb4, lb5, lb6, lb7, lb8, lb9, lb10, lb11, lb12, lb13, lb14,
      lb15, lb16, lb17, lb18, lb19, lb20, lb21, lb22, lb23, heading, lb24;
    JTextField jt1, jt2, jt3, jt4, jt5, jt6, jt7, jt8, jt9, jt10, jt11, jt12, jt13, jt14, jt15, jt16, jt18, jt17;
    JButton bt1, bt2;
    GridBagLayout gb;
    JScrollPane jscrollpane;
    GridBagConstraints gbc;
    JComboBox combo1, combo2, combo3, combo4, combo5, combo6;
    Connection con;
    PreparedStatement stat;
    Statement stmt;
    ResultSet rs;
    Font f;

    // this constructor was not valid - constructors don't have a return type
    // explicitlly stated, because they always return an instance of the class
    public HeartLandHomeFinance2() {
        // you don't need a new Frame here
        // your class is a JFrame
        // I moved the frame calls into createAndShowGUI() as well
        createAndShowGUI();
    }

    public void createAndShowGUI() {
        setTitle("Heart Land Home Finance");
        setDefaultLookAndFeelDecorated(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        Container contentPane = getContentPane();
        // you have to initialize gb before you make the setLayout call
        // you were using a null layout because gb was null
        gb = new GridBagLayout();

        Panel = new JPanel();
        Panel.setLayout(gb);
        Panel.setBackground(Color.RED);

        gbc = new GridBagConstraints();

        f = new Font("Monospaced", Font.BOLD, 24);
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.gridwidth = 3;

        heading = new JLabel("Heart Land Home Finance");
        heading.setForeground(Color.black);
        heading.setFont(f);
        Panel.add(heading, gbc);

        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.gridwidth = 5;

        lb1 = new JLabel("Please Fill All The Fields in CAPITAL LETTERS");
        lb1.setFont(f);
        lb1.setForeground(Color.black);
        gbc.ipady = 2;
        gbc.ipadx = 2;
        gbc.gridx = 2;
        gbc.gridy = 3;
        gb.setConstraints(lb1, gbc);
        Panel.add(lb1);

        lb2 = new JLabel("Name:");
        gbc.ipady = 2;
        gbc.ipadx = 2;
        gbc.gridx = 2;
        gbc.gridy = 3;
        gb.setConstraints(lb2, gbc);
        Panel.add(lb2);
        jt1 = new JTextField(30);
        gbc.ipady = 2;
        gbc.ipadx = 2;
        gbc.gridx = 1;
        gbc.gridy = 7;
        gb.setConstraints(jt1, gbc);
        Panel.add(jt1);

        // now the panel needs to be added to the content pane
        contentPane.add(Panel);
        
        // now set the size and show it
        setSize(600, 300);
        setVisible(true);
    }

    public static void main(String args[]) {
        HeartLandHomeFinance2 h = new HeartLandHomeFinance2();
        
    }
}

Now you just have to fix up your grid bag constraint properties.

Comments
your gud
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.