Console.java
上传用户:u_thks
上传日期:2022-07-31
资源大小:1910k
文件大小:1k
- package com.gamvan.swing;
- import javax.swing.*;
- import java.awt.event.*;
- public class Console {
- public static String title(Object o){
- String t = o.getClass().toString();
- if(t.indexOf("class")!=-1){
- t = t.substring(6);
- }
- return t;
- }
- public static void setupClosing(JFrame frame){
- frame.addWindowListener(new WindowAdapter(){
- public void windowClosing(WindowEvent e){
- System.exit(0);
- }
- });
- }
- public static void run(JFrame frame, int width, int height){
- setupClosing(frame);
- frame.setSize(width, height);
- frame.setVisible(true);
- }
- public static void run(JApplet applet, int width, int height){
- JFrame frame = new JFrame(title(applet));
- setupClosing(frame);
- frame.getContentPane().add(applet);
- frame.setSize(width, height);
- applet.init();
- applet.start();
- frame.setVisible(true);
- }
- public static void run(JPanel panel, int width, int height){
- JFrame frame = new JFrame(title(panel));
- setupClosing(frame);
- frame.getContentPane().add(panel);
- frame.setSize(width, height);
- frame.setVisible(true);
- }
-
- }