import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SimultaneousSolver extends JFrame implements ActionListener
{
JTextField tfEQ1X = new JTextField (20);
JTextField tfEQ1Y = new JTextField (20);
JTextField tfEQ1Num = new JTextField (20);
JTextField tfEQ2X = new JTextField (20);
JTextField tfEQ2Y = new JTextField (20);
JTextField tfEQ2Num = new JTextField (20);
JLabel lblX1 = new JLabel ("X₁");
JLabel lblY1 = new JLabel ("Y₁");
JLabel lblNum1 = new JLabel ("Number₁");
JLabel lblEqual1 = new JLabel ("=");
JLabel lblX2 = new JLabel ("X₂");
JLabel lblY2 = new JLabel ("Y₂");
JLabel lblNum2 = new JLabel ("Number₂");
JLabel lblEqual2 = new JLabel ("=");
JTextArea Empty = new JTextArea ("",1,20);
double X1, X2, Y1, Y2, Num1, Num2;
double SolX, SolY;
Font font = new Font("Comic Sans MS", Font.BOLD, 14);
SimultaneousSolver()
{
super ("Simultaneous Equation Solver");
setDesign();
setSize(700,400);
setResizable(false);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel panelEquation1 = new JPanel(new GridLayout(1,7));
{
panelEquation1.add(lblX1);
panelEquation1.add(tfEQ1X);
panelEquation1.add(lblY1);
panelEquation1.add(tfEQ1Y);
panelEquation1.add(lblEqual1);
panelEquation1.add(lblNum1);
panelEquation1.add(tfEQ1Num);
}
JPanel panelEquation2 = new JPanel(new GridLayout(1,7));
{
panelEquation2.add(lblX2);
panelEquation2.add(tfEQ2X);
panelEquation2.add(lblY2);
panelEquation2.add(tfEQ2Y);
panelEquation2.add(lblEqual2);
panelEquation2.add(lblNum2);
panelEquation2.add(tfEQ2Num);
}
setVisible(true);
}
public final void setDesign()
{
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
}
catch(Exception e)
{
}
}
public static void main(String[] args)
{
new SimultaneousSolver();
}
}
好吧,所以我正在使用纯粹的swing开始一个新的应用程序开发,所以我设置了我的对象和东西,当我尝试运行应用程序以查看它是否看起来不错时,除了空容器外什么都没有显示。
答案 0 :(得分:0)
在构造函数的末尾添加这两行。
setLayout(new GridLayout()); // sets layout for frame - you can choose any one suitable layout
add(panelEquation1); // adds 1st panel
add(panelEquation2); // adds 2nd panel