Что означает FormProcessQueue().PanelBase

Рейтинг: 0Ответов: 1Опубликовано: 01.03.2015
frame.setContentPane(new FormProcessQueue().PanelBase);

Запись FormProcessQueue().PanelBase мне как-то не понятна...

public class FormProcessQueue {
    private JPanel PanelBase;
    private JTextArea queue1;
    private JTextArea queue2;

    public static void main() {
        JFrame frame = new JFrame("Очередь");
        frame.setContentPane(new FormProcessQueue().PanelBase);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }
...

Ответы

▲ 2

@Letfar Это обращение к полю PanelBase анонимного объекта new FormProcessQueue(). Все равно что ты напишешь вот так. И кстати, пиши названия полей с маленькой буквы. Не C# же.

private JPanel panelBase;
private JTextArea queue1;
private JTextArea queue2;

public static void main() {
    JFrame frame = new JFrame("Очередь");
    FormProcessQueue form=new FormProcessQueue();
    frame.setContentPane(form.panelBase);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}