Results 1 to 7 of 7
Thread: a quiz program
- 12-15-2011, 02:20 AM #1
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
a quiz program
what i'm trying to create here is a quiz program
there are four radio buttons, each representing the possible answers to the question and if i click on a radio button, the next question will show up and so on
the problem is that i have no idea how to make that happen
any suggestions?
Java Code:import java.awt.BorderLayout; public class QuestionPage extends JFrame { private JPanel contentPane; private JTextField txtQuestion; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { QuestionPage frame = new QuestionPage(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public QuestionPage() { setTitle("Quiz"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 414, 241); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); ButtonGroup options = new ButtonGroup(); JRadioButton rbOpt1 = new JRadioButton("Option 1"); rbOpt1.addMouseListener(new MouseAdapter() { rbOpt1.setBounds(10, 84, 109, 23); options.add(rbOpt1); contentPane.add(rbOpt1); JRadioButton rbOpt2 = new JRadioButton("Option 2"); rbOpt2.setBounds(10, 110, 109, 23); options.add(rbOpt2); contentPane.add(rbOpt2); JRadioButton rbOpt3 = new JRadioButton("Option 3"); rbOpt3.setBounds(10, 136, 109, 23); options.add(rbOpt3); contentPane.add(rbOpt3); JRadioButton rbOpt4 = new JRadioButton("Option 4"); rbOpt4.setBounds(10, 162, 109, 23); options.add(rbOpt4); contentPane.add(rbOpt4); txtQuestion = new JTextField(); txtQuestion.setFont(new Font("Tahoma", Font.PLAIN, 18)); txtQuestion.setText("Question #1"); txtQuestion.setBounds(10, 39, 332, 28); contentPane.add(txtQuestion); txtQuestion.setColumns(10); } }Last edited by Eranga; 12-15-2011 at 02:53 AM. Reason: code tags added
- 12-15-2011, 02:53 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Re: a quiz program
Please use the code tags when you posting code segments next time. Unformatted codes are really hard to read.
- 12-15-2011, 02:57 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Re: a quiz program
Regarding your question,
1. You must have a way to store already created question and answers. Because you cannot generate question through a code, human interaction is need.
2. To store questions you can use a database, text file, etc...
3. In my experience, you can use XML (and XSLT too for formatting). So you can define a patter to store details of each question and work around.
4. Use of databases can cause lot of performance issues.
- 12-15-2011, 03:01 AM #4
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
Re: a quiz program
can you explain what XML and XSLT are? sorry i'm new to Java
- 12-15-2011, 03:05 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Re: a quiz program
If you don't know about XSLT just forget about that at the moment. Those are comes to picture when you have to dealing with formatting/styling. With or without XSLT we can do styling, but having it make your life easy.
However, the knowledge of XML is really valued for all the programmers I think. If you really don't know about that read the following Wiki first of all.
XML - Wikipedia, the free encyclopedia
- 12-15-2011, 03:08 AM #6
- 12-15-2011, 03:17 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Re: a quiz program
Similar Threads
-
Help with quiz program
By askinne2 in forum New To JavaReplies: 1Last Post: 04-16-2010, 10:49 PM -
quiz program using access as database
By miinnesh in forum AWT / SwingReplies: 5Last Post: 03-05-2010, 11:30 AM -
quiz program using access as database
By miinnesh in forum JDBCReplies: 0Last Post: 03-05-2010, 05:54 AM -
Help with quiz
By khanzaman in forum AWT / SwingReplies: 10Last Post: 01-19-2009, 07:45 AM -
Help pls with a quiz
By saytri in forum New To JavaReplies: 3Last Post: 12-23-2007, 06:09 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks