⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 messagebox.java

📁 用Java写的面相对象的数据库管理系统
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.//// $Id: MessageBox.java,v 1.7 2000/10/28 16:55:20 daniela Exp $package org.ozoneDB.tools;import java.awt.*;import java.awt.event.*;public class MessageBox extends Dialog {    public static int YES = 1;    public static int NO = 2;    public static int CANCEL = 4;    public static int OK = 8;    public static int CONFIRM = 16;    static int choice;            class MBButton extends Button implements ActionListener {        int kind;                        public MBButton( String title, int _kind ) {            super( title );            kind = _kind;            addActionListener( this );        }                        public void actionPerformed( ActionEvent e ) {            ((MessageBox)getParent()).choice = kind;            ((MessageBox)getParent()).close();        }     }            MessageBox( Frame parent, String msg, int buttons ) {        super( parent, true );        setLayout( new GridBagLayout() );        GridBagConstraints c = new GridBagConstraints();        c.weightx = 1.0;        c.weighty = 1.0;        c.fill = GridBagConstraints.NONE;        c.anchor = GridBagConstraints.CENTER;        c.gridwidth = GridBagConstraints.REMAINDER;        add( new Label( msg ), c );        c.fill = GridBagConstraints.BOTH;        c.gridwidth = GridBagConstraints.RELATIVE;        if ((buttons & YES) != 0) {            add( new MBButton( "YES", YES ), c );        }         if ((buttons & NO) != 0) {            add( new MBButton( "NO", NO ), c );        }         if ((buttons & CANCEL) != 0) {            add( new MBButton( "CANCEL", CANCEL ), c );        }         if ((buttons & OK) != 0) {            add( new MBButton( "OK", OK ), c );        }         if ((buttons & CONFIRM) != 0) {            add( new MBButton( "CONFIRM", CONFIRM ), c );        }         setSize( 20 + msg.length() * 7, 80 );        setLocation( 200, 200 );        show();    }            public void close() {        setVisible( false );    }             public static int YesNoBox( Frame parent, String msg ) {        new MessageBox( parent, msg, YES | NO );        return choice;    }             public static int OkCancelBox( Frame parent, String msg ) {        new MessageBox( parent, msg, OK | CANCEL );        return choice;    }             public static int ConfirmBox( Frame parent, String msg ) {        new MessageBox( parent, msg, CONFIRM );        return choice;    } }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -