I'm still learning Java and am currently building a Multiple-Choice Quiz for a class assignment. I have the code written and it works great, but it feels like an over-long mess when I go back in to edit it. I would like to break it down into different classes and methods, but it seems to get more complicated as I try. Is there a better (more elegant) way to do this? Below is a piece of what I'm working with...
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 700, 700);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
Font smallFont = new Font("Bookman Old Style", Font.ITALIC, 12);
Font smallBoldFont = new Font("Bookman Old Style", Font.BOLD, 12);
Font medBoldFont = new Font("Bookman Old Style", Font.BOLD, 18);
Font medBoldItalFont = new Font("Bookman Old Style", Font.BOLD +
Font.ITALIC, 18);
JLabel lblSubjectQuiz = new JLabel("SUBJECT QUIZ");
lblSubjectQuiz.setHorizontalTextPosition(SwingConstants.CENTER);
lblSubjectQuiz.setVerticalTextPosition(SwingConstants.CENTER);
lblSubjectQuiz.setHorizontalAlignment(SwingConstants.CENTER);
lblSubjectQuiz.setBounds(10, 10, 664, 70);
lblSubjectQuiz.setFont(new Font("Bookman Old Style", Font.BOLD, 28));
JLabel lblQuestion = new JLabel();
lblQuestion.setText("<html>" +
qAndA.getQuestion(randNum.qNumbers.get(qCount)) + "</html>");
lblQuestion.setHorizontalTextPosition(SwingConstants.CENTER);
lblQuestion.setVerticalTextPosition(SwingConstants.CENTER);
lblQuestion.setHorizontalAlignment(SwingConstants.CENTER);
lblQuestion.setFont(new Font("Bookman Old Style", Font.PLAIN, 18));
lblQuestion.setBounds(10, 86, 664, 126);
// Create radio buttons for the answer choices
JRadioButton btnAnswerA = new JRadioButton();
btnAnswerA.setFont(smallFont);
btnAnswerA.setBounds(28, 252, 325, 35);
btnAnswerA.setText(qAndA.getAnsA(randNum.qNumbers.get(qCount)));
JRadioButton btnAnswerB = new JRadioButton();
btnAnswerB.setFont(smallFont);
btnAnswerB.setBounds(28, 292, 325, 35);
btnAnswerB.setText(qAndA.getAnsB(randNum.qNumbers.get(qCount)));
JRadioButton btnAnswerC = new JRadioButton();
btnAnswerC.setFont(smallFont);
btnAnswerC.setBounds(28, 332, 325, 35);
btnAnswerC.setText(qAndA.getAnsC(randNum.qNumbers.get(qCount)));
JRadioButton btnAnswerD = new JRadioButton();
btnAnswerD.setFont(smallFont);
btnAnswerD.setBounds(28, 372, 325, 35);
btnAnswerD.setText(qAndA.getAnsD(randNum.qNumbers.get(qCount)));
ButtonGroup radioButtons = new ButtonGroup();
radioButtons.clearSelection();
radioButtons.add(btnAnswerA);
radioButtons.add(btnAnswerB);
radioButtons.add(btnAnswerC);
radioButtons.add(btnAnswerD);
JLabel lblRightAns = new JLabel("<html>" + "Correct!" + "</html>");
lblRightAns.setVisible(false);
lblRightAns.setHorizontalAlignment(SwingConstants.CENTER);
lblRightAns.setFont(medBoldItalFont);
lblRightAns.setForeground(Color.GREEN);
lblRightAns.setBounds(427, 240, 222, 64);