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

📄 gride.java

📁 This is the simple java random style generator. user can change the style, fill the style color.
💻 JAVA
字号:
//NG ENG SHEN
//A120358

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

public class GridE extends JApplet implements ActionListener {



private JTextField inputTX1,inputTX2;
private JLabel inputLB, xSimbol;
private JPanel panel;
private JButton okBT;
private JButton color1BT,color2BT;
private JButton refreshBT;
GraphicPanelE image = new GraphicPanelE();

public void init(){
	
	Container pane = getContentPane();
	inputTX1 = new JTextField("10",3);
	inputTX2 = new JTextField("10",3);
	inputLB = new JLabel("Bil Grid: ");
	xSimbol = new JLabel("X");
	panel = new JPanel();
	okBT = new JButton("OK");
	color1BT= new JButton("Colour 1");
	color2BT= new JButton("Colour 2");
	refreshBT = new JButton("Refresh");
	
	
	panel.add(inputLB);
	panel.add(inputTX1);
	panel.add(xSimbol);
	panel.add(inputTX2);
	panel.add(okBT);
	panel.add(color1BT);
	panel.add(color2BT);
	panel.add(refreshBT);
	okBT.addActionListener(this);
	color1BT.addActionListener(this);
	color2BT.addActionListener(this);
	refreshBT.addActionListener(this);
	
	pane.add(panel,BorderLayout.NORTH);
	pane.add(image,BorderLayout.CENTER);
	
}

public void actionPerformed(ActionEvent e){

	if(e.getSource()==okBT){
	image.setRandom(false);
	int ipt1=10,ipt2=10;
	ipt1 = Integer.parseInt(inputTX1.getText());
	ipt2 = Integer.parseInt(inputTX2.getText());
	image.setGrid(ipt1,ipt2);
	    repaint();

	}
	if(e.getSource()==color1BT)
	{
		Color color = JColorChooser.showDialog(this, "Color Chooser", image.getBColor());
		image.setBColor(color);
		repaint();
		
	}
	
	if(e.getSource()==color2BT)
	{
		Color color = JColorChooser.showDialog(this, "Color Chooser", image.getFColor());
		image.setFColor(color);
		repaint();
		
	}
	
	if(e.getSource()==refreshBT)
	{
		image.setRandom(true);
		image.setRandomValue();
		repaint();
	}



}

}



⌨️ 快捷键说明

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