Use JSplitPane for showing text & images dynamically

main
sgoudham 3 years ago
parent d7afe6b44f
commit 7e1c62de83
No known key found for this signature in database
GPG Key ID: EF51A29A50FB754C

@ -2,7 +2,7 @@
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="me.goudham.view.ClipboardView"> <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="me.goudham.view.ClipboardView">
<grid id="27dc6" binding="clipboard" layout-manager="GridBagLayout"> <grid id="27dc6" binding="clipboard" layout-manager="GridBagLayout">
<constraints> <constraints>
<xy x="20" y="20" width="641" height="794"/> <xy x="20" y="20" width="710" height="682"/>
</constraints> </constraints>
<properties> <properties>
<background color="-16710887"/> <background color="-16710887"/>
@ -12,25 +12,59 @@
</clientProperties> </clientProperties>
<border type="none"/> <border type="none"/>
<children> <children>
<component id="ccd73" class="javax.swing.JLabel" binding="title"> <splitpane id="a64a3">
<constraints> <constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/> <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<gridbag weightx="1.0" weighty="0.0"/> <preferred-size width="200" height="200"/>
</grid>
<gridbag weightx="1.0" weighty="1.0"/>
</constraints> </constraints>
<properties> <properties>
<font name="Berlin Sans FB Demi" size="48" style="1"/> <autoscrolls value="true"/>
<foreground color="-7401958"/> <background color="-16710887"/>
<text value="My Clipboard History"/> <continuousLayout value="true"/>
<verticalTextPosition value="1"/> <foreground color="-16710887"/>
<oneTouchExpandable value="true"/>
<opaque value="true"/>
<orientation value="0"/>
<preferredSize width="300" height="250"/>
</properties> </properties>
</component> <border type="none"/>
<scrollpane id="1de68" binding="scrollPane"> <children>
<scrollpane id="681c6" binding="imageScrollPane">
<constraints> <constraints>
<grid row="7" column="0" row-span="2" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/> <splitpane position="right"/>
<gridbag top="10" left="10" bottom="10" right="10" weightx="1.0" weighty="1.0"/>
</constraints> </constraints>
<properties>
<autoscrolls value="false"/>
<background color="-16710887"/>
<foreground color="-16710887"/>
<maximumSize width="300" height="300"/>
<minimumSize width="0" height="0"/>
<opaque value="false"/>
<preferredSize width="300" height="300"/>
</properties>
<border type="none"/>
<children>
<component id="a0714" class="javax.swing.JLabel" binding="imageLabel">
<constraints/>
<properties> <properties>
<autoscrolls value="true"/> <autoscrolls value="true"/>
<background color="-16710887"/>
<horizontalAlignment value="0"/>
<horizontalTextPosition value="0"/>
<opaque value="true"/>
<text value=""/>
</properties>
</component>
</children>
</scrollpane>
<scrollpane id="cebe0" binding="clipboardContentScrollPane">
<constraints>
<splitpane position="left"/>
</constraints>
<properties>
<minimumSize width="0" height="0"/>
</properties> </properties>
<border type="none"/> <border type="none"/>
<children> <children>
@ -56,197 +90,107 @@
</component> </component>
</children> </children>
</scrollpane> </scrollpane>
<grid id="a7b09" binding="buttonPane" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> </children>
<margin top="0" left="10" bottom="0" right="10"/> </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">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints> <constraints>
<grid row="6" 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"/>
<gridbag top="5" left="0" bottom="0" right="0" weightx="0.0" weighty="0.0"/> <gridbag top="5" left="5" bottom="5" right="5" weightx="0.0" weighty="0.0"/>
</constraints> </constraints>
<properties> <properties>
<background color="-16710887"/> <background color="-16710887"/>
<minimumSize width="367" height="30"/>
<preferredSize width="367" height="30"/>
</properties> </properties>
<border type="none"/> <border type="none"/>
<children> <children>
<component id="17bdb" class="javax.swing.JButton" binding="copySelectedTextButton" default-binding="true"> <component id="b16b7" class="javax.swing.JButton" binding="removeImageBelowButton" 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="2" 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>
<borderPainted value="true"/> <text value="Remove Image Below"/>
<doubleBuffered value="true"/>
<text value="Copy Selected Text"/>
</properties> </properties>
<clientProperties>
<hideActionText class="java.lang.Boolean" value="false"/>
</clientProperties>
</component> </component>
<component id="c36b1" class="javax.swing.JButton" binding="clearAllHistoryButton" default-binding="true"> <component id="6b15e" class="javax.swing.JButton" binding="toggleImageButton" default-binding="true">
<constraints> <constraints>
<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>
<borderPainted value="true"/> <text value="Toggle Image"/>
<doubleBuffered value="true"/>
<text value="Clear All History"/>
</properties> </properties>
</component> </component>
<component id="b7183" class="javax.swing.JButton" binding="removeButton"> <component id="cbf3c" class="javax.swing.JButton" binding="copyImageBelowButton" default-binding="true">
<constraints> <constraints>
<grid row="0" column="2" 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>
<actionCommand value="Button"/> <horizontalTextPosition value="11"/>
<text value="Remove Selected Text"/> <preferredSize width="126" height="30"/>
<text value="Copy Image Below"/>
</properties> </properties>
</component> </component>
</children> </children>
</grid> </grid>
<component id="f6be9" class="javax.swing.JLabel"> <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">
<constraints> <margin top="0" left="0" bottom="0" right="0"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<gridbag top="5" left="0" bottom="5" right="0" weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<font name="Berlin Sans FB Demi" size="24" style="1"/>
<foreground color="-263169"/>
<text value="Last Copied Image"/>
</properties>
</component>
<component id="12b73" class="javax.swing.JLabel" binding="textClipboardLabel">
<constraints> <constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" 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"/>
<gridbag top="5" left="0" bottom="5" right="0" weightx="0.0" weighty="0.0"/> <gridbag top="5" left="5" bottom="5" right="5" weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<font name="Berlin Sans FB Demi" size="24" style="1"/>
<foreground color="-263169"/>
<text value="Text History"/>
</properties>
</component>
<grid id="865e3" binding="imageButtonPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="10" bottom="10" right="10"/>
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints> </constraints>
<properties> <properties>
<background color="-16710887"/> <background color="-16710887"/>
<preferredSize width="389" height="30"/>
</properties> </properties>
<border type="none"/> <border type="none"/>
<children> <children>
<component id="cbf3c" class="javax.swing.JButton" binding="copyImageBelowButton" default-binding="true"> <component id="17bdb" class="javax.swing.JButton" binding="copySelectedTextButton" 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>
<text value="Copy Image Below"/> <borderPainted value="true"/>
</properties> <doubleBuffered value="true"/>
</component> <text value="Copy Selected Text"/>
<component id="b16b7" class="javax.swing.JButton" binding="removeImageBelowButton" default-binding="true">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Remove Image Below"/>
</properties> </properties>
<clientProperties>
<hideActionText class="java.lang.Boolean" value="false"/>
</clientProperties>
</component> </component>
<component id="6b15e" class="javax.swing.JButton" binding="toggleImageButton" default-binding="true"> <component id="c36b1" class="javax.swing.JButton" binding="clearAllHistoryButton" default-binding="true">
<constraints> <constraints>
<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>
<text value="Toggle Image"/> <borderPainted value="true"/>
<doubleBuffered value="true"/>
<text value="Clear All History"/>
</properties> </properties>
</component> </component>
</children> <component id="b7183" class="javax.swing.JButton" binding="removeButton">
</grid>
<scrollpane id="6714a" binding="anotherImagePanel">
<constraints> <constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/> <grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<gridbag top="5" left="5" bottom="5" right="5" weightx="0.0" weighty="0.0"/>
</constraints> </constraints>
<properties> <properties>
<background color="-16710887"/> <actionCommand value="Button"/>
<foreground color="-16710887"/> <text value="Remove Selected Text"/>
<opaque value="false"/>
</properties>
<border type="none"/>
<children>
<component id="d4095" class="javax.swing.JLabel" binding="imageIconLabel">
<constraints/>
<properties>
<autoscrolls value="true"/>
<background color="-16710887"/>
<horizontalAlignment value="0"/>
<horizontalTextPosition value="0"/>
<opaque value="true"/>
<text value=""/>
</properties> </properties>
</component> </component>
</children> </children>
</scrollpane>
<splitpane id="a64a3">
<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">
<preferred-size width="200" height="200"/>
</grid> </grid>
<gridbag weightx="0.0" weighty="0.0"/> <component id="ccd73" class="javax.swing.JLabel" binding="title">
</constraints>
<properties>
<autoscrolls value="true"/>
<background color="-16710887"/>
<continuousLayout value="true"/>
<foreground color="-16710887"/>
<oneTouchExpandable value="true"/>
<opaque value="true"/>
<orientation value="0"/>
<preferredSize width="300" height="300"/>
</properties>
<border type="none"/>
<children>
<component id="fc284" class="javax.swing.JList" binding="list1" default-binding="true">
<constraints>
<splitpane position="left"/>
</constraints>
<properties>
<background color="-16710887"/>
<font name="JetBrains Mono" size="18" style="1"/>
<foreground color="-1"/>
<minimumSize width="0" height="0"/>
<model/>
<opaque value="false"/>
<requestFocusEnabled value="false"/>
</properties>
</component>
<scrollpane id="681c6">
<constraints> <constraints>
<splitpane position="right"/> <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<gridbag weightx="1.0" weighty="0.0"/>
</constraints> </constraints>
<properties> <properties>
<background color="-16710887"/> <font name="Berlin Sans FB Demi" size="48" style="1"/>
<foreground color="-16710887"/> <foreground color="-7401958"/>
<opaque value="false"/> <text value="My Clipboard History"/>
</properties> <verticalTextPosition value="1"/>
<border type="none"/>
<children>
<component id="a0714" class="javax.swing.JLabel" binding="yetAnotherImageIcon">
<constraints/>
<properties>
<autoscrolls value="true"/>
<background color="-16710887"/>
<horizontalAlignment value="0"/>
<horizontalTextPosition value="0"/>
<maximumSize width="0" height="0"/>
<minimumSize width="0" height="0"/>
<opaque value="true"/>
<preferredSize width="0" height="0"/>
<text value=""/>
</properties> </properties>
</component> </component>
</children> </children>
</scrollpane>
</children>
</splitpane>
</children>
</grid> </grid>
</form> </form>

@ -22,34 +22,30 @@ public class ClipboardView implements ClipboardEvent {
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 JPanel textButtonPanel;
private JPanel buttonPane;
private JButton clearAllHistoryButton; private JButton clearAllHistoryButton;
private JButton removeButton; private JButton removeButton;
private JLabel imageIconLabel;
private JLabel textClipboardLabel;
private JButton copyImageBelowButton; private JButton copyImageBelowButton;
private JButton removeImageBelowButton; private JButton removeImageBelowButton;
private JPanel imageButtonPanel; private JPanel imageButtonPanel;
private JButton toggleImageButton; private JButton toggleImageButton;
private JScrollPane anotherImagePanel; private JLabel imageLabel;
private JList<String> list1; private JScrollPane imageScrollPane;
private JLabel yetAnotherImageIcon; private JScrollPane clipboardContentScrollPane;
private boolean toggle = true; private boolean toggle = true;
private BufferedImage storedImageContent; private BufferedImage storedImageContent;
public ClipboardView() { public ClipboardView() {
scrollPane.setBorder(BorderFactory.createEmptyBorder()); imageScrollPane.setBorder(BorderFactory.createEmptyBorder());
anotherImagePanel.setBorder(BorderFactory.createEmptyBorder()); clipboardContentScrollPane.setBorder(BorderFactory.createEmptyBorder());
buttonPane.setBorder(BorderFactory.createEmptyBorder()); textButtonPanel.setBorder(BorderFactory.createEmptyBorder());
listModel = new DefaultListModel<>(); listModel = new DefaultListModel<>();
clipboardContentList.setModel(listModel); clipboardContentList.setModel(listModel);
list1.setModel(listModel);
toggleImageButton.addActionListener(actionEvent -> { toggleImageButton.addActionListener(actionEvent -> {
if (toggle) { if (toggle) {
yetAnotherImageIcon.setIcon(null); imageLabel.setIcon(null);
// anotherImagePanel.setPreferredSize(null); // anotherImagePanel.setPreferredSize(null);
// anotherImagePanel.setVisible(false); // anotherImagePanel.setVisible(false);
// imageIconLabel.setMaximumSize(new Dimension(0, 0)); // imageIconLabel.setMaximumSize(new Dimension(0, 0));
@ -58,7 +54,7 @@ public class ClipboardView implements ClipboardEvent {
} else { } else {
// anotherImagePanel.setPreferredSize(new Dimension(300, 300)); // anotherImagePanel.setPreferredSize(new Dimension(300, 300));
// anotherImagePanel.setVisible(true); // anotherImagePanel.setVisible(true);
yetAnotherImageIcon.setIcon(new ImageIcon(storedImageContent)); imageLabel.setIcon(new ImageIcon(storedImageContent));
toggle = true; toggle = true;
} }
// anotherImagePanel.revalidate(); // anotherImagePanel.revalidate();
@ -135,7 +131,7 @@ public class ClipboardView implements ClipboardEvent {
public void onCopyImage(BufferedImage imageContent) { public void onCopyImage(BufferedImage imageContent) {
storedImageContent = imageContent; storedImageContent = imageContent;
// anotherImagePanel.setMinimumSize(new Dimension(300, 300)); // anotherImagePanel.setMinimumSize(new Dimension(300, 300));
yetAnotherImageIcon.setIcon(new ImageIcon(imageContent)); imageLabel.setIcon(new ImageIcon(imageContent));
toggle = true; toggle = true;
// //
// if (imageContent.getWidth() > 1000 || imageContent.getHeight() > 1000) { // if (imageContent.getWidth() > 1000 || imageContent.getHeight() > 1000) {

Loading…
Cancel
Save