小编use*_*275的帖子

Java中的不稳定GUI

我正在编写一个非常简单的GUI,它包含3个按钮,2个标签,2个文本字段和一个文本区域.奇怪的是,结果是不稳定的:当运行类时,GUI会出现随机数量的控件.我尝试了各种布局管理器,改变了控件之间的顺序 - 没有.

有人可以帮忙吗?

package finaltestrunner;

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

public class FinalTestGUI extends JFrame implements ActionListener
{   
public Boolean startState = false;

    JButton sofButton;
    JButton startStopButton;
    JButton exitButton;
        JTextField loopCounts;        
        JTextField trSnField;        
        JTextArea resultField = null;

    public FinalTestGUI() 
    {
// The constructor creates the panel and places the controls
    super();    // Jframe constructor

    JFrame trFrame = new JFrame();
    trFrame.setSize(1000, 100);
    trFrame.setVisible(true);
    trFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    trFrame.setTitle("Test runner");
    setFont(new Font("SansSerif", Font.PLAIN, 14));
//  trFrame.setLayout(new FlowLayout());

    JPanel trControlPanel = new JPanel();
    trControlPanel.setSize(1000, …
Run Code Online (Sandbox Code Playgroud)

java user-interface swing controls

1
推荐指数
1
解决办法
210
查看次数

标签 统计

controls ×1

java ×1

swing ×1

user-interface ×1