📄 xjavaconsole.java
字号:
/****************************************************************
* XBrowser - eXtended web Browser *
* *
* Copyright (c) 2000-2001 Armond Avanes *
* Refer to ReadMe & License files for more information *
* *
* *
* By: Armond Avanes *
* Armond555@yahoo.com & Armond333@yahoo.com *
* http://xbrowser.sourceforge.net/ *
*****************************************************************/
package xbrowser.plugin.defaults.javaconsole;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import xbrowser.plugin.*;
import xbrowser.options.*;
public class XJavaConsole extends JPanel implements XGUIPlugin
{
public void init()
{
txaConsole.setEditable(false);
setLayout( new BorderLayout() );
add(new JScrollPane(txaConsole), BorderLayout.CENTER);
add(getButtonsPanel(),BorderLayout.SOUTH);
try
{
PrintStream output = new PrintStream( new XOutputStream() );
System.setOut(output);
System.setErr(output);
}
catch( Exception e )
{
context.getLogger().error(this, "Error on redirecting the streams !!");
context.getLogger().error(this, e);
}
setPreferredSize( new Dimension(500,350) );
}
public void start()
{
}
public void stop()
{
}
public void destroy()
{
}
public void setContext(XPluginContext context)
{
this.context = context;
context.getResourceManager().initResourceBundle("XJavaConsole");
}
public Component getComponent()
{
return this;
}
public String getTitle()
{
return context.getResourceManager().getProperty(this, "Title");
}
public XOptionPage getOptionPage()
{
return null;
}
private JPanel getButtonsPanel()
{
JPanel pnl_main = new JPanel(new FlowLayout());
JPanel pnl = new JPanel(new GridLayout(1,3,20,0));
pnl.add(context.getComponentBuilder().buildButton(new ClearAction()));
pnl.add(context.getComponentBuilder().buildButton(new CopyAction()));
pnl_main.add(pnl);
return pnl_main;
}
private class ClearAction extends XPluginAction
{
public ClearAction()
{
super(XJavaConsole.this, "Clear", null, XJavaConsole.this.context);
}
public void actionPerformed(ActionEvent e)
{
txaConsole.setText("");
}
}
private class CopyAction extends XPluginAction
{
public CopyAction()
{
super(XJavaConsole.this, "Copy", null, XJavaConsole.this.context);
}
public void actionPerformed(ActionEvent e)
{
txaConsole.copy();
}
}
private class XOutputStream extends OutputStream
{
public synchronized void write(int b) throws IOException
{
txaConsole.append(""+((char)b));
}
}
// Attributes:
private JTextArea txaConsole = new JTextArea(20,10);
private XPluginContext context;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -