tags:

views:

69

answers:

2
A: 

Ofcourse you can do it with Java Swings. All you gotta do is based on user input you gotta take a decision to add new JPanels. From the picture you've given in the example, you would need to add a Q&A block dynamically. Simply attach that to any event handler within your application so that it gets added dynamically

public getQandAPanel(){
    JPanel questPanel = new JPanel();
    JPanel answerPanel = new JPanel();
    JPanel wrappingPanel = new JPanel();
    wrappingPanel.setLayout(new GridLayout(0,1));
    //CODE TO DECORATE question and answer panels should go here
    wrappingPanel.add(questPanel);
    wrappingPanel.add(answerPanel);
}

Now everytime when you call this getQandAPanel, this would return you a fresh JPanel everytime which you can add it to your parent JFrame. You should have a good idea of Java Swings to know what I'm talking about.

Bragboy
+2  A: 

Yes you can dynamically add and remove components. The basic code would be:

panel.add( ... );
panel.revalidate();
panel.repaint();
camickr