mirror of
https://github.com/DanilaFe/abacus
synced 2024-12-22 23:40:08 -08:00
Add copy pasting to history.
This commit is contained in:
parent
d746db8c9f
commit
81c774fcf4
|
@ -6,6 +6,9 @@ import org.nwapw.abacus.tree.TreeNode;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.datatransfer.StringSelection;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main UI window for the calculator.
|
* The main UI window for the calculator.
|
||||||
|
@ -177,5 +180,17 @@ public class Window extends JFrame {
|
||||||
lastOutputArea.setText(lastOutput);
|
lastOutputArea.setText(lastOutput);
|
||||||
inputField.setText(lastOutput);
|
inputField.setText(lastOutput);
|
||||||
});
|
});
|
||||||
|
historyTable.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
Point clickPoint = e.getPoint();
|
||||||
|
if(e.getClickCount() == 2){
|
||||||
|
int row = historyTable.rowAtPoint(clickPoint);
|
||||||
|
int column = historyTable.columnAtPoint(clickPoint);
|
||||||
|
String toCopy = historyTable.getValueAt(row, column).toString();
|
||||||
|
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(toCopy), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user