Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 871559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:39:28+00:00 2026-05-15T10:39:28+00:00

i have a simple JPanel bean in my projects, now i want to drag

  • 0

i have a simple JPanel bean in my projects, now i want to drag my panel bean class into my jframe.

My panel bean class is like this:

public class BeanPanel extends javax.swing.JPanel {

/** Creates new form BeanPanel */
public BeanPanel () {
    initComponents();
    Session session=HibernateUtil.getSessionFactory().openSession();
}

This code seem to break the bean:

Session session=HibernateUtil.getSessionFactory().openSession();

When i try to drag the class into my JFrame bean i had this error message:

This component cannot be instantiated. Please make sure it is a JavaBeans Component

If i comment it all works fine.
What is the reason of this?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:39:28+00:00Added an answer on May 15, 2026 at 10:39 am

    Don’t do expensive work (like opening a session) in the constructor. At best use only assignments in constructor. In your case when placing the component, NetBeans is calling its constructor. Which can’t connect, because probably the appropriate configurations aren’t loaded, or because the classpath is correct, or whatever.

    create a getter and setter for session, and use lazy initialization in the getter:

    public Session getSession() {
       if (session == null) {
           HibernateUtils.getSessionFactory().openSession();
       }
    }
    

    That said, I think you may have problems with session handling. Perhaps you can take a look at the getCurrentSession() method of SessionFactory.

    Another thing – don’t mix database access and UI. Move the handling of data outside your Panels.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is simple version of my problem. I have 3 classes: public class TopographyFrame
I tried create simple class which can slide a JPanel like this: +----------+ +------+---+
I have this simple application in which a command like RECT 10 20 100
I have a fairly simple question. I have a JPanel on a JFrame. I
I have a simple JPanel for tic-tac-toe, drawing lines... so class TTT extends JPanel,
I want to program a simple Snake. Therefore I have programmed a custom JPanel
I have simple class with width and height member fields which define number of
I have a JPanel with one component that I want to place in an
I have a JFrame with an associated JPanel which fill the screen, both having
All I want is to make a simple user password login. I have put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.