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

  • SEARCH
  • Home
  • 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 9258067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:18:00+00:00 2026-06-18T12:18:00+00:00

I have a main JFrame which consists of 3 small JPanel which are switched

  • 0

I have a main JFrame which consists of 3 small JPanel which are switched on the basis of selection by the user.

The problem is that I have to save the data inserted into JPanel into the database but I am unable to access the elements of the JPanel directly. So how do I accept those.

The entry in DB is done when the ACCEPT button is clicked in the main frame.
Please help

if(Selected==Credit Card){
    Select Credit Card Panel;
    }
if(Selected==Debit Card){
    Select Debit Card Panel;
    }
if(Selected==Cash on Delivery){
    Select Cash on Delivery Panel;
    }



onAccept(){
    if(Selected==Credit Card){
get data from Credit Card panel and store in Database; (variables like cc number, cvv)
}

if(Selected==Debit Card){
get data from Debit Card panel and store in Database;
}

if(Selected==Cash on Delivery){
get data from Cash on Delivery Card panel and store in Database;
}
    }
  • 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-06-18T12:18:01+00:00Added an answer on June 18, 2026 at 12:18 pm

    Have each of your 3 panels implement the same interface:

    public interface DataStorer {
        public void storeDataInDatabase();
    }
    

    Then, when the accept button is clicked, call this:

    DataStorer selectedPanel = (DataStorer) theDisplayedPanel;
    selectedPanel.storeDataInDatabase();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JFrame and a Jpanel over that in which various buttons are
I have a main JFrame which holds a default JPanel. I'm trying to use
I have Main class, StartFrame extends JFrame, and UserPanel extends JPanel which I add
I have a program that uses the java swing jframe as my main class.
Consider the following scenario: I have a JFrame Main which has a jButton caravanDataButton
I have this main JFrame (call it DrinkChooser) that shows another complex confirmation JFrame
I have an application that needs to log the user in. Data is stored
I have jFrame class MainForm which contains main() , placePanel(panel) and drop down menu.
I have this problem in a program which changes panels in a JFrame. I
I have a program in which a JPanel is added to a JFrame: public

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.