|
|
@ -1,38 +1,38 @@
|
|
|
|
package me.goudham.view;
|
|
|
|
package me.goudham.view;
|
|
|
|
|
|
|
|
|
|
|
|
import me.goudham.ClipboardListener;
|
|
|
|
import java.awt.Dimension;
|
|
|
|
import me.goudham.listener.ClipboardEvent;
|
|
|
|
import java.awt.Image;
|
|
|
|
import me.goudham.model.MyClipboardContent;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.AbstractAction;
|
|
|
|
|
|
|
|
import javax.swing.Action;
|
|
|
|
|
|
|
|
import javax.swing.ActionMap;
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory;
|
|
|
|
import javax.swing.BorderFactory;
|
|
|
|
import javax.swing.DefaultListModel;
|
|
|
|
import javax.swing.DefaultListModel;
|
|
|
|
import javax.swing.InputMap;
|
|
|
|
import javax.swing.ImageIcon;
|
|
|
|
import javax.swing.JButton;
|
|
|
|
import javax.swing.JButton;
|
|
|
|
import javax.swing.JFrame;
|
|
|
|
import javax.swing.JFrame;
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
import javax.swing.JList;
|
|
|
|
import javax.swing.JList;
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
import javax.swing.JScrollPane;
|
|
|
|
import javax.swing.JScrollPane;
|
|
|
|
import javax.swing.KeyStroke;
|
|
|
|
import me.goudham.ClipboardListener;
|
|
|
|
import java.awt.Dimension;
|
|
|
|
import me.goudham.listener.ClipboardEvent;
|
|
|
|
import java.awt.Toolkit;
|
|
|
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
|
|
|
import java.awt.event.KeyEvent;
|
|
|
|
|
|
|
|
import java.awt.event.KeyListener;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class ClipboardView implements ClipboardEvent {
|
|
|
|
public class ClipboardView implements ClipboardEvent {
|
|
|
|
private JPanel Clipboard;
|
|
|
|
private JPanel Clipboard;
|
|
|
|
private JButton copyButton;
|
|
|
|
private JButton copySelectedTextButton;
|
|
|
|
private JList<String> clipboardContentList;
|
|
|
|
private JList<String> clipboardContentList;
|
|
|
|
private final DefaultListModel<String> listModel;
|
|
|
|
private final DefaultListModel<String> listModel;
|
|
|
|
private JLabel title;
|
|
|
|
private JLabel title;
|
|
|
|
private JScrollPane scrollPane;
|
|
|
|
private JScrollPane scrollPane;
|
|
|
|
private JPanel buttonPane;
|
|
|
|
private JPanel buttonPane;
|
|
|
|
private JButton clearButton;
|
|
|
|
private JButton clearAllHistoryButton;
|
|
|
|
private JButton removeButton;
|
|
|
|
private JButton removeButton;
|
|
|
|
|
|
|
|
private JLabel imageIconLabel;
|
|
|
|
|
|
|
|
private JLabel textClipboardLabel;
|
|
|
|
|
|
|
|
private JButton copyImageBelowButton;
|
|
|
|
|
|
|
|
private JButton removeImageBelowButton;
|
|
|
|
|
|
|
|
private JPanel imageButtonPanel;
|
|
|
|
|
|
|
|
private JPanel imagePanel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean resize = false;
|
|
|
|
|
|
|
|
|
|
|
|
public ClipboardView() {
|
|
|
|
public ClipboardView() {
|
|
|
|
scrollPane.setBorder(BorderFactory.createEmptyBorder());
|
|
|
|
scrollPane.setBorder(BorderFactory.createEmptyBorder());
|
|
|
@ -90,15 +90,23 @@ public class ClipboardView implements ClipboardEvent {
|
|
|
|
jFrame.setVisible(true);
|
|
|
|
jFrame.setVisible(true);
|
|
|
|
jFrame.setAlwaysOnTop(true);
|
|
|
|
jFrame.setAlwaysOnTop(true);
|
|
|
|
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
jFrame.setPreferredSize(new Dimension(1000, 680));
|
|
|
|
jFrame.setPreferredSize(new Dimension(1200, 900));
|
|
|
|
jFrame.setMaximumSize(new Dimension(1000, 680));
|
|
|
|
|
|
|
|
jFrame.setResizable(true);
|
|
|
|
jFrame.setResizable(true);
|
|
|
|
jFrame.pack();
|
|
|
|
jFrame.pack();
|
|
|
|
jFrame.setLocationRelativeTo(null);
|
|
|
|
jFrame.setLocationRelativeTo(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public <T> void onCopy(MyClipboardContent<T> copiedContent) {
|
|
|
|
public void onCopyString(String stringContent) {
|
|
|
|
listModel.add(0, copiedContent.getContent().toString());
|
|
|
|
listModel.add(0, stringContent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onCopyImage(BufferedImage imageContent) {
|
|
|
|
|
|
|
|
if (imageContent.getWidth() > 1000 || imageContent.getHeight() > 500) {
|
|
|
|
|
|
|
|
imageIconLabel.setIcon(new ImageIcon(new ImageIcon(imageContent).getImage().getScaledInstance(1000, 300, Image.SCALE_SMOOTH)));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
imageIconLabel.setIcon(new ImageIcon(imageContent));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|