Update GUI & Auto-generate source code for GUI

main
Hammy 3 years ago
parent 0a271b6da7
commit f7a38da31e

@ -21,15 +21,15 @@
</constraints> </constraints>
<properties> <properties>
<autoscrolls value="true"/> <autoscrolls value="true"/>
<background color="-16710887"/> <background color="-263169"/>
<continuousLayout value="true"/> <continuousLayout value="true"/>
<foreground color="-16710887"/> <foreground color="-263169"/>
<oneTouchExpandable value="true"/> <oneTouchExpandable value="true"/>
<opaque value="true"/> <opaque value="true"/>
<orientation value="0"/> <orientation value="1"/>
<preferredSize width="300" height="250"/> <preferredSize width="300" height="250"/>
</properties> </properties>
<border type="none"/> <border type="etched"/>
<children> <children>
<scrollpane id="681c6" binding="imageScrollPane"> <scrollpane id="681c6" binding="imageScrollPane">
<constraints> <constraints>
@ -47,7 +47,7 @@
<preferredSize width="300" height="300"/> <preferredSize width="300" height="300"/>
<verticalScrollBarPolicy value="20"/> <verticalScrollBarPolicy value="20"/>
</properties> </properties>
<border type="none"/> <border type="empty"/>
<children> <children>
<component id="a0714" class="javax.swing.JLabel" binding="imageLabel"> <component id="a0714" class="javax.swing.JLabel" binding="imageLabel">
<constraints/> <constraints/>
@ -57,7 +57,7 @@
<horizontalAlignment value="0"/> <horizontalAlignment value="0"/>
<horizontalTextPosition value="0"/> <horizontalTextPosition value="0"/>
<opaque value="true"/> <opaque value="true"/>
<text value=""/> <verifyInputWhenFocusTarget value="true"/>
</properties> </properties>
</component> </component>
</children> </children>
@ -96,7 +96,7 @@
</scrollpane> </scrollpane>
</children> </children>
</splitpane> </splitpane>
<grid id="865e3" binding="imageButtonPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="true" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="865e3" binding="imageButtonPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="true" same-size-vertically="true" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/> <margin top="0" left="0" bottom="0" right="0"/>
<constraints> <constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@ -104,8 +104,7 @@
</constraints> </constraints>
<properties> <properties>
<background color="-16710887"/> <background color="-16710887"/>
<minimumSize width="367" height="30"/> <preferredSize width="389" height="30"/>
<preferredSize width="367" height="30"/>
</properties> </properties>
<border type="none"/> <border type="none"/>
<children> <children>
@ -122,22 +121,21 @@
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<opaque value="true"/>
<text value="No Image Stored"/> <text value="No Image Stored"/>
</properties> </properties>
</component> </component>
<component id="cbf3c" class="javax.swing.JButton" binding="copyImageBelowButton" default-binding="true"> <component id="93788" class="javax.swing.JButton" binding="copyImageBelowButton" default-binding="true">
<constraints> <constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<horizontalTextPosition value="11"/>
<preferredSize width="126" height="30"/>
<text value="Copy Image Below"/> <text value="Copy Image Below"/>
</properties> </properties>
</component> </component>
</children> </children>
</grid> </grid>
<grid id="a7b09" binding="textButtonPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="true" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="a7b09" binding="textButtonPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="true" same-size-vertically="true" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/> <margin top="0" left="0" bottom="0" right="0"/>
<constraints> <constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@ -145,6 +143,7 @@
</constraints> </constraints>
<properties> <properties>
<background color="-16710887"/> <background color="-16710887"/>
<minimumSize width="471" height="30"/>
<preferredSize width="389" height="30"/> <preferredSize width="389" height="30"/>
</properties> </properties>
<border type="none"/> <border type="none"/>

@ -1,20 +1,33 @@
package me.goudham.view; package me.goudham.view;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.StringSelection;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.Locale;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JComponent;
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.JSplitPane;
import javax.swing.ListSelectionModel; import javax.swing.ListSelectionModel;
import javax.swing.border.TitledBorder;
import javax.swing.plaf.FontUIResource;
import javax.swing.text.StyleContext;
import me.goudham.listener.ClipboardEvent; import me.goudham.listener.ClipboardEvent;
import me.goudham.listener.ClipboardListener; import me.goudham.listener.ClipboardListener;
import me.goudham.listener.MacClipboardListener; import me.goudham.listener.MacClipboardListener;
@ -26,18 +39,17 @@ public class ClipboardView {
private JButton copySelectedTextButton; private JButton copySelectedTextButton;
private JList<String> clipboardContentList; private JList<String> clipboardContentList;
private final DefaultListModel<String> listModel = new DefaultListModel<>(); private final DefaultListModel<String> listModel = new DefaultListModel<>();
private ListSelectionModel listSelectionModel = clipboardContentList.getSelectionModel();
private JLabel title; private JLabel title;
private JPanel textButtonPanel; private JPanel textButtonPanel;
private JButton clearAllHistoryButton; private JButton clearAllHistoryButton;
private JButton removeButton; private JButton removeButton;
private JButton copyImageBelowButton;
private JButton removeImageBelowButton; private JButton removeImageBelowButton;
private JPanel imageButtonPanel; private JPanel imageButtonPanel;
private JButton toggleImageButton; private JButton toggleImageButton;
private JLabel imageLabel; private JLabel imageLabel;
private JScrollPane imageScrollPane; private JScrollPane imageScrollPane;
private JScrollPane clipboardContentScrollPane; private JScrollPane clipboardContentScrollPane;
private JButton copyImageBelowButton;
private boolean toggle = true; private boolean toggle = true;
private BufferedImage storedImageContent; private BufferedImage storedImageContent;
@ -50,6 +62,7 @@ public class ClipboardView {
clipboardContentScrollPane.getVerticalScrollBar().setUnitIncrement(200); clipboardContentScrollPane.getVerticalScrollBar().setUnitIncrement(200);
clipboardContentScrollPane.getHorizontalScrollBar().setUnitIncrement(200); clipboardContentScrollPane.getHorizontalScrollBar().setUnitIncrement(200);
clipboardContentList.setModel(listModel); clipboardContentList.setModel(listModel);
ListSelectionModel listSelectionModel = clipboardContentList.getSelectionModel();
listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
toggleImageButton.addActionListener(actionEvent -> { toggleImageButton.addActionListener(actionEvent -> {
@ -121,4 +134,169 @@ public class ClipboardView {
private boolean isWindows() { private boolean isWindows() {
return SystemUtils.IS_OS_WINDOWS; return SystemUtils.IS_OS_WINDOWS;
} }
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
clipboard = new JPanel();
clipboard.setLayout(new GridBagLayout());
clipboard.setBackground(new Color(-16710887));
clipboard.putClientProperty("html.disable", Boolean.FALSE);
final JSplitPane splitPane1 = new JSplitPane();
splitPane1.setAutoscrolls(true);
splitPane1.setBackground(new Color(-263169));
splitPane1.setContinuousLayout(true);
splitPane1.setForeground(new Color(-263169));
splitPane1.setOneTouchExpandable(true);
splitPane1.setOpaque(true);
splitPane1.setOrientation(1);
splitPane1.setPreferredSize(new Dimension(300, 250));
GridBagConstraints gbc;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 3;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
clipboard.add(splitPane1, gbc);
splitPane1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
imageScrollPane = new JScrollPane();
imageScrollPane.setAutoscrolls(false);
imageScrollPane.setBackground(new Color(-16710887));
imageScrollPane.setDoubleBuffered(true);
imageScrollPane.setForeground(new Color(-16710887));
imageScrollPane.setHorizontalScrollBarPolicy(30);
imageScrollPane.setMaximumSize(new Dimension(300, 300));
imageScrollPane.setMinimumSize(new Dimension(0, 0));
imageScrollPane.setOpaque(true);
imageScrollPane.setPreferredSize(new Dimension(300, 300));
imageScrollPane.setVerticalScrollBarPolicy(20);
splitPane1.setRightComponent(imageScrollPane);
imageScrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
imageLabel = new JLabel();
imageLabel.setAutoscrolls(true);
imageLabel.setBackground(new Color(-16710887));
imageLabel.setHorizontalAlignment(0);
imageLabel.setHorizontalTextPosition(0);
imageLabel.setOpaque(true);
imageLabel.setVerifyInputWhenFocusTarget(true);
imageScrollPane.setViewportView(imageLabel);
clipboardContentScrollPane = new JScrollPane();
clipboardContentScrollPane.setDoubleBuffered(true);
clipboardContentScrollPane.setMinimumSize(new Dimension(0, 0));
splitPane1.setLeftComponent(clipboardContentScrollPane);
clipboardContentList = new JList();
clipboardContentList.setAlignmentX(0.5f);
clipboardContentList.setAlignmentY(0.5f);
clipboardContentList.setBackground(new Color(-16710887));
clipboardContentList.setDragEnabled(false);
clipboardContentList.setFixedCellHeight(-1);
clipboardContentList.setFixedCellWidth(-1);
clipboardContentList.setFocusable(true);
Font clipboardContentListFont = this.$$$getFont$$$(null, Font.BOLD, 14, clipboardContentList.getFont());
if (clipboardContentListFont != null) clipboardContentList.setFont(clipboardContentListFont);
clipboardContentList.setForeground(new Color(-263169));
clipboardContentList.setInheritsPopupMenu(false);
clipboardContentList.setLayoutOrientation(0);
clipboardContentList.setOpaque(true);
clipboardContentList.putClientProperty("List.isFileList", Boolean.FALSE);
clipboardContentScrollPane.setViewportView(clipboardContentList);
imageButtonPanel = new JPanel();
imageButtonPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1, true, true));
imageButtonPanel.setBackground(new Color(-16710887));
imageButtonPanel.setPreferredSize(new Dimension(389, 30));
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 5, 5, 5);
clipboard.add(imageButtonPanel, gbc);
removeImageBelowButton = new JButton();
removeImageBelowButton.setText("Remove Image Below");
imageButtonPanel.add(removeImageBelowButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
toggleImageButton = new JButton();
toggleImageButton.setOpaque(true);
toggleImageButton.setText("No Image Stored");
imageButtonPanel.add(toggleImageButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
copyImageBelowButton = new JButton();
copyImageBelowButton.setText("Copy Image Below");
imageButtonPanel.add(copyImageBelowButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
textButtonPanel = new JPanel();
textButtonPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1, true, true));
textButtonPanel.setBackground(new Color(-16710887));
textButtonPanel.setMinimumSize(new Dimension(471, 30));
textButtonPanel.setPreferredSize(new Dimension(389, 30));
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 5, 5, 5);
clipboard.add(textButtonPanel, gbc);
copySelectedTextButton = new JButton();
copySelectedTextButton.setBorderPainted(true);
copySelectedTextButton.setDoubleBuffered(true);
copySelectedTextButton.setText("Copy Selected Text");
copySelectedTextButton.putClientProperty("hideActionText", Boolean.FALSE);
textButtonPanel.add(copySelectedTextButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
clearAllHistoryButton = new JButton();
clearAllHistoryButton.setBorderPainted(true);
clearAllHistoryButton.setDoubleBuffered(true);
clearAllHistoryButton.setText("Clear All History");
textButtonPanel.add(clearAllHistoryButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
removeButton = new JButton();
removeButton.setActionCommand("Button");
removeButton.setText("Remove Selected Text");
textButtonPanel.add(removeButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
title = new JLabel();
Font titleFont = this.$$$getFont$$$("Berlin Sans FB Demi", Font.BOLD, 48, title.getFont());
if (titleFont != null) title.setFont(titleFont);
title.setForeground(new Color(-7401958));
title.setText("My Clipboard History");
title.setVerticalTextPosition(1);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
clipboard.add(title, gbc);
}
/**
* @noinspection ALL
*/
private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) {
if (currentFont == null) return null;
String resultName;
if (fontName == null) {
resultName = currentFont.getName();
} else {
Font testFont = new Font(fontName, Font.PLAIN, 10);
if (testFont.canDisplay('a') && testFont.canDisplay('1')) {
resultName = fontName;
} else {
resultName = currentFont.getName();
}
}
Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() { return clipboard; }
} }

Loading…
Cancel
Save