在主方法调用JFrame出错?
packageservers;importjava.awt.*;importjavax.swing.*;publicclassmainclass{publicclassc...
package servers;
import java.awt.*;
import javax.swing.*;
public class mainclass {
public class ct1 extends JFrame{
public void CreateJframe(String title) {
JFrame jf = new JFrame(title);
Container container = jf.getContentPane();
JLabel jl = new JLabel("new thing");
jl.setHorizontalAlignment(SwingConstants.CENTER);
container.add(jl);
container.setBackground(Color.gray);
jf.setVisible(true);
jf.setSize(400, 300);
jf.setDefaultCloseOperation(HIDE_ON_CLOSE);
}
}
public static void main(String[] args) {
new ct1().CreateJframe("hey1");
System.out.println("hey");
}
} 展开
import java.awt.*;
import javax.swing.*;
public class mainclass {
public class ct1 extends JFrame{
public void CreateJframe(String title) {
JFrame jf = new JFrame(title);
Container container = jf.getContentPane();
JLabel jl = new JLabel("new thing");
jl.setHorizontalAlignment(SwingConstants.CENTER);
container.add(jl);
container.setBackground(Color.gray);
jf.setVisible(true);
jf.setSize(400, 300);
jf.setDefaultCloseOperation(HIDE_ON_CLOSE);
}
}
public static void main(String[] args) {
new ct1().CreateJframe("hey1");
System.out.println("hey");
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询