📄 text4.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.Graphics;
import java.awt.Image;
public class Text4 extends JFrame implements ActionListener
{
JLabel JL1,JL2,JL3;
JTextField jt1,jt2,jt3;
JButton jb1,jb2;
Canvas c;
public Text4()
{
this.setTitle("aa");
Container cc=getContentPane();
cc.setLayout(null);
// Panel p=new Panel();
JL1=new JLabel("X坐标");
JL1.setBounds(10,10,60,20);
cc.add(JL1);
jt1=new JTextField();
jt1.setBounds(80,10,60,20);
cc.add(jt1);
JL2=new JLabel("Y坐标");
JL2.setBounds(150,10,60,20);
cc.add(JL2);
jt2=new JTextField();
jt2.setBounds(220,10,60,20);
cc.add(jt2);
JL3=new JLabel("半径");
JL3.setBounds(300,10,60,20);
cc.add(JL3);
jt3=new JTextField();
jt3.setBounds(370,10,60,20);
cc.add(jt3);
jb1=new JButton("确定");
jb1.setBounds(450,10,60,20);
cc.add(jb1);
jb1.addActionListener(this);
jb2=new JButton("重置");
jb2.setBounds(530,10,60,20);
cc.add(jb2);
jb2.addActionListener(this);
c=new Canvas();
cc.add(c);
// c.setBackground(Color.cyan);
c.setBounds(40,80,300,200);
this.setBounds(10,10,800,600);
this.setVisible(true);
}
public static void main(String args[])
{
Text4 aaa=new Text4();
}
public void actionPerformed (ActionEvent e)
{
if(e.getSource()==jb1)
{
int a1=Integer.parseInt(jt1.getText());
int a2=Integer.parseInt(jt2.getText());
int a3=Integer.parseInt(jt3.getText());
c.getGraphics().drawOval(a1,a2,a3,a3);
}
if(e.getSource()==jb2)
{
c.repaint();
jt1.setText("");
jt2.setText("");
jt3.setText("");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -