⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quizitempanel.java

📁 CroftSoft Code Library是一个开源的可移植的纯Java游戏库
💻 JAVA
字号:
     package com.croftsoft.apps.quiz;

     import java.awt.*;
     import javax.swing.*;

     import com.croftsoft.core.lang.NullArgumentException;

     /*********************************************************************
     *
     * <p />
     *
     * @version
     *   2001-07-11
     * @since
     *   2001-07-10
     * @author
     *   <a href="http://croftsoft.com/">David Wallace Croft</a>
     *********************************************************************/

     public final class  QuizItemPanel
       extends JPanel
     //////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////
     {

//   private QuizItem  quizItem;

     private JTextArea  questionJTextArea;

     private JTextArea  answerJTextArea;

     private JTextArea  referenceJTextArea;

     //////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////

     public  QuizItemPanel (
       Color  panelBackgroundColor,
       Color  textFieldBackgroundColor )
     //////////////////////////////////////////////////////////////////////
     {
       super ( new GridBagLayout ( ), true ); // isDoubleBuffered

// the panels currently ignore the colors

       questionJTextArea  = new JTextArea ( );

       answerJTextArea    = new JTextArea ( );

       referenceJTextArea = new JTextArea ( );

       GridBagConstraints  gridBagConstraints = new GridBagConstraints ( );

       gridBagConstraints.fill = GridBagConstraints.BOTH;

       gridBagConstraints.weightx = 1.0;

       gridBagConstraints.gridy = 0;

       gridBagConstraints.weighty = 1.0;

       add ( new JScrollPane ( questionJTextArea  ), gridBagConstraints );

       gridBagConstraints.gridy = 1;

       gridBagConstraints.weighty = 3.0;

       add ( new JScrollPane ( answerJTextArea    ), gridBagConstraints );

       gridBagConstraints.gridy = 2;

       gridBagConstraints.weighty = 1.0;

       add ( new JScrollPane ( referenceJTextArea ), gridBagConstraints );
     }

     public  QuizItemPanel ( )
     //////////////////////////////////////////////////////////////////////
     {
       this ( null, null );
     }

     //////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////

     public void  setQuizItem ( QuizItem  quizItem )
     //////////////////////////////////////////////////////////////////////
     {
       String  question  = null;

       String  answer    = null;

       String  reference = null;

       if ( quizItem != null )
       {
         question  = quizItem.getQuestion  ( );

         answer    = quizItem.getAnswer    ( );

         reference = quizItem.getReference ( );
       }
       
       questionJTextArea .setText ( question  != null ? question  : "" );

       answerJTextArea   .setText ( answer    != null ? answer    : "" );

       referenceJTextArea.setText ( reference != null ? reference : "" );
     }

     //////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////
     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -