Окно JFrame не открывается на Eclipse Java, но работает на IntelliJJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Окно JFrame не открывается на Eclipse Java, но работает на IntelliJ

Сообщение Anonymous »

Изображение, показывающее расположение каталогов. Я пишу простой код с графическим интерфейсом и хочу, чтобы в Eclipse отображался экран окна. В коде нет ошибок, но когда я нажимаю «Выполнить», экран окна не отображается. В коде нет ошибок, поскольку он работает на IntelliJ. Что я делаю не так?

Код: Выделить всё

package adventure;
import javax.swing.JFrame;

import java.awt.Color;

//import javax.swing.JFrame;
//
//import javax.swing.JFrame;

public class Game {

JFrame firstWindow;

public static void main(String[] args) {
new Game();
}

public Game() {

firstWindow = new JFrame();
//      setSize determines the dimension of the window panel we are creating
firstWindow.setSize(800,600);
//      setDefaultCloseOperation assures what happens if we press the 'X' button and EXIT_ON_CLOSE descibes the end
firstWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);;
//      getContentPane for the content and setBackground for the bg color
firstWindow.getContentPane().setBackground(Color.pink);
//      null is so that we can customize the layout
firstWindow.setLayout(null);
//      setVisible so that we can see the window
firstWindow.setVisible(true);

}

}

Сначала JFrames вызывал у меня ошибки, и я менял версии файлов JRE, но просто не мог получить экран окна.

Подробнее здесь: https://stackoverflow.com/questions/791 ... n-intellij
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»