瀏覽代碼

Fix instruction size cutting off data.

Sam Jaffe 4 年之前
父節點
當前提交
9267e664a7
共有 1 個文件被更改,包括 10 次插入6 次删除
  1. 10 6
      src/main/lombok/org/leumasjaffe/recipe/view/StepPanel.java

+ 10 - 6
src/main/lombok/org/leumasjaffe/recipe/view/StepPanel.java

@@ -1,6 +1,7 @@
 package org.leumasjaffe.recipe.view;
 
 import javax.swing.JPanel;
+import javax.swing.JTextArea;
 import javax.swing.event.DocumentListener;
 
 import org.leumasjaffe.observer.ForwardingObservableListener;
@@ -23,13 +24,10 @@ import java.awt.Insets;
 import java.awt.event.FocusListener;
 
 import javax.swing.JLabel;
-import javax.swing.JTextPane;
 import java.awt.Component;
 import javax.swing.Box;
 import javax.swing.JFormattedTextField;
 
-import java.awt.Dimension;
-
 @SuppressWarnings("serial")
 @FieldDefaults(level=AccessLevel.PRIVATE)
 public class StepPanel extends JPanel implements AutoGrowPanel.ChildComponent {
@@ -38,10 +36,13 @@ public class StepPanel extends JPanel implements AutoGrowPanel.ChildComponent {
 	ObservableListener<JFormattedTextField, Step> durationController;
 
 	JLabel lblIndex;
-	@Getter(AccessLevel.PACKAGE) JTextPane txtpnInstructions;
+	@Getter(AccessLevel.PACKAGE) JTextArea txtpnInstructions;
 	AutoGrowPanel<IngredientPanel, Ingredient> panelIngredients;
 	DurationPanel panelDuration;
 		
+	/**
+	 * @wbp.parser.constructor
+	 */
 	public StepPanel(final ScaleFactor scale) {
 		GridBagLayout gridBagLayout = new GridBagLayout();
 		gridBagLayout.columnWidths = new int[]{0, 0, 0};
@@ -94,8 +95,11 @@ public class StepPanel extends JPanel implements AutoGrowPanel.ChildComponent {
 		gbc_panelIngredients.gridy = 1;
 		panelLeft.add(panelIngredients, gbc_panelIngredients);
 		
-		txtpnInstructions = new JTextPane();
-		txtpnInstructions.setPreferredSize(new Dimension(200, 30));
+		// 0 rows -> automatic resizing
+		// 20 columns -> long enough for 44 characters, apparently
+		txtpnInstructions = new JTextArea(0, 20);
+		txtpnInstructions.setLineWrap(true);
+		txtpnInstructions.setWrapStyleWord(true);
 		GridBagConstraints gbc_txtpnInstructions = new GridBagConstraints();
 		gbc_txtpnInstructions.fill = GridBagConstraints.BOTH;
 		gbc_txtpnInstructions.gridx = 1;