|
|
@@ -1,6 +1,10 @@
|
|
|
package com.leanwo.management.console;
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
|
+import java.awt.Rectangle;
|
|
|
+import java.awt.Toolkit;
|
|
|
+import java.awt.datatransfer.Clipboard;
|
|
|
+import java.awt.datatransfer.StringSelection;
|
|
|
import java.awt.event.ActionEvent;
|
|
|
import java.awt.event.ActionListener;
|
|
|
import java.util.Date;
|
|
|
@@ -19,6 +23,7 @@ public class LogConsole extends JPanel{
|
|
|
private JTextArea textArea;
|
|
|
private JCheckBox autoScrollCheckBox;
|
|
|
private JButton clearButton;
|
|
|
+ private JButton copyButton;
|
|
|
|
|
|
private Process process;
|
|
|
|
|
|
@@ -34,6 +39,8 @@ public class LogConsole extends JPanel{
|
|
|
/** 自动滚动 */
|
|
|
private boolean autoScroll;
|
|
|
|
|
|
+ Clipboard clipboard;
|
|
|
+
|
|
|
public LogConsole(String name) {
|
|
|
this.name = name;
|
|
|
initData();
|
|
|
@@ -101,14 +108,33 @@ public class LogConsole extends JPanel{
|
|
|
autoScrollCheckBox = new JCheckBox("自动滚动");
|
|
|
autoScrollCheckBox.setSelected(autoScroll);
|
|
|
bottomPanel.add(autoScrollCheckBox, BorderLayout.WEST);
|
|
|
+
|
|
|
+ copyButton=new JButton("复制日志");
|
|
|
+ bottomPanel.add(copyButton, BorderLayout.EAST);
|
|
|
|
|
|
clearButton=new JButton("清空");
|
|
|
bottomPanel.add(clearButton);
|
|
|
+
|
|
|
|
|
|
setLayout(new BorderLayout());
|
|
|
add(new JScrollPane(textArea),BorderLayout.CENTER);
|
|
|
add(bottomPanel,BorderLayout.SOUTH);
|
|
|
|
|
|
+ copyButton.addActionListener(new ActionListener() {
|
|
|
+ @Override
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ //创建能传输指定 String 的 Transferable。
|
|
|
+ StringSelection editText =
|
|
|
+ new StringSelection(textArea.getText());
|
|
|
+ /**
|
|
|
+ 将剪贴板的当前内容设置到指定的 transferable 对象,
|
|
|
+ 并将指定的剪贴板所有者作为新内容的所有者注册。
|
|
|
+ */
|
|
|
+ clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
|
|
+ clipboard.setContents(editText,editText);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
clearButton.addActionListener(new ActionListener() {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|