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

📄 wordsetpanel.java

📁 一款背单词的小程序,可以自己在自定义词库中加单词,运行环境JCreator
💻 JAVA
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;

public class WordSetPanel extends JPanel
{
	
	JSlider sb ;
	static JCheckBox checkBox1 = new JCheckBox("不显示中文");
	static JCheckBox checkBox2 = new JCheckBox("不显示英文");
	ButtonGroup g = new ButtonGroup();
	static JRadioButton jrb1 = new JRadioButton("顺序",true);
	static JRadioButton jrb2 = new JRadioButton("倒序",false);
	static JRadioButton jrb3 = new JRadioButton("随机",false);
	JPanel panel = new JPanel();
	JLabel label = new JLabel("秒");
	static JLabel label1 = new JLabel("");
	JLabel label2 = new JLabel("输入一组单词个数");
	 JPanel textPanel = new JPanel();
	JPanel panel3 = new JPanel();
	static JTextField wordCountText = new JTextField(10);
	SliderListener sl = new SliderListener();
	RadioButtonListener brl = new RadioButtonListener();
	 static int delay =1000;
	 static int order = 1;
	 /////////////////////////////////////////////////
	 ///////////
	WordSetPanel()
	{
		panel.setOpaque(false);
		label.setForeground(Color.yellow);
		label1.setForeground(Color.yellow);
		label.setFont(new Font("宋体",Font.BOLD,15));
		label1.setFont(new Font("宋体",Font.BOLD,15));
	    CheckBoxListener boxl =new CheckBoxListener();
	    checkBox2.setForeground(Color.yellow);
        checkBox1.setForeground(Color.yellow);
        checkBox2.setFont(new Font("宋体",Font.BOLD,15));
        checkBox1.setFont(new Font("宋体",Font.BOLD,15));
        jrb1.setForeground(Color.yellow);
        jrb2.setForeground(Color.yellow);
        jrb3.setForeground(Color.yellow);
       jrb3.setFont(new Font("宋体",Font.BOLD,15)); 
       jrb1.setFont(new Font("宋体",Font.BOLD,15)); 
       jrb2.setFont(new Font("宋体",Font.BOLD,15)); 	   
 	   sb = new JSlider(500,10000,delay);	
	  sb.setValue(delay);
	 this.setLayout(new GridLayout(7,1));
	 sb.setOpaque(false);
	 sb.addChangeListener(sl);
	 label1.setText(String.valueOf((double)(delay/100)/10));
	 g.add(jrb1);
	 g.add(jrb2);
	 g.add(jrb3);
	 jrb1.addActionListener(brl);
	 jrb2.addActionListener(brl);
	 jrb3.addActionListener(brl);
	 panel.add(label1);
      this.setOpaque(false);
	 panel.add(label);
	 textPanel.setLayout(new GridLayout(2,1));
	 textPanel.add(label2);
	 panel3.add(wordCountText);
	 textPanel.add(panel3);
	 sb.setPreferredSize(new Dimension(100,20) );
	  panel.add(sb);
	  this.add(panel);
	  this.add(jrb1);
	  this.add(jrb2);
	  this.add(jrb3);
	  this.add(textPanel);  
	  this.add(checkBox1);
	  this.add(checkBox2);
	  wordCountText.getDocument().addDocumentListener(new TextListen());
	  
	  wordCountText.setText(String.valueOf(ReadDat.wordCount));	
	  checkBox1.addActionListener(boxl);
		checkBox2.addActionListener(boxl);
		label2.setForeground(Color.yellow);
		checkBox1.setOpaque(false);
		checkBox2.setOpaque(false);
		textPanel.setOpaque(false);
		label2.setOpaque(false);
		panel3.setOpaque(false);
		jrb1.setOpaque(false);
		jrb2.setOpaque(false);
		jrb3.setOpaque(false);
	
	}
	
	public 
	
////////////////////////////////////////////////////////////////////////
////////////////	
class RadioButtonListener implements ActionListener
    {
    	public void actionPerformed(ActionEvent e)
    	{
    		if(e.getSource()==jrb1)
    		 {
    		 	jrb1.setEnabled(true);
    		 	order = 1;
    		 }
    		 
    		if(e.getSource()==jrb2)
    		 {
    		 	jrb2.setEnabled(true);
    		 	order = 2;
    		 }
    		 
    		if(e.getSource()==jrb3)
    		 {
    		 	jrb3.setEnabled(true);
    		 	order = 3;
    		 }
    	}
    }
/////////////////////////////////////////////////
///////////////
class TextListen implements DocumentListener
{
	public void insertUpdate(DocumentEvent e)
	{
		ReadDat.wordCount = Integer.parseInt(wordCountText.getText());
		System.out.println(ReadDat.wordCount+"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
	}
	public void removeUpdate(DocumentEvent e){}
	
	public void changedUpdate(DocumentEvent e){}
}

////////////////////////////////////////////////////////////
///////////
class SliderListener implements ChangeListener
    {
    	public void stateChanged(ChangeEvent e)
        {
          delay  = ((JSlider)(e.getSource())).getValue() ;
          label1.setText(String.valueOf((double)(delay/100)/10));
        }
    }

}
	

⌨️ 快捷键说明

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