-2
我正在做一個Java測驗程序,它有一個MySQL數據庫(使用QuestionID, Question_text, Answer_1, Answer_2, Answer_3, Answer_4, Right_Answer, Explanation
作爲我的模式)。List to Array | Java測試GUI基於
我有很多問題,因爲我需要「生成」一個新的JPanel,隨機問題(應該有一個圖像,一個問題和3個答案)。
用戶完成答案後,我想顯示結果。
所以我的問題是關於創建JPanels,與問題,並與答案...
請,誰能幫助我?這裏是我的代碼:
CardLayout card = (CardLayout) frame.getContentPane().getLayout();
card.show(frame.getContentPane(), "panel_Exame1");
try {
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/escolaconducao_linhacerta", "root", "");
PreparedStatement stmt = (PreparedStatement) con.prepareStatement("SELECT texto, opcao1, opcao2, opcao3, opcao4, resposta, explicacao FROM perguntas WHERE idPergunta=1");
ResultSet res = stmt.executeQuery();
while (res.next()) {
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Erro: " + ex.getLocalizedMessage());
}
我想創建一個列表(不是代碼,因爲它是錯的,我刪除了它),然後得到的數值,以填補新JPanel
,與數據庫裏面的數據正確的地方。