正在加载图片...
Applet vs application WelcomeApplet java: Applet for displaying a message import javax. swing. X public class WelcomeApplet extends JApplet /*大工 nitia1 ize the app1et public void init() add(new JLabel (" Welcome to Java JLabel center))i import javax. swIng.大 public class My FrameWithlable public static void main(String[] args)i JFrame frame new JFrame("My FrameWithLable")i frame. add (new JLabel(" Welcome to Java", Jlabel center))i frame setsize(400, 300) frame setvisible(true)i frame setDefaultCloseOperation (JFrame EXIT ON CLOSE)i frame. setLocationRelativeTo(null);// New since JDK 1.4 Liang, Introduction to Java Programming, Sixth Edition, (c)2005 Pearson Education, Inc. All rights reserved. 0-13-148952-6Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved. 0-13-148952-6 6 Applet vs. Application import javax.swing.*; public class MyFrameWithlable{ public static void main(String[] args) { JFrame frame = new JFrame("MyFrameWithLable"); frame.add(new JLabel("Welcome to Java", JLabel.CENTER)); frame.setSize(400, 300); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); // New since JDK 1.4 } } // WelcomeApplet.java: Applet for displaying a message import javax.swing.*; public class WelcomeApplet extends JApplet { /** Initialize the applet */ public void init() { add(new JLabel("Welcome to Java", JLabel.CENTER)); } }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有