Browse Source

Fix sizing when loading something with a lot of tags due to FlowLayout

Sam Jaffe 5 years ago
parent
commit
86947aa26a

+ 2 - 2
src/main/lombok/org/leumasjaffe/recipe/view/TagInputPanel.java

@@ -42,7 +42,7 @@ public class TagInputPanel extends JPanel {
 	
 	private final class TagField extends JPanel {
 		private TagField(final String value) {
-			setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
+			setLayout(new FlowLayout(FlowLayout.CENTER));
 			add(new JLabel(value));
 			JButton btnRemove = new JButton(X_MARK);
 			btnRemove.setPreferredSize(new Dimension(10, 10));
@@ -60,7 +60,7 @@ public class TagInputPanel extends JPanel {
 	JTextField textField;
 
 	public TagInputPanel() {
-		setLayout(new FlowLayout(FlowLayout.LEADING, 5, 5));
+		setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
 		
 		textField = new JTextField();
 		new GhostTextController(textField, "Tags...");

+ 7 - 2
src/main/lombok/org/leumasjaffe/recipe/view/summary/SummaryPanel.java

@@ -1,5 +1,6 @@
 package org.leumasjaffe.recipe.view.summary;
 
+import java.awt.Dimension;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.Insets;
@@ -39,6 +40,7 @@ public class SummaryPanel extends JPanel {
 	
 	JTextField txtTitle;
 	JTextArea txaDescription;
+	TagInputPanel panelTags;
 	
 	public SummaryPanel() {
 		controller = new ReplaceChildrenAction<>(RecipeCard::getElements, element -> {
@@ -145,13 +147,16 @@ public class SummaryPanel extends JPanel {
 		gbc_panelPhoto.gridy = 0;
 		panel.add(panelPhoto, gbc_panelPhoto);
 		
-		JPanel panelTags = new TagInputPanel();
+		JPanel wrapper = new JPanel(new VerticalLayout());
+		panelTags = new TagInputPanel();
+		panelTags.setPreferredSize(new Dimension(200, 100));
 		GridBagConstraints gbc_panelTags = new GridBagConstraints();
 		gbc_panelTags.insets = new Insets(0, 0, 5, 0);
 		gbc_panelTags.fill = GridBagConstraints.BOTH;
 		gbc_panelTags.gridx = 0;
 		gbc_panelTags.gridy = 1;
-		panel.add(panelTags, gbc_panelTags);
+		panel.add(wrapper, gbc_panelTags);
+		wrapper.add(panelTags);
 		
 		txaDescription = new JTextArea(5, 20);
 		txaDescription.setWrapStyleWord(true);