List of usage examples for javax.swing Box createVerticalStrut
public static Component createVerticalStrut(int height)
From source file:com.apatar.ui.JPublishToApatarDialog.java
private void createDialog() { GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); this.setLayout(gridbag); c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0;/*from w ww. jav a 2s . co m*/ c.weighty = 0.0; c.fill = GridBagConstraints.HORIZONTAL; //c.insets = new Insets(5, 5, 5, 5); JPanel panelLogin = new JPanel(); panelLogin.setBorder(new EmptyBorder(10, 10, 0, 10)); panelLogin.setLayout(new BoxLayout(panelLogin, BoxLayout.X_AXIS)); panelLogin.add(new JLabel("User Name")); panelLogin.add(Box.createHorizontalStrut(5)); panelLogin.add(username); username.setComponentPopupMenu(new JDefaultContextMenu(username)); panelLogin.add(Box.createHorizontalStrut(5)); panelLogin.add(new JLabel("Password")); panelLogin.add(Box.createHorizontalStrut(5)); panelLogin.add(password); JPanel panelForgotPassLink = new JPanel(); panelForgotPassLink.setBorder(new EmptyBorder(10, 10, 0, 10)); panelForgotPassLink.setLayout(new BoxLayout(panelForgotPassLink, BoxLayout.X_AXIS)); panelForgotPassLink.add(new JLabel("Lost your password? ")); panelForgotPassLink.add(Box.createHorizontalStrut(5)); panelForgotPassLink.add(forgotPassLinkLabel); forgotPassLinkLabel.setFont(UiUtils.NORMAL_SIZE_12_FONT); forgotPassLinkLabel.addMouseListener(new MouseHyperLinkEvent()); forgotPassLinkLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); forgotPassLinkLabel.setText( "<html><a href='http://www.apatarforge.org/profile/lostpassword.html'>Click here to retrieve it</a></html>"); JPanel panelFile = new JPanel(); panelFile.setBorder(new EmptyBorder(10, 10, 0, 10)); panelFile.setLayout(new BoxLayout(panelFile, BoxLayout.X_AXIS)); panelFile.add(selectFromFile); panelFile.add(Box.createHorizontalStrut(5)); panelFile.add(new JLabel("New File ")); panelFile.add(Box.createHorizontalStrut(5)); panelFile.add(nameFile); panelFile.add(Box.createHorizontalStrut(5)); panelFile.add(browse); nameFile.setEnabled(false); nameFile.setComponentPopupMenu(new JDefaultContextMenu(nameFile)); browse.setEnabled(false); JPanel panelLocation = new JPanel(); panelLocation.setBorder(new EmptyBorder(10, 10, 0, 10)); panelLocation.setLayout(new BoxLayout(panelLocation, BoxLayout.X_AXIS)); panelLocation.add(new JLabel("Suggest Location:")); panelLocation.add(Box.createHorizontalStrut(5)); panelLocation.add(location); JPanel panelDMName = new JPanel(); panelDMName.setBorder(new EmptyBorder(10, 10, 0, 10)); panelDMName.setLayout(new BoxLayout(panelDMName, BoxLayout.X_AXIS)); JLabel datamapNameLabel = new JLabel("DataMap Name:"); datamapNameLabel.setBorder(new EmptyBorder(0, 0, 0, 10)); panelDMName.add(datamapNameLabel); panelDMName.add(Box.createHorizontalStrut(5)); panelDMName.add(dataMapName); dataMapName.setComponentPopupMenu(new JDefaultContextMenu(dataMapName)); JPanel panelDMDescription = new JPanel(); panelDMDescription.setBorder(new EmptyBorder(10, 10, 0, 10)); panelDMDescription.setLayout(new BoxLayout(panelDMDescription, BoxLayout.X_AXIS)); panelDMDescription.add(new JLabel("DataMap Description (16000 Chars)")); panelDMDescription.add(Box.createHorizontalStrut(5)); //JScrollPane scroll = new JScrollPane(dataMapDescription); //scroll.setSize(300, 50); dataMapDescription.setLineWrap(true); dataMapDescription.setWrapStyleWord(true); panelDMDescription.add(new JScrollPane(dataMapDescription)); JPanel panelDMShortDescription = new JPanel(); panelDMShortDescription.setBorder(new EmptyBorder(10, 10, 0, 10)); panelDMShortDescription.setLayout(new BoxLayout(panelDMShortDescription, BoxLayout.X_AXIS)); JLabel labelShort = new JLabel("Short Description:"); labelShort.setBorder(new EmptyBorder(0, 0, 0, 85)); panelDMShortDescription.add(labelShort); panelDMShortDescription.add(Box.createHorizontalStrut(5)); shortDescription.setLineWrap(true); shortDescription.setWrapStyleWord(true); panelDMShortDescription.add(new JScrollPane(shortDescription)); setEnableShortDescription(false); // ------------- JPanel panelTitleForTags = new JPanel(); panelTitleForTags.setBorder(new EmptyBorder(10, 10, 0, 10)); panelTitleForTags.setLayout(new BoxLayout(panelTitleForTags, BoxLayout.X_AXIS)); panelTitleForTags.add(new JLabel("Add tags associated with your DataMap:")); // ------------- JPanel panelListAddedTags = new JPanel(); panelListAddedTags.setBorder(new EmptyBorder(0, 10, 10, 10)); panelListAddedTags.setLayout(new BoxLayout(panelListAddedTags, BoxLayout.X_AXIS)); // -- JPanel panelFrom = new JPanel(); panelFrom.setLayout(new BoxLayout(panelFrom, BoxLayout.Y_AXIS)); JPanel panelMiddle = new JPanel(); panelMiddle.setLayout(new BoxLayout(panelMiddle, BoxLayout.X_AXIS)); JPanel panelTo = new JPanel(); panelTo.setLayout(new BoxLayout(panelTo, BoxLayout.Y_AXIS)); // -- JPanel panelAddNewTag = new JPanel(); panelAddNewTag.setLayout(new BoxLayout(panelAddNewTag, BoxLayout.X_AXIS)); panelAddNewTag.add(new JLabel("Add new tag:")); panelAddNewTag.add(Box.createHorizontalStrut(5)); textfieldAddNewTag = new JTextField(); textfieldAddNewTag.setComponentPopupMenu(new JDefaultContextMenu(textfieldAddNewTag)); panelAddNewTag.add(textfieldAddNewTag); panelAddNewTag.add(Box.createHorizontalStrut(5)); JButton buttonAddTag = new JButton("Add"); buttonAddTag.addActionListener(addNewTagMouseListener); panelAddNewTag.add(buttonAddTag); // -- JPanel panelDeleteTags = new JPanel(); panelDeleteTags.setLayout(new BoxLayout(panelDeleteTags, BoxLayout.X_AXIS)); panelDeleteTags.add(new JLabel("Delete selected tag(s):")); panelDeleteTags.add(Box.createHorizontalStrut(5)); JButton buttonDeleteTag = new JButton("Delete"); buttonDeleteTag.addActionListener(deleteTagMouseListener); panelDeleteTags.add(buttonDeleteTag); panelDeleteTags.add(new JPanel()); // -- JButton moveTag = new JButton(UiUtils.ARROW_ICON); moveTag.addActionListener(addTagsMouseListener); panelMiddle.add(moveTag); tblModelFrom = new DefaultTableModel(); tblModelTo = new DefaultTableModel(); tblModelFrom.addColumn("Tag Name"); tblModelTo.addColumn("Tag Name"); tagsTableFrom = new JTable(tblModelFrom); tagsTableTo = new JTable(tblModelTo); tagsTableFrom.setOpaque(false); tagsTableFrom.setBackground(null); tagsTableFrom.setBorder(null); tagsTableFrom.setShowGrid(false); tagsTableTo.setOpaque(false); tagsTableTo.setBackground(null); tagsTableTo.setBorder(null); tagsTableTo.setShowGrid(false); tagsTableFrom.getColumn("Tag Name").setCellEditor(new CellEditor(new JTextField())); tagsTableTo.getColumn("Tag Name").setCellEditor(new CellEditor(new JTextField())); fillTableTags(); tagsTableFrom.setComponentPopupMenu(new JDefaultContextMenu(tagsTableFrom)); tagsTableTo.setComponentPopupMenu(new JDefaultContextMenu(tagsTableTo)); JScrollPane srollPane = new JScrollPane(tagsTableFrom); srollPane.setBorder(null); JScrollPane srollPane2 = new JScrollPane(tagsTableTo); srollPane.setBorder(null); panelFrom.add(srollPane); panelFrom.add(Box.createVerticalStrut(5)); panelFrom.add(panelAddNewTag); panelTo.add(srollPane2); panelTo.add(Box.createVerticalStrut(5)); panelTo.add(panelDeleteTags); panelListAddedTags.add(panelFrom); panelListAddedTags.add(Box.createHorizontalStrut(5)); panelListAddedTags.add(panelMiddle); panelListAddedTags.add(Box.createHorizontalStrut(5)); panelListAddedTags.add(panelTo); // ------- JPanel panelButton = new JPanel(); panelButton.setLayout(new BoxLayout(panelButton, BoxLayout.X_AXIS)); panelButton.add(Box.createHorizontalGlue()); panelButton.add(bOk); panelButton.add(Box.createHorizontalStrut(5)); panelButton.add(bCancel); panelButton.add(Box.createHorizontalStrut(5)); ComponentBuilder.makeComponent(new JCommentPanel(), gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelLogin, gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelForgotPassLink, gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelFile, gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelLocation, gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelDMName, gridbag, c, getContentPane()); c.fill = GridBagConstraints.BOTH; c.weighty = 2.0; ComponentBuilder.makeComponent(panelDMDescription, gridbag, c, getContentPane()); c.weighty = 0.0; ComponentBuilder.makeComponent(autoGenerateShortDescription, gridbag, c, getContentPane()); c.weighty = 1.0; ComponentBuilder.makeComponent(panelDMShortDescription, gridbag, c, getContentPane()); c.weighty = 1.0; ComponentBuilder.makeComponent(panelTitleForTags, gridbag, c, getContentPane()); c.weighty = 3.0; ComponentBuilder.makeComponent(panelListAddedTags, gridbag, c, getContentPane()); c.weighty = 0.0; ComponentBuilder.makeComponent(new JSeparator(), gridbag, c, getContentPane()); c.weighty = 1.0; ComponentBuilder.makeComponent(panelButton, gridbag, c, getContentPane()); }
From source file:org.openmicroscopy.shoola.agents.imviewer.util.proj.ProjSavingDialog.java
/** * Returns the file queue and indicates where the files will be imported. * //from www . ja va 2 s. com * @return See above. */ private void buildLocationPane() { selectionPane.removeAll(); JPanel row = createRow(); selectionPane.add(row); selectionPane.add(Box.createVerticalStrut(2)); row = createRow(); row.add(UIUtilities.setTextFont(PROJECT_TXT)); row.add(parentsBox); selectionPane.add(row); selectionPane.add(Box.createVerticalStrut(8)); row = createRow(); row.add(UIUtilities.setTextFont(DATASET_TXT)); row.add(datasetsBox); selectionPane.add(row); }
From source file:coreferenceresolver.gui.MarkupGUI.java
private JScrollPane newReviewPanel(Review review, int reviewId) throws BadLocationException { //Model/*from w ww. j a v a 2 s.c o m*/ ReviewElement reviewElement = new ReviewElement(); ScrollablePanel reviewPanel = new ScrollablePanel(); reviewPanel.setLayout(new BoxLayout(reviewPanel, BoxLayout.PAGE_AXIS)); JTextField title = new JTextField("NEW REVIEW " + reviewId); title.setBackground(Color.pink); reviewPanel.add(title); JTextArea reviewContentTxtArea = new JTextArea(); reviewContentTxtArea.setLineWrap(true); reviewContentTxtArea.setWrapStyleWord(true); reviewContentTxtArea.setEditable(false); reviewContentTxtArea.setText(review.getRawContent()); int chainId = 0; for (CorefChain cc : review.getCorefChains()) { for (int npId : cc.getChain()) { NounPhrase np = review.getNounPhrases().get(npId); Object highlighTag = reviewContentTxtArea.getHighlighter().addHighlight(np.getOffsetBegin(), np.getOffsetEnd() + 1, highlightPainters.get(chainId)); this.markupReviews.get(reviewId).getNounPhrases().get(npId).highlighterTag = highlighTag; } ++chainId; } reviewPanel.add(reviewContentTxtArea); ScrollablePanel markupsPanel = new ScrollablePanel(); markupsPanel.setLayout(new BoxLayout(markupsPanel, BoxLayout.PAGE_AXIS)); for (int i = 0; i < review.getNounPhrases().size(); ++i) { JScrollPane newMarkupPanel = newMarkupPanel(review.getNounPhrases().get(i), reviewElement); markupsPanel.add(newMarkupPanel); } JScrollPane scrollMarkupsPanel = new JScrollPane(markupsPanel); //Add Dimension for scrolling Dimension curScreenDimen = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); scrollMarkupsPanel.setPreferredSize(new Dimension((int) curScreenDimen.getWidth() - 50, 400)); reviewPanel.add(scrollMarkupsPanel); //MODEL reviewElement.reviewTextArea = reviewContentTxtArea; reviewElements.add(reviewElement); reviewPanel.add(new JSeparator(SwingConstants.HORIZONTAL)); reviewPanel.add(Box.createVerticalStrut(20)); JScrollPane scrollReviewPanel = new JScrollPane(reviewPanel); return scrollReviewPanel; }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.FileSelectionTable.java
/** * Builds and lays out the controls./*from w ww. ja v a2 s .c o m*/ * * @return See above. */ JPanel buildControls() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); if (ImporterAgent.runAsPlugin() != LookupNames.IMAGE_J_IMPORT) { p.add(addButton); p.add(Box.createVerticalStrut(5)); } p.add(removeButton); p.add(Box.createVerticalStrut(5)); p.add(removeAllButton); return p; }
From source file:org.rdv.ui.channel.LocalChannelDialog.java
private JPanel buildVariablesPanel() { JPanel variablesPanel = new JPanel(); variablesPanel.setLayout(new BorderLayout()); JScrollPane variablesScrollPane = new JScrollPane(variablesTable.getComponent()); variablesPanel.add(variablesScrollPane, BorderLayout.CENTER); Box variablesButtonsPanel = Box.createVerticalBox(); variablesButtonsPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); JButton addVariableButton = new JButton(); addVariableButton.setName("addVariableButton"); addVariableButton.setText(PROPERTY_REPO.getValue(ADD_VARIABLE_BUTTON_KEY)); addVariableButton.addActionListener(new ActionListener() { @Override/*from w w w. j av a 2s .c o m*/ public void actionPerformed(ActionEvent e) { addVariable(); } }); variablesButtonsPanel.add(addVariableButton); variablesButtonsPanel.add(Box.createVerticalStrut(5)); removeVariableButton.setName("removeVariableButton"); removeVariableButton.setText(PROPERTY_REPO.getValue(REMOVE_VARIABLE_BUTTON_KEY)); removeVariableButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeVariable(); } }); variablesButtonsPanel.add(removeVariableButton); variablesPanel.add(variablesButtonsPanel, BorderLayout.EAST); return variablesPanel; }
From source file:org.isatools.isacreator.gui.DataEntryForm.java
/** * Adds the fields describing a section to a Container (e.g. JPanel, Box, etc.) * * @param containerToAddTo @see JPanel, @see Box, @see Container * @param sectionToAddTo - @see InvestigationFileSection as a reference for where the fields are being added * @param fieldValues - Map of field name to values. * @param referenceObject - A @see DataEntryReferenceObject which gives information about *//*from www . ja va 2 s. c o m*/ public void addFieldsToPanel(Container containerToAddTo, InvestigationFileSection sectionToAddTo, OrderedMap<String, String> fieldValues, DataEntryReferenceObject referenceObject) { if (fieldDefinitions == null) { fieldDefinitions = new ListOrderedMap<String, JComponent>(); } Set<String> ontologyFields = referenceObject.getOntologyTerms(sectionToAddTo); Set<String> fieldsToIgnore = referenceObject.getFieldsToIgnore(); for (String fieldName : fieldValues.keySet()) { if (!fieldsToIgnore.contains(fieldName)) { FieldObject fieldDescriptor = referenceObject.getFieldDefinition(fieldName); if (!fieldDescriptor.isHidden()) { String tmpFieldName = fieldName; if (realNamesToAliases.containsKey(fieldName)) { tmpFieldName = realNamesToAliases.get(fieldName); } JPanel fieldPanel = createFieldPanel(1, 2); JLabel fieldLabel = createLabel(tmpFieldName); JComponent textComponent; if (fieldDescriptor.getDatatype() == DataTypes.STRING || fieldDescriptor.getDatatype() == DataTypes.ONTOLOGY_TERM || fieldDescriptor.getDatatype() == DataTypes.DATE) { textComponent = new RoundedJTextField(10); } else if (fieldDescriptor.getDatatype() == DataTypes.LONG_STRING) { textComponent = new JTextArea(); ((JTextArea) textComponent).setSelectionColor(UIHelper.LIGHT_GREEN_COLOR); ((JTextArea) textComponent).setSelectedTextColor(UIHelper.BG_COLOR); ((JTextArea) textComponent).setWrapStyleWord(true); ((JTextArea) textComponent).setLineWrap(true); textComponent.setBackground(UIHelper.BG_COLOR); textComponent.setBorder(UIHelper.GREEN_ROUNDED_BORDER); } else if (fieldDescriptor.getDatatype() == DataTypes.LIST) { textComponent = new JComboBox(fieldDescriptor.getFieldList()); } else { textComponent = new RoundedJTextField(10); } if (textComponent instanceof JTextArea || textComponent instanceof JTextComponent) { ((JTextComponent) textComponent) .setText(fieldValues.get(fieldName).equals("") ? fieldDescriptor.getDefaultVal() : fieldValues.get(fieldName)); } textComponent.setToolTipText(fieldDescriptor.getDescription()); UIHelper.renderComponent(textComponent, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false); fieldPanel.add(fieldLabel); if (textComponent instanceof JTextArea) { JScrollPane invDescScroll = new JScrollPane(textComponent, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); invDescScroll.setPreferredSize(new Dimension(200, 75)); invDescScroll.getViewport().setBackground(UIHelper.BG_COLOR); ((JTextArea) textComponent).getDocument().addDocumentListener(new DocumentChangeListener()); IAppWidgetFactory.makeIAppScrollPane(invDescScroll); fieldPanel.add( UIHelper.createTextEditEnableJTextArea(invDescScroll, (JTextArea) textComponent)); } else if (textComponent instanceof JTextComponent) { if (fieldDescriptor.getDatatype() == DataTypes.ONTOLOGY_TERM || ontologyFields.contains(fieldName)) { fieldPanel.add(createOntologyDropDown(fieldName, (JTextComponent) textComponent, true, false, fieldDescriptor.getRecommmendedOntologySource())); } else if (fieldDescriptor.getDatatype() == DataTypes.DATE) { fieldPanel.add(createDateDropDown((JTextComponent) textComponent)); } else if (fieldDescriptor.isAcceptsFileLocations()) { fieldPanel.add(createFileField((JTextComponent) textComponent)); } else { fieldPanel.add(textComponent); } ((JTextComponent) textComponent).getDocument() .addDocumentListener(new DocumentChangeListener()); } else { fieldPanel.add(textComponent); } fieldDefinitions.put(tmpFieldName, textComponent); containerToAddTo.add(fieldPanel); containerToAddTo.add(Box.createVerticalStrut(5)); } } } }
From source file:com.diversityarrays.kdxplore.heatmap.AskForPositionNamesAndTraitInstancePanel.java
public AskForPositionNamesAndTraitInstancePanel(int nPositionsWanted, int nTraitInstancesWanted, List<ValueRetriever<?>> positionAndPlotRetrievers, Map<TraitInstance, SimpleStatistics<?>> statsByTraitInstance, final Closure<Boolean> enableActionNotifier, CurationContext context) { super(new BorderLayout()); if (nPositionsWanted > 3) { // coz we only do X,Y,Z !! throw new IllegalArgumentException("At most 3 position names can be chosen"); }/*from ww w . j a v a 2 s. c o m*/ nPositionNamesToChoose = nPositionsWanted; nTraitInstancesToChoose = nTraitInstancesWanted; this.enableActionNotifier = enableActionNotifier; // this.traitInstanceIsAvailable = traitInstanceIsAvailable; this.statsByTraitInstance = statsByTraitInstance; traitInstancesX = new ArrayList<TraitInstance>(statsByTraitInstance.keySet()); Collections.sort(traitInstancesX, TraitHelper.COMPARATOR); List<ValueRetriever<?>> list = new ArrayList<ValueRetriever<?>>(); list.addAll(positionAndPlotRetrievers); Function<TraitInstance, List<KdxSample>> sampleProvider = new Function<TraitInstance, List<KdxSample>>() { @Override public List<KdxSample> apply(TraitInstance ti) { return context.getPlotInfoProvider().getSampleMeasurements(ti); } }; for (TraitInstance ti : traitInstancesX) { try { ValidationRule vrule = ValidationRule.create(ti.trait.getTraitValRule()); validationRuleByTraitInstance.put(ti, vrule); TraitInstanceValueRetriever<?> tivr = TraitInstanceValueRetriever .getValueRetriever(context.getTrial(), ti, sampleProvider); list.add(tivr); } catch (InvalidRuleException e) { validationRuleExceptionByTraitInstance.put(ti, e); } } tableModel.initialise(list); Box buttons = Box.createVerticalBox(); final List<AxisChoiceAction> axisChoiceActions = new ArrayList<>(); for (AxisChoice ac : AxisChoice.values()) { AxisChoiceAction action = new AxisChoiceAction(ac); action.setEnabled(false); axisChoiceActions.add(action); } buttons.add(new JLabel("Select Axis:")); for (AxisChoiceAction action : axisChoiceActions) { if (AxisChoice.Z == action.axisChoice) { buttons.add(Box.createVerticalStrut(10)); } buttons.add(new JButton(action)); if (AxisChoice.NOT_SELECTED == action.axisChoice) { buttons.add(Box.createVerticalStrut(10)); } } buttons.add(Box.createVerticalGlue()); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int mrow = -1; int vrow = table.getSelectedRow(); if (vrow >= 0) { mrow = table.convertRowIndexToModel(vrow); } if (mrow >= 0) { ValueRetriever<?> vr = tableModel.valueRetrievers.get(mrow); boolean isTraitInstance = vr instanceof TraitInstanceValueRetriever; for (AxisChoiceAction action : axisChoiceActions) { switch (action.axisChoice) { case NOT_SELECTED: case X: case Y: action.setEnabled(true); break; case Z: action.setEnabled(isTraitInstance); break; default: action.setEnabled(false); break; } } } else { for (AxisChoiceAction action : axisChoiceActions) { action.setEnabled(false); } } } } }); table.setDefaultRenderer(AxisChoice.class, new AxisChoiceRenderer("Not available", "*")); table.setDefaultRenderer(TraitInstance.class, new TraitInstanceRenderer()); String text = nTraitInstancesToChoose <= 1 ? "Select Axes and Value:" : "Select Axes and Values:"; JPanel traitInstancesPanel = new JPanel(new BorderLayout()); traitInstancesPanel.setBorder(new EmptyBorder(0, 10, 0, 0)); traitInstancesPanel.add(new JLabel(text), BorderLayout.NORTH); traitInstancesPanel.add(new JScrollPane(table), BorderLayout.CENTER); add(buttons, BorderLayout.WEST); add(traitInstancesPanel, BorderLayout.CENTER); if (!tableModel.excluded.isEmpty()) { JLabel lbl = new JLabel("TraitInstances without plottable data have been excluded"); lbl.setHorizontalAlignment(JLabel.CENTER); add(lbl, BorderLayout.SOUTH); // StringBuilder sb = new StringBuilder("<HTML>No Data:"); // for (ValueRetriever<?> vr : tableModel.excluded) { // sb.append("<BR>").append(StringUtil.htmlEscape(vr.getDisplayName())); // } // add(new JScrollPane(new JLabel(sb.toString())), BorderLayout.SOUTH); } }
From source file:com.frostwire.gui.library.LibraryFilesTableMediator.java
/** * Override the default removal so we can actually stop sharing * and delete the file.//from w ww. ja v a 2s. c o m * Deletes the selected rows in the table. * CAUTION: THIS WILL DELETE THE FILE FROM THE DISK. */ public void removeSelection() { int[] rows = TABLE.getSelectedRows(); if (rows.length == 0) return; if (TABLE.isEditing()) { TableCellEditor editor = TABLE.getCellEditor(); editor.cancelCellEditing(); } List<File> files = new ArrayList<File>(rows.length); // sort row indices and go backwards so list indices don't change when // removing the files from the model list Arrays.sort(rows); for (int i = rows.length - 1; i >= 0; i--) { File file = DATA_MODEL.getFile(rows[i]); files.add(file); } CheckBoxListPanel<File> listPanel = new CheckBoxListPanel<File>(files, new FileTextProvider(), true); listPanel.getList().setVisibleRowCount(4); // display list of files that should be deleted Object[] message = new Object[] { new MultiLineLabel(I18n.tr( "Are you sure you want to delete the selected file(s), thus removing it from your computer?"), 400), Box.createVerticalStrut(ButtonRow.BUTTON_SEP), listPanel, Box.createVerticalStrut(ButtonRow.BUTTON_SEP) }; // get platform dependent options which are displayed as buttons in the dialog Object[] removeOptions = createRemoveOptions(); int option = JOptionPane.showOptionDialog(MessageService.getParentComponent(), message, I18n.tr("Message"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, removeOptions, removeOptions[0] /* default option */); if (option == removeOptions.length - 1 /* "cancel" option index */ || option == JOptionPane.CLOSED_OPTION) { return; } // remove still selected files List<File> selected = listPanel.getSelectedElements(); List<String> undeletedFileNames = new ArrayList<String>(); for (File file : selected) { // stop seeding if seeding BittorrentDownload dm = null; if ((dm = TorrentUtil.getDownloadManager(file)) != null) { dm.setDeleteDataWhenRemove(false); dm.setDeleteTorrentWhenRemove(false); BTDownloadMediator.instance().remove(dm); } // close media player if still playing if (MediaPlayer.instance().isThisBeingPlayed(file)) { MediaPlayer.instance().stop(); MPlayerMediator.instance().showPlayerWindow(false); } // removeOptions > 2 => OS offers trash options boolean removed = FileUtils.delete(file, removeOptions.length > 2 && option == 0 /* "move to trash" option index */); if (removed) { DATA_MODEL.remove(DATA_MODEL.getRow(file)); } else { undeletedFileNames.add(getCompleteFileName(file)); } } clearSelection(); if (undeletedFileNames.isEmpty()) { return; } // display list of files that could not be deleted message = new Object[] { new MultiLineLabel(I18n.tr( "The following files could not be deleted. They may be in use by another application or are currently being downloaded to."), 400), Box.createVerticalStrut(ButtonRow.BUTTON_SEP), new JScrollPane(createFileList(undeletedFileNames)) }; JOptionPane.showMessageDialog(MessageService.getParentComponent(), message, I18n.tr("Error"), JOptionPane.ERROR_MESSAGE); super.removeSelection(); }
From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUIElement.java
/** * Builds and lays out the header./*from w w w . j ava2s .c o m*/ * * @return See above. */ private JPanel buildHeader() { sizeLabel = UIUtilities.createComponent(null); sizeLabel.setText(FileUtils.byteCountToDisplaySize(sizeImport)); reportLabel = UIUtilities.setTextFont("Report:", Font.BOLD); importSizeLabel = UIUtilities.setTextFont("Import Size:", Font.BOLD); double[][] design = new double[][] { { TableLayout.PREFERRED }, { TableLayout.PREFERRED, TableLayout.PREFERRED } }; TableLayout layout = new TableLayout(design); JPanel detailsPanel = new JPanel(layout); detailsPanel.setBackground(UIUtilities.BACKGROUND_COLOR); JPanel p = createRow(); p.add(reportLabel); p.add(numberOfImportLabel); detailsPanel.add(p, "0, 0"); p = createRow(); p.add(importSizeLabel); p.add(sizeLabel); detailsPanel.add(p, "0, 1"); JPanel middlePanel = new JPanel(); middlePanel.setBackground(UIUtilities.BACKGROUND_COLOR); middlePanel.add(filterButton); JTextArea description = new JTextArea(MESSAGE); makeLabelStyle(description); description.setBackground(UIUtilities.BACKGROUND_COLOR); JPanel descriptionPanel = new JPanel(); descriptionPanel.setBackground(UIUtilities.BACKGROUND_COLOR); descriptionPanel.add(description); JPanel header = new JPanel(); header.setBackground(UIUtilities.BACKGROUND_COLOR); header.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); header.setLayout(new BorderLayout()); header.add(Box.createVerticalStrut(10), BorderLayout.NORTH); header.add(detailsPanel, BorderLayout.WEST); header.add(middlePanel, BorderLayout.CENTER); header.add(descriptionPanel, BorderLayout.EAST); header.add(Box.createVerticalStrut(10), BorderLayout.SOUTH); return header; }
From source file:com.limegroup.gnutella.gui.search.ResultPanel.java
/** * Adds the overlay panel into the table & converts the button * to 'download'.//from w w w.j a v a 2 s . com */ private void setupFakeTable(JPanel overlay) { MAIN_PANEL.removeAll(); JPanel background = new JPanel(); background.setLayout(new OverlayLayout(background)); JPanel overlayPanel = new BoxPanel(BoxPanel.Y_AXIS); overlayPanel.setOpaque(false); overlayPanel.add(Box.createVerticalStrut(20)); overlayPanel.add(overlay); overlayPanel.setMinimumSize(new Dimension(0, 0)); JComponent table = getScrolledTablePane(); table.setOpaque(false); background.add(overlayPanel); background.add(table); MAIN_PANEL.add(background); if (BUTTON_ROW != null) { MAIN_PANEL.add(Box.createVerticalStrut(GUIConstants.SEPARATOR)); MAIN_PANEL.add(BUTTON_ROW); } MAIN_PANEL.setMinimumSize(ZERO_DIMENSION); }