Hello I want to have One JLabel (For question from database), four JRadio Buttons for answer and options(from database) and Next button. I am using One Jrame which contains one JPanel. In my Jpanel I have loaded these components but how can I refresh/reload the panel with other these similar components when user click Next button for next question so that label should be loaded with another question and radio buttons with other answer/options.
If you have a sequence of panels of components to be shown to the user you could use the java.awt.CardLayout layout manager to allow you to easily 'flip' panels.
Some one told me that if you have same components to display each time, like every question contains same label, radiobuttons, and button, you do not need card layout. Can you please guide me how can I use card layout? I mean I will have one panel with card layout and these components, what will I do when user click Next button. How to shuffle the cards, how many panels I will have, it will be great if you come up with a brief detail.
Thanks
Yes, if the components are the same for each panel then you can just change the text displayed by each component. But if you have different components on the panels then you will need to use another approach such as CardLayout. For help on using this layout manager see the Java tutorial https://docs.oracle.com/javase/tutorial/uiswing/layout/card.html
Thanks again.
Actually coming specific to my project, suppose I want to include questions like true/false having different components (JLabel/Two radio buttons and Next button), then I will have separate panel for it? And if I want to include another type of question in which user will directly input answer to text field(no choices/radio buttons), I will have separate jPanel for it, right?
In this case, I will have three jPanels? In which Panel I will have to set the layout as Card layout?
Second, these three panels will be separate in one jframe or one main panel will contain these three jpanels?
Don't know. You should not go round thinking what sort of components you will need. You start by asking what you want the display to look like. Draw it with true‑false questions included and that drawing should tell you what components you will need.
I know which components to add for each type of questions, but I want to ask, suppose I have three different types of questions with three different types of components, so it means I will have three jpanels one for each type of question? And besides these three separate jpanels, one main panel which contain these three panels? And the cardlayout will be set for main Jpanel,?
Am I right?