List of usage examples for com.jgoodies.forms.layout FormLayout getColumnCount
public int getColumnCount()
From source file:uk.ac.ebi.mnb.dialog.file.NewGeneProduct.java
License:Open Source License
@Override public JPanel getForm() { JPanel panel = super.getForm(); FormLayout layout = (FormLayout) panel.getLayout(); layout.appendRow(new RowSpec(Sizes.DLUY4)); layout.appendRow(new RowSpec(Sizes.PREFERRED)); CellConstraints cc = new CellConstraints(); Box buttons = Box.createHorizontalBox(); buttons.add(protein);/*from w ww . ja va 2 s.c om*/ buttons.add(trna); buttons.add(rrna); protein.setSelected(true); panel.add(buttons, cc.xyw(1, layout.getRowCount(), layout.getColumnCount())); return panel; }
From source file:uk.ac.ebi.mnb.dialog.file.NewReaction.java
License:Open Source License
@Override public JPanel getForm() { JPanel panel = super.getForm(); equation = new SuggestionField(this, 5, new ReactionSuggestionHandler(), new ReplacementHandler()); FormLayout layout = (FormLayout) panel.getLayout(); layout.appendRow(new RowSpec(Sizes.DLUY4)); layout.appendRow(new RowSpec(Sizes.PREFERRED)); JLabel label = LabelFactory.newFormLabel("Reaction Equation", "Enter a text equation for your reaction (e.g. 1 A + B -> C [e])"); label.setHorizontalAlignment(JLabel.LEADING); panel.add(label, cc.xyw(1, layout.getRowCount(), layout.getColumnCount())); layout.appendRow(new RowSpec(Sizes.DLUY4)); layout.appendRow(new RowSpec(Sizes.PREFERRED)); panel.add(equation, cc.xyw(1, layout.getRowCount(), layout.getColumnCount())); return panel; }
From source file:uk.ac.ebi.mnb.view.entity.reaction.ReactionPanel.java
License:Open Source License
@Override public JPanel getBasicPanel() { JPanel panel = super.getBasicPanel(); FormLayout layout = (FormLayout) panel.getLayout(); participantXref = PanelFactory.createInfoPanel(); // add a row/*from w w w .j a va 2s .c o m*/ layout.appendRow(new RowSpec(RowSpec.CENTER, Sizes.DLUY4, RowSpec.DEFAULT_GROW)); layout.appendRow(new RowSpec(RowSpec.CENTER, Sizes.PREFERRED, RowSpec.DEFAULT_GROW)); panel.add(reactionLabel, cc.xyw(1, layout.getRowCount(), layout.getColumnCount(), cc.CENTER, cc.CENTER)); layout.appendRow(new RowSpec(RowSpec.CENTER, Sizes.PREFERRED, RowSpec.NO_GROW)); panel.add(participantXref, cc.xyw(1, layout.getRowCount(), layout.getColumnCount(), cc.CENTER, cc.CENTER)); layout.appendRow(new RowSpec(RowSpec.CENTER, Sizes.PREFERRED, RowSpec.NO_GROW)); panel.add(editor.getComponent(), cc.xyw(1, layout.getRowCount(), layout.getColumnCount(), cc.CENTER, cc.CENTER)); editor.getComponent().setVisible(false); return panel; }
From source file:util.paramhandler.ParamInputField.java
License:Open Source License
/** * Create the GUI//from www. jav a2 s.c o m * @param text Text to use in the InputField * @param singleLine set True, if Input-Field should be a Single-Line */ private void createGui(String text, boolean singleLine) { FormLayout layout = new FormLayout("fill:pref:grow, 3dlu, default, 3dlu, default, 3dlu, default", "fill:pref:grow, 3dlu, default"); setLayout(layout); CellConstraints cc = new CellConstraints(); mParamText = new JTextArea(); mParamText.setText(text); if (singleLine) { mParamText.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent ke) { if (ke.getKeyCode() == KeyEvent.VK_ENTER) { ke.consume(); } } }); JScrollPane scroll = new JScrollPane(mParamText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); add(scroll, cc.xyw(1, 1, layout.getColumnCount())); } else { mParamText.setLineWrap(true); add(new JScrollPane(mParamText), cc.xyw(1, 1, layout.getColumnCount())); } ArrayList<String> items = new ArrayList<String>(); items.add(mLocalizer.msg("insert", "Insert")); List<String> functions = Arrays.asList(mParamLibrary.getPossibleFunctions()); Collections.sort(functions); for (String function : functions) { items.add(function + "()"); } List<String> keys = Arrays.asList(mParamLibrary.getPossibleKeys()); Collections.sort(keys); for (String key : keys) { items.add(key); } final JComboBox insert = new JComboBox(items.toArray(new String[items.size()])); add(insert, cc.xy(layout.getColumnCount() - 4, 3)); insert.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (insert.getSelectedIndex() > 0) { // find out whether to insert with braces or not boolean inFunction = false; String newText = insert.getSelectedItem().toString(); int selStart = mParamText.getSelectionStart(); if (selStart > 0) { try { if (mParamText.getText(selStart - 1, 1).equals("(")) { inFunction = true; } } catch (BadLocationException e1) { e1.printStackTrace(); } } int selEnd = mParamText.getSelectionEnd(); if (selEnd < mParamText.getText().length()) { try { if (mParamText.getText(selEnd + 1, 1).equals(")")) { inFunction = true; } } catch (BadLocationException e1) { e1.printStackTrace(); } } if (!inFunction) { newText = "{" + newText + "}"; } mParamText.insert(newText, selStart); // reposition cursor if this was a function itself int lastBrace = newText.lastIndexOf(')'); if (lastBrace > 0) { if (newText.length() - lastBrace <= 2) { mParamText.setCaretPosition( mParamText.getSelectionStart() - (newText.length() - lastBrace)); } } mParamText.requestFocus(); } } }); JButton check = new JButton(mLocalizer.msg("check", "Check")); check.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Window bestparent = UiUtilities.getBestDialogParent(ParamInputField.this); ParamCheckDialog dialog = new ParamCheckDialog(bestparent, mParamLibrary, mParamText.getText()); dialog.setVisible(true); } }); add(check, cc.xy(layout.getColumnCount() - 2, 3)); JButton help = new JButton(Localizer.getLocalization(Localizer.I18N_HELP)); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Window bestparent = UiUtilities.getBestDialogParent(ParamInputField.this); ParamHelpDialog dialog = new ParamHelpDialog(bestparent, mParamLibrary); dialog.setVisible(true); } }); add(help, cc.xy(layout.getColumnCount(), 3)); }
From source file:xmet.tools.metadata.editor.views.custom.Panel.java
License:Open Source License
/** * Removes the repeated panel./*from w w w .j a v a 2s. c o m*/ * @param panel the panel */ private void removeRepeatedPanel(final Panel panel) { panels.remove(panel); /* remove everything and reconstruct the panel */ removeAll(); /* create and set default layout */ final FormLayout layout = new FormLayout("$ugap,f:d,$rgap,f:d,$rgap,f:p:grow,$ugap", "$ugap,f:d,$rgap"); setLayout(layout); /* add the Add button */ final JButton btnAdd = new JButton("Add"); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent arg0) { addRepeatedPanel(); } }); this.add(btnAdd, CC.xywh(2, 2, 1, 1)); /* add all repeated panels one by one */ for (final Panel rPanel : panels) { layout.appendRow(RowSpec.decode("$rgap")); layout.appendRow(RowSpec.decode("f:d")); this.add(rPanel, CC.xywh(2, layout.getRowCount(), layout.getColumnCount() - 2, 1)); layout.appendRow(RowSpec.decode("$rgap")); layout.appendRow(RowSpec.decode("f:d")); final JButton btnRemove = new JButton("Remove"); btnRemove.addActionListener(new RemovePanelAction(rPanel)); this.add(btnRemove, CC.xywh(2, layout.getRowCount(), 1, 1)); } revalidate(); this.repaint(); }