Java computer secondary operation questions related to swing questions

Question Type One
Insert picture description here

import javax.swing.JOptionPane;  //导入JOptionPane类

public class a {
    
    
   public static void main( String args[] )
   {
    
    
//*********Found********
      JOptionPane.showMessageDialog(
         null, "欢迎\n你\n参加\nJava\n考试!" );
      System.exit( 0 );  // 结束程序,量为0时表示正常退出,为非零时表示非正常退出
   }
}
/* JOptionPane类的常用静态方法如下:
   showInputDialog()//输入对话框 
   showConfirmDialog()//确认对话框
   showMessageDialog()//消息对话框 
   showOptionDialog()//选择对话框
*/

Question type two
Insert picture description here
java code

//*********Found********
import java.applet.*;
//导入applet包中的Applet类, 说明要写的是小程序,是固定的格式。小程序都是要嵌入到浏览器中运行的。写完之后要写个HTML文件。
import java.awt.Graphics;
//Graphics是一个用来绘制2D图像必须导入的java包,提供对图形图像的像素,颜色的绘制。
//*********Found********
public class Java_1 extends Applet{
    
    
   public void paint( Graphics g )
   {
    
    
//*********Found********
      g.drawString( "欢迎你来参加Java 语言考试!", 25, 25 );
      //在这个位置绘制一个字符串,
   }
}

html code

<html>
<applet code="Java_1.class" width=300 height=45>
</applet>
/** 指定applet类名称,applet的宽度和高度。 **/
</html>

Guess you like

Origin blog.csdn.net/weixin_44931166/article/details/104066218