import jalview.util.MessageManager;
-import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
+import java.awt.Container;
import java.awt.Font;
-import java.awt.GridLayout;
-import java.awt.Rectangle;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
-import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
-import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
}
/**
+ * A convenience method that that adds a component with label to a container,
+ * sets a tooltip on both component and label, and optionally specifies layout
+ * constraints for the added component (but not the label)
*
- * @param panel
+ * @param container
* @param tooltip
* @param label
- * @param valBox
- * @return the GUI element created that was added to the layout so it's
- * attributes can be changed.
+ * @param comp
+ * @param constraints
*/
- public static JPanel addtoLayout(JPanel panel, String tooltip,
- JComponent label, JComponent valBox)
- {
- JPanel laypanel = new JPanel(new GridLayout(1, 2));
- JPanel labPanel = new JPanel(new BorderLayout());
- JPanel valPanel = new JPanel();
- labPanel.setBounds(new Rectangle(7, 7, 158, 23));
- valPanel.setBounds(new Rectangle(172, 7, 270, 23));
- labPanel.add(label, BorderLayout.WEST);
- valPanel.add(valBox);
- laypanel.add(labPanel);
- laypanel.add(valPanel);
- valPanel.setToolTipText(tooltip);
- labPanel.setToolTipText(tooltip);
- valBox.setToolTipText(tooltip);
- panel.add(laypanel);
- panel.validate();
- return laypanel;
- }
-
- public static void mgAddtoLayout(JPanel cpanel, String tooltip,
- JLabel jLabel, JComponent name)
- {
- mgAddtoLayout(cpanel, tooltip, jLabel, name, null);
- }
-
- public static void mgAddtoLayout(JPanel cpanel, String tooltip,
- JLabel jLabel, JComponent name, String params)
+ public static void addtoLayout(Container container, String tooltip,
+ JComponent label, JComponent comp, String constraints)
{
- cpanel.add(jLabel);
- if (params == null)
- {
- cpanel.add(name);
- }
- else
- {
- cpanel.add(name, params);
- }
- name.setToolTipText(tooltip);
- jLabel.setToolTipText(tooltip);
+ container.add(label);
+ container.add(comp, constraints);
+ comp.setToolTipText(tooltip); // this doesn't seem to show?
+ label.setToolTipText(tooltip);
}
/**
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
+import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
protColourLabel.setText(
MessageManager.getString("label.prot_alignment_colour") + " ");
- JvSwingUtils.addtoLayout(coloursTab,
+ GPreferences.addtoLayout(coloursTab,
MessageManager
.getString("label.default_colour_scheme_for_alignment"),
protColourLabel, protColour);
nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
nucColourLabel.setText(
MessageManager.getString("label.nuc_alignment_colour") + " ");
- JvSwingUtils.addtoLayout(coloursTab,
+ GPreferences.addtoLayout(coloursTab,
MessageManager
.getString("label.default_colour_scheme_for_alignment"),
nucColourLabel, nucColour);
annotationShding.setBorder(new TitledBorder(
MessageManager.getString("label.annotation_shading_default")));
annotationShding.setLayout(new GridLayout(1, 2));
- JvSwingUtils.addtoLayout(annotationShding,
+ GPreferences.addtoLayout(annotationShding,
MessageManager.getString(
"label.default_minimum_colour_annotation_shading"),
mincolourLabel, minColour);
- JvSwingUtils.addtoLayout(annotationShding,
+ GPreferences.addtoLayout(annotationShding,
MessageManager.getString(
"label.default_maximum_colour_annotation_shading"),
maxcolourLabel, maxColour);
protected void validateCygwinPath()
{
}
+
+ /**
+ * A helper method to add a panel containing a label and a component to a
+ * panel
+ *
+ * @param panel
+ * @param tooltip
+ * @param label
+ * @param valBox
+ */
+ protected static void addtoLayout(JPanel panel, String tooltip,
+ JComponent label, JComponent valBox)
+ {
+ JPanel laypanel = new JPanel(new GridLayout(1, 2));
+ JPanel labPanel = new JPanel(new BorderLayout());
+ JPanel valPanel = new JPanel();
+ labPanel.setBounds(new Rectangle(7, 7, 158, 23));
+ valPanel.setBounds(new Rectangle(172, 7, 270, 23));
+ labPanel.add(label, BorderLayout.WEST);
+ valPanel.add(valBox);
+ laypanel.add(labPanel);
+ laypanel.add(valPanel);
+ valPanel.setToolTipText(tooltip);
+ labPanel.setToolTipText(tooltip);
+ valBox.setToolTipText(tooltip);
+ panel.add(laypanel);
+ panel.validate();
+ }
}
optionsPanel = new JPanel(new MigLayout("", "[fill]", "[fill]"));
JScrollPane optionView = new JScrollPane();
optionView.setViewportView(options);
- JvSwingUtils.mgAddtoLayout(dpane,
+ JvSwingUtils.addtoLayout(dpane,
MessageManager.getString("label.input_parameter_name"),
new JLabel(MessageManager.getString("label.name")), tok,
"grow,spanx 3,wrap");
cpanel = details;
name = new JTextArea(1, 12);
- JvSwingUtils.mgAddtoLayout(cpanel,
+ JvSwingUtils.addtoLayout(cpanel,
MessageManager
.getString("label.short_descriptive_name_for_service"),
new JLabel(MessageManager.getString("label.name")), name,
"wrap");
action = new JComboBox();
- JvSwingUtils.mgAddtoLayout(cpanel,
+ JvSwingUtils.addtoLayout(cpanel,
MessageManager.getString("label.function_service_performs"),
new JLabel(MessageManager.getString("label.service_action")),
action, "wrap");
descr = new JTextArea(4, 60);
descrVp = new JScrollPane();
descrVp.setViewportView(descr);
- JvSwingUtils.mgAddtoLayout(cpanel,
+ JvSwingUtils.addtoLayout(cpanel,
MessageManager.getString("label.brief_description_service"),
new JLabel(MessageManager.getString("label.description")),
descrVp, "wrap");
url = new JTextArea(2, 60);
urlVp = new JScrollPane();
urlVp.setViewportView(url);
- JvSwingUtils.mgAddtoLayout(cpanel,
+ JvSwingUtils.addtoLayout(cpanel,
MessageManager.getString("label.url_post_data_service"),
new JLabel(MessageManager.getString("label.post_url")), urlVp,
"wrap");
urlsuff = new JTextArea();
urlsuff.setColumns(60);
- JvSwingUtils.mgAddtoLayout(cpanel,
+ JvSwingUtils.addtoLayout(cpanel,
MessageManager.getString("label.optional_suffix"),
new JLabel(MessageManager.getString("label.url_suffix")),
urlsuff, "wrap");
}
});
gapChar = new JComboBox();
- JvSwingUtils.mgAddtoLayout(cpanel,
+ JvSwingUtils.addtoLayout(cpanel,
MessageManager.getString("label.preferred_gap_character"),
new JLabel(
MessageManager.getString("label.gap_character") + ":"),