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

📄 test.java

📁 单词查询系统 用java实现 界面美观大方 可以进行存取 查询等功能
💻 JAVA
字号:
package program;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import support.*;
public class test extends JFrame implements ActionListener{

	/**
	 * @param args
	 */
	public ALabel l=new ALabel("hello\nhello\nnijkjlh");
	Label lbl=new Label("NIHAO");
	JButton btn=new JButton("start");
	JButton btn2=new JButton("change");
	JTextField txt=new JTextField();
	JTextField txt2=new JTextField("wanted width");
	JTextField txt3=new JTextField("wanted height");
	ImageIcon im=new ImageIcon("test.gif");
	WordList wl=new WordList();
	Dimension Size =this.getSize();
	String h[]={"hello","fuc\nk","girl","paney","a","b","c","d","kjhg","jhkjh"};
	JLabel lbl2[]=new JLabel[2];
	 JList storlst;//当前所查询的柱体存储空间内的单词
	 JComboBox jbox;//
	 JScrollPane  stoPane=new  JScrollPane(storlst);
    boolean conter=true;
	public test()
	{
		super("test");
		Container c =this.getContentPane();
		c.setLayout(new GridLayout(2,7));
		//c.setLayout(null);
		 lbl2[0]=new JLabel("baby1");
		 lbl2[1]=new JLabel("baby2");
		c.add(l);
		c.add(lbl);
		c.add(btn);
		c.add(txt);
		c.add(btn2);
		c.add(txt2);
		c.add(txt3);
		
		storlst=new JList(h);
		jbox=new JComboBox(h);
		c.add(jbox);
		c.add(storlst);
		stoPane=new  JScrollPane(storlst);
		c.add(stoPane);
		this.setBackground(Color.BLACK);
		txt.requestFocus();
		btn2.addActionListener(this);
		Size=this.getSize();
		txt2.setText(""+Size.getWidth()+","+Size.getHeight()+"");
		//btn2.setSize(20,50);
		//btn2.setLocation(0,300);
		txt.addActionListener(this);
		btn.addActionListener(this);	
		l.setSize(30,30);
		l.setLocation(0,0);
		//l.setLeft(5);
		//l.setTop(10);
		//l.strpack();
		l.setIcon(im);
		l.setRecycle(false);
		l.setBackColor(new Color(0.2f,0.3f,0.5f,0.7f));	
		this.pack();
		//this.setResizable(false);
		//this.setSize(500,500);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			//得到系统默认外观
		      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		    }catch(Exception e) {}
		    
         test t2=new test();
         t2.show();
	}
	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource().equals(btn)){
		
		l.Start(30);
		
		}
		if(e.getSource().equals(txt))
		{
			if(txt.getText().equals("start"))
			{
				l.Start(30);
			}
			if(txt.getText().equals("stop"))
			{
				l.Stop();
			}
			if(txt.getText().equals("pause"))
			{
				l.Pause();
			}
			if(txt.getText().equals("restart"))
					{
				l.Restart(50);
					}
		txt.setText("");
		}
		if(e.getSource().equals(btn2))
		{
			
		}
	}
	public void paint(Graphics g)
	{
		super.paint(g);
		Size=this.getSize();
		txt2.setText(""+Size.getWidth()+","+Size.getHeight()+"");
		txt3.setText("lst"+storlst.getWidth());
	}

}

⌨️ 快捷键说明

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