0
我在Eclipse Indigo中運行了此代碼,並且沒有框架作爲輸出打開,但是當我在BLUEJ中運行相同的代碼時,它正常工作並且框架打開。 Plz告訴我這個錯誤。Eclipse未打開框架窗口
這裏是我的代碼:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MainFrame extends JFrame
{
void MainFrame()
{
setTitle("Square's Root Finder");
setSize(350,100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLookAndFeel();
setVisible(true);
JButton but1 = new JButton("Calculate");
JLabel label1= new JLabel("Enter the number:");
JTextField t = new JTextField();
add(but1);
add(label1);
add(t);
}
private void setLookAndFeel() {
try {
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception exc) {
// ignore error
}
}
public static void main(String[] args)
{
MainFrame newFrame = new MainFrame();
}
}