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

📄 gui.java

📁 大一JAVA实习的题目
💻 JAVA
字号:

/**
 * Write a description of class GUI here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class GUI extends JFrame implements ActionListener
{
    private double a,b,c;
    private JLabel label1=new JLabel("a=");
    private JLabel label2=new JLabel("b=");
    private JLabel label3=new JLabel("c=");
    private JTextField aField=new JTextField(10);
    private JTextField bField=new JTextField(10);
    private JTextField cField=new JTextField(10);
    private JButton calcButton=new JButton("开始计算");
    private JTextArea outArea=new JTextArea(3,10);
    
    public GUI()
    {
        setTitle("三角形");
        setLayout(new FlowLayout());
        
        add(label1);
        add(aField);
        add(label2);
        add(bField);
        add(label3);
        add(cField);
        add(calcButton);
        add(outArea);
        
        calcButton.addActionListener(this);
        
        setSize(300,300);
        setVisible(true);
    }
    
    public void actionPerformed(ActionEvent e)
    {
        String Str1;
        String Text1=aField.getText();
        a=Double.parseDouble(Text1);
        String Text2=bField.getText();
        b=Double.parseDouble(Text2);
        String Text3=cField.getText();
        c=Double.parseDouble(Text3);
        
        sjx mysjx=new sjx(a,b,c);
        if(mysjx.pd())
            Str1="";
        else Str1="不";
            
        outArea.setText(Str1+"可以构成三角形\n");
        if(mysjx.pd())
            outArea.append(mysjx.xz());
    }
}

⌨️ 快捷键说明

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