1.GUIç¨åºè®¾è®¡(java)
2.ç¼åä¸ä¸ªJava GUI
3.jgl文件是什么意思
GUIç¨åºè®¾è®¡(java)
=====================第ä¸ä¸ªç±»=============================
/
***
* å®ç°äºç³»ç»è®¡ç®å¨è¿ç»æ"="åæ"+","-","*","/"è¿è¡ç´¯è®°è¿ç®ç模å¼
*
* */
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CalculatorFrame extends JFrame {
private JTextField txtDis = new JTextField("0", ); //æ¾ç¤ºææ¬æ¡
private JButton[] btnGrp = new JButton[]; //个æé®
private JPanel jpnMain = new JPanel(); //主é¢æ¿
private JPanel jpnNorth = new JPanel(); //ä¸é¢æ¿
private JPanel jpnSouth = new JPanel(); //ä¸é¢æ¿
private double numSaved; //ä¿åçåä¸ä¸ªæ°
private String operator = ""; //ä¿åçè¿ç®ç¬¦å·
private String lastPress = ""; //ä¸ä¸æ¬¡æçæé®ï¼"æ°å","è¿ç®ç¬¦" æ "çå·"ï¼
/*æé å½æ°*/
public CalculatorFrame() {
//çªå£è®¾ç½®
setTitle("计ç®å¨");
setSize(, );
buttonInit(); //æé®åå§å
//主é¢æ¿è®¾ç½®
add(jpnMain);
jpnMain.setLayout(null);
jpnMain.add(jpnNorth);
jpnMain.add(jpnSouth);
jpnMain.add(btnGrp[]);
btnGrp[].setBounds(8, , , ); //æ·»å â=âæé®
//ä¸é¢æ¿è®¾ç½®
jpnNorth.setBounds(8, , , );
jpnNorth.add(txtDis);
txtDis.setHorizontalAlignment(JTextField.RIGHT); //设置ææ¬å³å¯¹é½
txtDis.setEditable(false);
//ä¸é¢æ¿è®¾ç½®
jpnSouth.setBounds(8, , , );
jpnSouth.setLayout(new GridLayout(4, 4));
addSouthJpn(); //æ·»å 个æé®
//æ·»å çå¬å¨
addListener();
}
/*个æé®æ¾ç¤ºå¼åå§å*/
public void buttonInit() {
for (int i = 0; i < ; i++) {
btnGrp[i] = new JButton("" + i);
}
btnGrp[] = new JButton(".");
btnGrp[] = new JButton("+");
btnGrp[] = new JButton("-");
btnGrp[] = new JButton("*");
btnGrp[] = new JButton("/");
btnGrp[] = new JButton("=");
btnGrp[] = new JButton("C");
for (int i = 0; i < ; i++) {
btnGrp[i].setFont(new Font("Dialog", Font.PLAIN, ));
}
}
/*æç½æ ¼é¡ºåºæ·»å é¤â=âå¤ä¸ªæé®*/
public void addSouthJpn() {
int[] index={ 7,8,9,,4,5,6,,1,2,3,,0,,,};
for(int i=0;i<index.length;i++){
jpnSouth.add(btnGrp[index[i]]);
}
}
/*ç»æé®æ·»å çå¬å¨*/
public void addListener() {
//ç»æ°åæé®æ·»å çå¬å¨,btnGrp[]æ¯"."å·
for (int i = 0; i <= ; i++) {
btnGrp[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String button = ( (JButton) e.getSource()).getText();
//å¦ææè¿ç®æä½ç¬¦æææ¬æ¡æ°å为0并ä¸æé®ä¸ä¸ºâãâ
if (lastPress == "è¿ç®ç¬¦" || lastPress == "çå·"
|| txtDis.getText().equals("0") && button != ".") {
txtDis.setText(""); //æ¸ ç©ºææ¬æ¡
}
if (lastPress == "çå·") {
operator = ""; //ä¸æ¬¡æçæ¯=å·ï¼è¿æ¬¡ææ°åï¼æ¸ 空è¿ç®ç¬¦
}
if (button == "." && txtDis.getText().indexOf(".") != -1) {
} //è¿æ¬¡æçæ¯.ææ¬æ¡å å·²ç»å å«.è¿ç§æ åµä»ä¹é½ä¸å,é²æ¢.éå¤
else {
txtDis.setText(txtDis.getText() + button); //ææ¬æ¡æ·»å å 容
}
lastPress = "æ°å";
}
});
}
//ç»è¿ç®æä½ç¬¦æé®æ·»å çå¬å¨
for (int i = ; i <= ; i++) {
btnGrp[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (operator != "" && lastPress == "æ°å") { //è¿ç®ç¬¦ä¸ä¸ºç©ºå¹¶ä¸ä¹åæçæ¯æ°å
(btnGrp[].getActionListeners())[0].actionPerformed(e); //æå¨è°ç¨=å·ççå¬ååºå®ç°=å·åè½
}
numSaved = Double.parseDouble(txtDis.getText()); //ä¿åå½åææ¬æ¡çæ°å
operator = ( (JButton) e.getSource()).getText(); //ä¿åè¿ç®æä½ç¬¦
lastPress = "è¿ç®ç¬¦"; //æ·»å è¿ç®ç¬¦æ è®°ï¼ä¸æ¬¡ææ¬æ¡æ¸ 空
}
});
}
//ç»çå·æé®æ·»å çå¬å¨
btnGrp[].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
double numNow = Double.parseDouble(txtDis.getText()); //å½åææ¬æ¡çæ°å
//è¿ç®ç¬¦å¹é æä½
if (operator.equals("+")) {
txtDis.setText( (numSaved + numNow) + "");
}
else if (operator.equals("-")) {
if (lastPress == "çå·") { //累记è¿ç®æ¶çç®æ³ï¼ä¸ç´æçå·ï¼
txtDis.setText( (numNow - numSaved) + "");
}
else {
txtDis.setText( (numSaved - numNow) + "");
}
}
else if (operator.equals("*")) {
txtDis.setText( (numSaved * numNow) + "");
}
else if (operator.equals("/")) {
if (lastPress == "çå·") { //累记è¿ç®æ¶çç®æ³ï¼ä¸ç´æçå·ï¼
txtDis.setText( (numNow / numSaved) + "");
}
else {
txtDis.setText( (numSaved / numNow) + "");
}
}
if (lastPress != "çå·") { //æ¯ç¬¬ä¸æ¬¡,以åæ累记è¿ç®
numSaved = numNow; //ä¿åæ°æ¹ä¸ºåä¸ä¸ªæ°
}
lastPress = "çå·"; //æ·»å è¿ç®ç¬¦æ è®°ï¼ä¸æ¬¡ææ¬æ¡æ¸ 空
}
});
//ç»å¤ä½ç¬¦âCâæé®æ·»å çå¬å¨
btnGrp[].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
txtDis.setText("0");
numSaved = 0;
operator = "";
lastPress = "";
}
});
}
}
=====================第äºä¸ªç±»=============================
import javax.swing.*;
public class Test {
public Test() {
CalculatorFrame calframe = new CalculatorFrame(); //æ°çªå£
calframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //è®¾ç½®å ³é
calframe.setLocationRelativeTo(null); //çªå£ç½®ä¸
calframe.setVisible(true); //æ¾ç¤ºçªå£
calframe.setDefaultLookAndFeelDecorated(false); //使ç¨windowsè§æ
calframe.setResizable(false); //çªå£ä¸å¯è°å¤§å°
}
public static void main(String[] args) {
Test test = new Test();
}
}
ç¼åä¸ä¸ªJava GUI
è¯ä¸ä¸ä¸é¢ç代ç
ï¼å¦æç¹å»æé®å没æä»»ä½ååï¼å°çªå£æå°åä¸ä¸å°±æäºï¼
没æåºç°è¿ä¸ªé®é¢çè¯ï¼ä¹è¯·åè¯æä¸ä¸~
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class painting extends JFrame implements ActionListener{
private JButton round,rectangle,ellipse,beeline;
private JLabel xaxis,yaxis,remain,information;
private JTextField xTF,yTF;
private BorderLayout layout;
private Container cp;
private JPanel pCenter;
Vector<Object> v=new Vector<Object>(); //å®ä¹ä¸ä¸ªéåç±»ç¨äºåå¨æé®å¯¹è±¡
public painting(){ //æé æ¹æ³ ------------------æ¡æ¶åå§å-------------------
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("painting");
setSize(,);
layout = new BorderLayout();
cp = getContentPane();
cp.setLayout(layout);
round= new JButton("ç»å");
rectangle= new JButton("ç»ç©å½¢");
ellipse= new JButton("ç»æ¤å");
beeline= new JButton("ç»ç´çº¿");
xaxis=new JLabel("xåæ ");
yaxis=new JLabel("yåæ ");
remain=new JLabel("å³ä¸è§åæ (,) ");
xTF=new JTextField("0",5);
yTF=new JTextField("0",5);
JPanel pUp= new JPanel();//第ä¸ä¸ªé¢æ¿ å¨ä¸é¨
pUp.add(remain);
pUp.add(xaxis);//置两个ææ¬æ¡
pUp.add(xTF);
pUp.add(yaxis);
pUp.add(yTF);
cp.add(pUp, "North");
//pCenter=new JPanel();//第äºä¸ªé¢æ¿ å¨ä¸é¨
//pCenter.add(information);//ç½®æ¾ç¤ºè¯´æä¸ç»å¾åº
//cp.add(pCenter,"Center");
JPanel pDown= new JPanel();//第ä¸ä¸ªé¢æ¿ å¨ä¸é¨
pDown.add(round);// ç½®å个æé®
pDown.add(rectangle);
pDown.add(ellipse);
pDown.add(beeline);
cp.add(pDown, "South");
round.addActionListener(this); //ç½®æé®çå¬--------------æé®è¡ä¸ºçå¬ä¸ååº-------------
rectangle.addActionListener(this);
ellipse.addActionListener(this);
beeline.addActionListener(this);
}
public void actionPerformed(ActionEvent e) { //çå¬ååº
v.add(e.getSource());//å°æé®æ åµåå ¥vä¸
}
public void paint(Graphics g) { //--------------ç»å¾ååº-------------
super.paint(g);
int xx=Integer.parseInt(xTF.getText());//è·åä½ç½®å¼
int yy=Integer.parseInt(yTF.getText());
int size=0;
Object o;
//while(v.size()!=size){ //å½ç¨æ·ç¹å»æé®éæ©æä¸ç§å¾å½¢æ¶ï¼vç大å°å°±ä¼æ¯sizeå¼å¤§1ï¼å½ç»å¾å®æåï¼v.sizeåçäºsizeï¼ææå°±æ¯ï¼åºç°ç¹å» å³å»å¤ç
o=v.lastElement();
if(o == round) { g.drawOval(xx,yy,,);}
else if (o == rectangle){ g.drawRect(xx,yy,,);}
else if (o == ellipse) { g.drawOval(xx,yy,,);}
else if(o == beeline) { g.drawLine(xx,yy,xx+,yy);}
size++;
}
}
public static void main(String[] args){ // ------------ç¨åºå ¥å£-------------
JFrame frame = new painting();
frame.setVisible(true);
}
}
jgl文件是什么意思
根据我的搜索,JGL文件可以指多个不同类型的文件,具体取决于上下文和应用程序。
以下是够级游戏源码一些JGL文件类型及其含义:
1. JGL script File:JGL脚本文件是Java GUI语言(JGL)的源代码文件。JGL是一个基于Java的用户界面框架,用于创建和管理GUI应用程序。tinyalsa工具源码JGL脚本文件通常包含GUI控件的定义和其属性设置。
2. JGraph Layout File:JGraph是一个用于创建和显示图形的Java库。JGL文件可以指JGraph中的布局文件,该文件包含有关图形布局和排列的信息,例如节点位置和边的路径。
3. Jigsaw Glue File:Jigsaw是Java平台的一个模块系统。JGL文件可以是翻牌游戏源码Jigsaw Glue文件,用于指定模块之间的依赖关系和模块规范等信息。这些文件通常用于构建和管理Java模块化应用程序。
4. JGlobalLab Project File:JGlobalLab是ifconfig的源码一个用于科学计算和数据分析的Java应用程序。JGL文件可以是JGlobalLab项目文件,包含项目设置、数据文件和计算脚本等信息。纸牌 游戏 源码因此,需要更具上下文判断JGL文件的具体类型和含义。