📄 questionpanel.java
字号:
/* * QuestionPanel.java * * Created on 2004年1月14日, 下午3:17 */package romulus.UI;import romulus.*;import java.util.*;import java.awt.*;import javax.swing.*;/** * * @author Administrator */public class QuestionPanel extends javax.swing.JPanel implements java.awt.event.ActionListener{ /** Creates new form QuestionPanel */ public QuestionPanel(Test t, boolean check) { initComponents(); this.test = t; this.check = check; if(check){ this.CommitButton.setText("Finish"); } initTest(); if(!check){ time = (int)(t.getTiming()); if(time > 0){ timer = new javax.swing.Timer(1000, this); timer.setRepeats(true); timer.start(); } } } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents java.awt.GridBagConstraints gridBagConstraints; TestInfoLabel = new javax.swing.JLabel(); TimeInfoLabel = new javax.swing.JLabel(); QuestionInfoLabel = new javax.swing.JLabel(); ObjectiveScrollPane = new javax.swing.JScrollPane(); ObjectiveTextArea = new javax.swing.JTextArea(); FeedbackScrollPane = new javax.swing.JScrollPane(); FeedbackTextArea = new javax.swing.JTextArea(); ContentScrollPane = new javax.swing.JScrollPane(); ContentTextArea = new javax.swing.JTextArea(); AnswerScrollPane = new javax.swing.JScrollPane(); AnswerPanel = new javax.swing.JPanel(); ButtonPanel = new javax.swing.JPanel(); BackButton = new javax.swing.JButton(); ForwordButton = new javax.swing.JButton(); CommitButton = new javax.swing.JButton(); setLayout(new java.awt.GridBagLayout()); setBorder(new javax.swing.border.TitledBorder(null, "\u8bd5\u9898", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, getFont())); setFont(getFont()); TestInfoLabel.setFont(getFont()); TestInfoLabel.setText("TestInfo"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 5.0; gridBagConstraints.weighty = 1.0; add(TestInfoLabel, gridBagConstraints); TimeInfoLabel.setFont(getFont()); TimeInfoLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); TimeInfoLabel.setText("TimeInfo"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; add(TimeInfoLabel, gridBagConstraints); QuestionInfoLabel.setFont(getFont()); QuestionInfoLabel.setText("QuestionInfo"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; add(QuestionInfoLabel, gridBagConstraints); ObjectiveScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); ObjectiveScrollPane.setViewportBorder(new javax.swing.border.TitledBorder(null, "Objective", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, getFont())); ObjectiveScrollPane.setFont(getFont()); ObjectiveTextArea.setFont(getFont()); ObjectiveTextArea.setLineWrap(true); ObjectiveTextArea.setDisabledTextColor(java.awt.Color.darkGray); ObjectiveTextArea.setEnabled(false); ObjectiveScrollPane.setViewportView(ObjectiveTextArea); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; add(ObjectiveScrollPane, gridBagConstraints); FeedbackScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); FeedbackScrollPane.setViewportBorder(new javax.swing.border.TitledBorder(null, "Feedback", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, getFont())); FeedbackScrollPane.setFont(getFont()); FeedbackTextArea.setFont(getFont()); FeedbackTextArea.setLineWrap(true); FeedbackTextArea.setDisabledTextColor(java.awt.Color.darkGray); FeedbackTextArea.setEnabled(false); FeedbackScrollPane.setViewportView(FeedbackTextArea); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; add(FeedbackScrollPane, gridBagConstraints); ContentScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); ContentScrollPane.setViewportBorder(new javax.swing.border.TitledBorder(null, "Question", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, getFont())); ContentScrollPane.setFont(getFont()); ContentTextArea.setFont(getFont()); ContentTextArea.setLineWrap(true); ContentTextArea.setDisabledTextColor(java.awt.Color.darkGray); ContentTextArea.setEnabled(false); ContentScrollPane.setViewportView(ContentTextArea); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 5.0; gridBagConstraints.weighty = 2.0; add(ContentScrollPane, gridBagConstraints); AnswerScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); AnswerScrollPane.setViewportBorder(new javax.swing.border.TitledBorder(null, "Answer", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, getFont())); AnswerScrollPane.setFont(getFont()); AnswerPanel.setLayout(new javax.swing.BoxLayout(AnswerPanel, javax.swing.BoxLayout.Y_AXIS)); AnswerPanel.setFont(getFont()); AnswerScrollPane.setViewportView(AnswerPanel); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 5.0; gridBagConstraints.weighty = 1.0; add(AnswerScrollPane, gridBagConstraints); ButtonPanel.setLayout(new java.awt.GridBagLayout()); ButtonPanel.setFont(getFont()); BackButton.setFont(getFont()); BackButton.setText("Back(<)"); BackButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BackButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; ButtonPanel.add(BackButton, gridBagConstraints); ForwordButton.setFont(getFont()); ForwordButton.setText("Forword(>)"); ForwordButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ForwordButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; ButtonPanel.add(ForwordButton, gridBagConstraints); CommitButton.setFont(getFont()); CommitButton.setText("Commit"); CommitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CommitButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; ButtonPanel.add(CommitButton, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 3.0; gridBagConstraints.weighty = 1.0; add(ButtonPanel, gridBagConstraints); }//GEN-END:initComponents private void CommitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CommitButtonActionPerformed // Add your handling code here: if(check){ firePropertyChange(PropName_Exit, null, null); } else{ setAnswer(Question_Num); firePropertyChange(PropName_Commit, null, this.test); } }//GEN-LAST:event_CommitButtonActionPerformed private void ForwordButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ForwordButtonActionPerformed if(!check){ setAnswer(Question_Num); } this.Question_Num++; ShowQuestion(Question_Num, check); if(this.Question_Num == (this.Total_Num-1)){ this.ForwordButton.setEnabled(false); } this.BackButton.setEnabled(true); }//GEN-LAST:event_ForwordButtonActionPerformed private void BackButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BackButtonActionPerformed if(!check){ setAnswer(Question_Num); } this.Question_Num--;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -