List of usage examples for javax.swing JProgressBar setBorder
@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.") public void setBorder(Border border)
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JProgressBar Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JProgressBar progressBar = new JProgressBar(); progressBar.setValue(25);//from w w w .j a v a 2s .co m progressBar.setStringPainted(true); Border border = BorderFactory.createTitledBorder("Reading..."); progressBar.setBorder(border); f.add(progressBar, BorderLayout.NORTH); f.setSize(300, 100); f.setVisible(true); }
From source file:net.sf.jabref.util.Util.java
/** * Automatically add links for this set of entries, based on the globally stored list of external file types. The * entries are modified, and corresponding UndoEdit elements added to the NamedCompound given as argument. * Furthermore, all entries which are modified are added to the Set of entries given as an argument. * <p>//from w ww . ja v a2 s .c o m * The entries' bibtex keys must have been set - entries lacking key are ignored. The operation is done in a new * thread, which is returned for the caller to wait for if needed. * * @param entries A collection of BibEntry objects to find links for. * @param ce A NamedCompound to add UndoEdit elements to. * @param changedEntries MODIFIED, optional. A Set of BibEntry objects to which all modified entries is added. * This is used for status output and debugging * @param singleTableModel UGLY HACK. The table model to insert links into. Already existing links are not * duplicated or removed. This parameter has to be null if entries.count() != 1. The hack has been * introduced as a bibtexentry does not (yet) support the function getListTableModel() and the * FileListEntryEditor editor holds an instance of that table model and does not reconstruct it after the * search has succeeded. * @param metaData The MetaData providing the relevant file directory, if any. * @param callback An ActionListener that is notified (on the event dispatch thread) when the search is finished. * The ActionEvent has id=0 if no new links were added, and id=1 if one or more links were added. This * parameter can be null, which means that no callback will be notified. * @param diag An instantiated modal JDialog which will be used to display the progress of the autosetting. This * parameter can be null, which means that no progress update will be shown. * @return the thread performing the autosetting */ public static Runnable autoSetLinks(final Collection<BibEntry> entries, final NamedCompound ce, final Set<BibEntry> changedEntries, final FileListTableModel singleTableModel, final MetaData metaData, final ActionListener callback, final JDialog diag) { final Collection<ExternalFileType> types = ExternalFileTypes.getInstance().getExternalFileTypeSelection(); if (diag != null) { final JProgressBar prog = new JProgressBar(JProgressBar.HORIZONTAL, 0, types.size() - 1); final JLabel label = new JLabel(Localization.lang("Searching for files")); prog.setIndeterminate(true); prog.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); diag.setTitle(Localization.lang("Autosetting links")); diag.getContentPane().add(prog, BorderLayout.CENTER); diag.getContentPane().add(label, BorderLayout.SOUTH); diag.pack(); diag.setLocationRelativeTo(diag.getParent()); } Runnable r = new Runnable() { @Override public void run() { // determine directories to search in List<File> dirs = new ArrayList<>(); List<String> dirsS = metaData.getFileDirectory(Globals.FILE_FIELD); for (String dirs1 : dirsS) { dirs.add(new File(dirs1)); } // determine extensions Collection<String> extensions = new ArrayList<>(); for (final ExternalFileType type : types) { extensions.add(type.getExtension()); } // Run the search operation: Map<BibEntry, List<File>> result; if (Globals.prefs.getBoolean(JabRefPreferences.AUTOLINK_USE_REG_EXP_SEARCH_KEY)) { String regExp = Globals.prefs.get(JabRefPreferences.REG_EXP_SEARCH_EXPRESSION_KEY); result = RegExpFileSearch.findFilesForSet(entries, extensions, dirs, regExp); } else { result = FileUtil.findAssociatedFiles(entries, extensions, dirs); } boolean foundAny = false; // Iterate over the entries: for (Entry<BibEntry, List<File>> entryFilePair : result.entrySet()) { FileListTableModel tableModel; String oldVal = entryFilePair.getKey().getField(Globals.FILE_FIELD); if (singleTableModel == null) { tableModel = new FileListTableModel(); if (oldVal != null) { tableModel.setContent(oldVal); } } else { assert entries.size() == 1; tableModel = singleTableModel; } List<File> files = entryFilePair.getValue(); for (File f : files) { f = FileUtil.shortenFileName(f, dirsS); boolean alreadyHas = false; //System.out.println("File: "+f.getPath()); for (int j = 0; j < tableModel.getRowCount(); j++) { FileListEntry existingEntry = tableModel.getEntry(j); //System.out.println("Comp: "+existingEntry.getLink()); if (new File(existingEntry.link).equals(f)) { alreadyHas = true; break; } } if (!alreadyHas) { foundAny = true; ExternalFileType type; Optional<String> extension = FileUtil.getFileExtension(f); if (extension.isPresent()) { type = ExternalFileTypes.getInstance().getExternalFileTypeByExt(extension.get()); } else { type = new UnknownExternalFileType(""); } FileListEntry flEntry = new FileListEntry(f.getName(), f.getPath(), type); tableModel.addEntry(tableModel.getRowCount(), flEntry); String newVal = tableModel.getStringRepresentation(); if (newVal.isEmpty()) { newVal = null; } if (ce != null) { // store undo information UndoableFieldChange change = new UndoableFieldChange(entryFilePair.getKey(), Globals.FILE_FIELD, oldVal, newVal); ce.addEdit(change); } // hack: if table model is given, do NOT modify entry if (singleTableModel == null) { entryFilePair.getKey().setField(Globals.FILE_FIELD, newVal); } if (changedEntries != null) { changedEntries.add(entryFilePair.getKey()); } } } } // handle callbacks and dialog // FIXME: The ID signals if action was successful :/ final int id = foundAny ? 1 : 0; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (diag != null) { diag.dispose(); } if (callback != null) { callback.actionPerformed(new ActionEvent(this, id, "")); } } }); } }; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // show dialog which will be hidden when the task is done if (diag != null) { diag.setVisible(true); } } }); return r; }
From source file:UI.MainViewPanel.java
public JProgressBar getPanel7(Metric7 m7) { JProgressBar openPortBar = new JProgressBar(0, 100); openPortBar.setValue(m7.totalCriticalCount); openPortBar.setBorder(BorderFactory.createLineBorder(Color.BLACK)); UIDefaults defaults = new UIDefaults(); Painter foregroundPainter = new MyPainter(new Color(230, 219, 27)); Painter backgroundPainter = new MyPainter(chartBackgroundColor); defaults.put("ProgressBar[Enabled].foregroundPainter", foregroundPainter); defaults.put("ProgressBar[Enabled+Finished].foregroundPainter", foregroundPainter); defaults.put("ProgressBar[Enabled].backgroundPainter", backgroundPainter); openPortBar.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.TRUE); openPortBar.putClientProperty("Nimbus.Overrides", defaults); openPortBar.setString("" + m7.totalCriticalCount); openPortBar.setStringPainted(true);//from ww w .j av a2 s .co m return openPortBar; }
From source file:Import.pnl_import_vcf.java
public void progressBar() { JProgressBar progressBar = new JProgressBar(); TitledBorder border = BorderFactory.createTitledBorder("Importing..."); progressBar.setBorder(border); progressBar.setIndeterminate(true);//w w w . j a v a 2 s. c om JDialog dialog = new JDialog(); }
From source file:net.pandoragames.far.ui.swing.FileListPanel.java
private void init(SwingConfig config, ComponentRepository componentRepository) { this.setLayout(new BorderLayout()); this.setBorder( BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); tableModel = componentRepository.getTableModel(); componentRepository.getResetDispatcher().addResetable(tableModel); componentRepository.getSearchBaseListener().addResetable(tableModel); componentRepository.getUndoListener().setTableModel(tableModel); JTable fileListTable = componentRepository.getFileSetTable(); int totalWidth = fileListTable.getPreferredSize().width; fileListTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); fileListTable.setColumnSelectionAllowed(true); fileListTable.getTableHeader().addMouseListener(new TableHeaderMouseListener()); fileListTable.getTableHeader().getColumnModel().getColumn(0) .setHeaderRenderer(new TableHeaderCheckBoxColumnRenderer()); fileListPopupMenu = new FileListPopupMenu(fileListTable, tableModel, componentRepository, config); fileListTable.setComponentPopupMenu(fileListPopupMenu); fileListTable.addMouseListener(new FileViewOpener(fileListTable, componentRepository.getRootWindow(), config, componentRepository)); fileListTable.getColumnModel().getColumn(0).setPreferredWidth(20); fileListTable.getColumnModel().getColumn(0).setMaxWidth(20); fileListTable.getColumnModel().getColumn(1).setCellRenderer(new TargetFileListTableCellRenderer()); fileListTable.getColumnModel().getColumn(1).setPreferredWidth(2 * totalWidth / 5); fileListTable.getColumnModel().getColumn(2).setCellRenderer(new PathColumnRenderer()); fileListTable.getColumnModel().getColumn(3).setCellRenderer(new InfoColumnRenderer(config)); JScrollPane scrollPane = new JScrollPane(fileListTable); this.add(scrollPane, BorderLayout.CENTER); SelectCounter fileCounter = new SelectCounter(); fileCounter.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); fileCounter.setForeground(Color.GRAY); ErrorCounter errorCounter = new ErrorCounter(); errorCounter.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); JPanel counterLine = new JPanel(); counterLine.setLayout(new BorderLayout()); counterLine.add(fileCounter, BorderLayout.WEST); counterLine.add(errorCounter, BorderLayout.EAST); JProgressBar progressBar = new JProgressBar(); progressBar.setEnabled(false);/*from ww w. j av a 2 s. co m*/ progressBar.setMaximumSize(new Dimension(100, 20)); progressBar.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); componentRepository.getProgressBarUpdater().setProgressBar(progressBar); JPanel progressBarPanel = new JPanel(); progressBarPanel.add(progressBar); counterLine.add(progressBarPanel, BorderLayout.CENTER); counterLine.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); this.add(counterLine, BorderLayout.SOUTH); tableModel.addTableModelListener(new ColumnCountListener(fileCounter)); tableModel.addTableModelListener(errorCounter); componentRepository.getResetDispatcher().addResetable(fileCounter); componentRepository.getSearchBaseListener().addResetable(fileCounter); componentRepository.getOperationCallBackListener().addComponentStartReseted(fileCounter, OperationType.FIND); componentRepository.getResetDispatcher().addResetable(errorCounter); componentRepository.getSearchBaseListener().addResetable(errorCounter); viewAction = new ActionView(componentRepository, config); }
From source file:net.sf.jabref.openoffice.AutoDetectPaths.java
public JDialog showProgressDialog(JDialog progressParent, String title, String message, boolean includeCancelButton) { fileSearchCancelled = false;//from w w w .j a va2 s .com JProgressBar bar = new JProgressBar(SwingConstants.HORIZONTAL); JButton cancel = new JButton(Localization.lang("Cancel")); cancel.addActionListener(event -> { fileSearchCancelled = true; ((JButton) event.getSource()).setEnabled(false); }); final JDialog progressDialog = new JDialog(progressParent, title, false); bar.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); bar.setIndeterminate(true); if (includeCancelButton) { progressDialog.add(cancel, BorderLayout.SOUTH); } progressDialog.add(new JLabel(message), BorderLayout.NORTH); progressDialog.add(bar, BorderLayout.CENTER); progressDialog.pack(); progressDialog.setLocationRelativeTo(null); progressDialog.setVisible(true); return progressDialog; }