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

📄 jinfoframe.java

📁 JavaExplorer是一个独立于平台的浏览器
💻 JAVA
字号:
/**  * File and FTP Explorer  * Copyright 2002  * BOESCH Vincent  *  * This program is free software; you can redistribute it and/or  * modify it under the terms of the GNU General Public License  * as published by the Free Software Foundation; either version 2  * of the License, or (at your option) any later version.  *  * This program is distributed in the hope that it will be useful,  * but WITHOUT ANY WARRANTY; without even the implied warranty of  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  * GNU General Public License for more details.  *  * You should have received a copy of the GNU General Public License  * along with this program; if not, write to the Free Software  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  */package javaexplorer.gui.internal;import java.awt.*;import java.awt.event.*;import javaexplorer.ressource.*;import javax.swing.*;import javax.swing.border.*;import javax.swing.text.DefaultStyledDocument;import javax.swing.text.MutableAttributeSet;import javax.swing.text.SimpleAttributeSet;import javax.swing.text.StyleConstants;/** *@author     BOESCH Vincent *@created    21 janvier 2002 *@version    3.3 */public class JInfoFrame extends JInternalFrame implements ActionListener {    private BorderLayout borderLayout1 = new BorderLayout();    private JPanel jPanel1 = new JPanel();    private JButton jbtClear = new JButton();    private JButton jbtHide = new JButton();    private JCheckBox jcbAlwaysPopup = new JCheckBox();    private JPanel jpnlInfo = new JPanel();    private JTextPane jtpInfo = new JTextPane();    private TitledBorder titledBorder1;    private JScrollPane jScrollPane1 = new JScrollPane(jtpInfo);    DefaultStyledDocument doc = new DefaultStyledDocument();        public static final int DEBUG = 0;    public static final int INFO = 1;    public static final int ERROR = 2;        private Color colorDebug = Color.BLUE;    private Color colorInfo = Color.BLACK;    private Color colorError = Color.RED;            /**     *  Constructeur objet JInfoFrame     *     *@param  showOnStart  Description of the     *      Parameter     */    public JInfoFrame(boolean showOnStart) {        super("Info", true, true, false, false);        jcbAlwaysPopup.setSelected(showOnStart);                try {            jbInit();        } catch (Exception e) {            javaexplorer.util.Log.addError(e);        }    }    /**     *@param  e  Description of the Parameter     */    public void actionPerformed(ActionEvent e) {        Object obj = e.getSource();        if (obj == jbtClear) {            jtpInfo.setText("");        } else if (obj == jbtHide) {            this.setVisible(false);        }    }    /**     *  Adds a feature to the Message attribute     *  of the JInfoFrame object     *     *@param  message  The feature to be added     *      to the Message attribute     */    public void addMessage(String message, int level) {    	Color color = null;    	ImageIcon icon = null;        if (message != null) {        	switch(level){        	case ERROR:        		color = colorError;        		icon = ImageRessource.iconError;        		break;        	case DEBUG:        		color = colorDebug;        		icon = ImageRessource.iconDebug;        		break;        	case INFO:        	default:        		color = colorInfo;        		icon = ImageRessource.iconInfo;        		break;        		        	}        	try{        		jtpInfo.setEditable(true);                jtpInfo.setCaretPosition(doc.getLength() );        	    jtpInfo.insertIcon(icon);        	    jtpInfo.setEditable(false);        	            	    MutableAttributeSet attr = new SimpleAttributeSet();        	    StyleConstants.setForeground(attr, color);        		doc.insertString(doc.getLength(),                     " " + message + "\n" , attr);                jtpInfo.setCaretPosition(doc.getLength() );                     	}catch( Exception ioe ){        		javaexplorer.util.Log.addError(ioe);        	}        	        }    }            /**     *@throws  Exception  Description of the     *      Exception     */    private void jbInit() throws Exception {        Font defaultFont = new java.awt.Font("Dialog", 1, 10);                this.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);        this.setTitle("Info");        titledBorder1 = new TitledBorder("");        jpnlInfo.setLayout(borderLayout1);        jbtHide.setText("Hide");        jbtClear.setText("Clear");        jbtClear.addActionListener(this);        jbtHide.addActionListener(this);        jpnlInfo.setBorder(titledBorder1);        jtpInfo.setToolTipText("");        jtpInfo.setFont(defaultFont);        jtpInfo.setStyledDocument(doc);        jtpInfo.setEditable(false);                jcbAlwaysPopup.setText("Always Display for Each Message");        jpnlInfo.add(jScrollPane1, BorderLayout.CENTER);        jpnlInfo.add(jPanel1, BorderLayout.SOUTH);        jPanel1.add(jbtClear, null);        jPanel1.add(jbtHide, null);        jPanel1.add(jcbAlwaysPopup, null);        this.getContentPane().setLayout(new BorderLayout());        this.getContentPane().add(jpnlInfo, BorderLayout.CENTER);        if (ImageRessource.iiInfo != null) {            this.setFrameIcon(ImageRessource.iiInfo);        }        setBounds(10, 10, 600, 250);        setOpaque(true);    }    /**     *@return    Description of the Return     *      Value     */    public boolean needsToDisplay() {        return jcbAlwaysPopup.isSelected();    }}

⌨️ 快捷键说明

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