начинающий с использованием GUI и не может понять, почему это не добавляет поля в мой графический интерфейс. Он открывает фрейм, но он пуст. Ошибок нет. Любая помощь приветствуется.GUI, не добавляющий панели
import javax.swing.*;
import java.awt.*;
public class Project3 extends JFrame {
public Project3() {
//set layout
setLayout(new GridLayout(5, 2, 5, 5));
//add radio panel
JPanel radioPanel = new JPanel();
//set Radio Buttons
JRadioButton iter = new JRadioButton("Iteration", true);
JRadioButton recur = new JRadioButton("Recursion", true);
//add radio buttons to group
ButtonGroup radioGroup = new ButtonGroup();
radioGroup.add(iter);
radioGroup.add(recur);
radioPanel.add(iter);
radioPanel.add(recur);
recur.setSelected(true);
//add another panel
JPanel secondPanel = new JPanel();
secondPanel.setLayout(new GridLayout(4, 2, 5, 5));
//add text fields and button
JLabel enter = new JLabel("Enter n:");
JTextField eight = new JTextField(8);
//?????????????????????????????
JButton compute = new JButton("Compute");
JLabel result = new JLabel("Result:");
JTextField eight1 = new JTextField(8);
JLabel efficiency = new JLabel("Efficiency:");
JTextField eight2 = new JTextField(8);
//add items to panel
secondPanel.add(enter);
secondPanel.add(eight);
secondPanel.add(compute);
secondPanel.add(result);
secondPanel.add(eight1);
secondPanel.add(efficiency);
secondPanel.add(eight2);
add(radioPanel);
add(secondPanel);
}
public static void main(String[] args) {
// Create frame
JFrame frame = new JFrame("Project 3");
frame.setSize(400, 300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Спасибо Джеймс ... знал, что это был простой надзор. Ценю вашу помощь. – Brad