List of usage examples for javax.swing JScrollPane getVerticalScrollBar
@Transient
public JScrollBar getVerticalScrollBar()
From source file:org.nuclos.client.dbtransfer.DBTransferImport.java
private boolean setupPreviewPanel(List<PreviewPart> previewParts) { boolean blnTransferWithWarnings = false; jpnPreviewHeader.removeAll();//from w ww . jav a 2 s.co m jpnPreviewFooter.removeAll(); // setup parameter scroll pane jpnPreviewContent.removeAll(); double[] rowContraints = new double[previewParts.size()]; for (int i = 0; i < previewParts.size(); i++) rowContraints[i] = TableLayout.PREFERRED; final int iWidthBeginnigSpace = 3; final int iWidthSeparator = 6; final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); JLabel lbPreviewHeaderEntity = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.11", "Entit\u00e4t")); JLabel lbPreviewHeaderTable = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.12", "Tabellenname")); JLabel lbPreviewHeaderRecords = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.4", "Datens\u00e4tze")); lbPreviewHeaderRecords.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.5", "Anzahl der betroffenen Datens\u00e4tze")); utils.initJPanel(jpnPreviewContent, new double[] { iWidthBeginnigSpace, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED }, rowContraints); int iWidthEntityLabelSize = 0; int iWidthTableLabelSize = 0; int iWidthRecordsLabelSize = 0; int iCountNew = 0; int iCountDeleted = 0; int iCountChanged = 0; int iRow = 0; for (final PreviewPart pp : previewParts) { String tooltip = ""; JLabel lbEntity = new JLabel(pp.getEntity()); JLabel lbTable = new JLabel(pp.getTable()); JLabel lbRecords = new JLabel(String.valueOf(pp.getDataRecords())); lbRecords.setHorizontalAlignment(SwingConstants.RIGHT); if (lbEntity.getPreferredSize().width < lbPreviewHeaderEntity.getPreferredSize().width) lbEntity.setPreferredSize(lbPreviewHeaderEntity.getPreferredSize()); if (lbTable.getPreferredSize().width < lbPreviewHeaderTable.getPreferredSize().width) lbTable.setPreferredSize(lbPreviewHeaderTable.getPreferredSize()); if (lbRecords.getPreferredSize().width < lbPreviewHeaderRecords.getPreferredSize().width) lbRecords.setPreferredSize(lbPreviewHeaderRecords.getPreferredSize()); iWidthEntityLabelSize = iWidthEntityLabelSize < lbEntity.getPreferredSize().width ? lbEntity.getPreferredSize().width : iWidthEntityLabelSize; iWidthTableLabelSize = iWidthTableLabelSize < lbTable.getPreferredSize().width ? lbTable.getPreferredSize().width : iWidthTableLabelSize; iWidthRecordsLabelSize = iWidthRecordsLabelSize < lbRecords.getPreferredSize().width ? lbRecords.getPreferredSize().width : iWidthRecordsLabelSize; Icon icoStatement = null; switch (pp.getType()) { case PreviewPart.NEW: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.6", "Entit\u00e4t wird hinzugef\u00fcgt"); icoStatement = ParameterEditor.COMPARE_ICON_NEW; iCountNew++; break; case PreviewPart.CHANGE: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.7", "Entit\u00e4t wird ge\u00e4ndert"); icoStatement = ParameterEditor.COMPARE_ICON_VALUE_CHANGED; iCountChanged++; break; case PreviewPart.DELETE: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.8", "Entit\u00e4t wird gel\u00f6scht"); icoStatement = ParameterEditor.COMPARE_ICON_DELETED; iCountDeleted++; break; } JLabel lbIcon = new JLabel(icoStatement); JLabel lbStatemnts = new JLabel("<html><u>" + localeDelegate.getMessage("dbtransfer.import.step1.9", "Script anzeigen") + "...</u></html>"); lbStatemnts.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lbStatemnts.addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseClicked(MouseEvent e) { String statements = ""; for (String statement : pp.getStatements()) { statements = statements + statement + ";\n\n"; } JTextArea txtArea = new JTextArea(statements); txtArea.setEditable(false); txtArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JScrollPane scroll = new JScrollPane(txtArea); scroll.getVerticalScrollBar().setUnitIncrement(20); scroll.setPreferredSize(new Dimension(600, 300)); scroll.setBorder(BorderFactory.createEmptyBorder()); MainFrameTab overlayFrame = new MainFrameTab( localeDelegate.getMessage("dbtransfer.import.step1.10", "Script f\u00fcr") + " " + pp.getEntity() + " (" + pp.getTable() + ")"); overlayFrame.setLayeredComponent(scroll); ifrm.add(overlayFrame); } }); lbIcon.setToolTipText(tooltip); lbStatemnts.setToolTipText(tooltip); lbEntity.setToolTipText(tooltip); lbTable.setToolTipText(tooltip); jpnPreviewContent.add(lbEntity, "1," + iRow + ",l,c"); jpnPreviewContent.add(lbTable, "3," + iRow + ",l,c"); jpnPreviewContent.add(lbRecords, "5," + iRow + ",r,c"); jpnPreviewContent.add(lbIcon, "7," + iRow + ",l,c"); jpnPreviewContent.add(lbStatemnts, "8," + iRow + ",l,c"); if (pp.getWarning() > 0) { lbIcon.setIcon(Icons.getInstance().getIconPriorityCancel16()); blnTransferWithWarnings = true; } iRow++; } jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "2,0,2," + (iRow - 1)); jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "4,0,4," + (iRow - 1)); jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "6,0,6," + (iRow - 1)); // setup preview header utils.initJPanel(jpnPreviewHeader, new double[] { iWidthBeginnigSpace, iWidthEntityLabelSize, iWidthSeparator, iWidthTableLabelSize, iWidthSeparator, iWidthRecordsLabelSize, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, TableLayout.PREFERRED }, new double[] { TableLayout.PREFERRED }); if (previewParts.isEmpty()) { jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.18", "Keine Struktur\u00e4nderungen am Datenbankschema.")), "0,0,8,0"); return blnTransferWithWarnings; } jpnPreviewHeader.add(lbPreviewHeaderEntity, "1,0"); jpnPreviewHeader.add(lbPreviewHeaderTable, "3,0"); jpnPreviewHeader.add(lbPreviewHeaderRecords, "5,0"); jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.13", "\u00c4nderung")), "7,0"); // setup preview footer utils.initJPanel(jpnPreviewFooter, new double[] { TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED }, new double[] { TableLayout.PREFERRED }); final JLabel lbCompare = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.14", "\u00c4nderungen") + ":"); final JLabel lbCompareNew = new JLabel(iCountNew + ""); final JLabel lbCompareDeleted = new JLabel(iCountDeleted + ""); final JLabel lbCompareValueChanged = new JLabel(iCountChanged + ""); lbCompareNew.setIcon(ParameterEditor.COMPARE_ICON_NEW); lbCompareDeleted.setIcon(ParameterEditor.COMPARE_ICON_DELETED); lbCompareValueChanged.setIcon(ParameterEditor.COMPARE_ICON_VALUE_CHANGED); lbCompareNew.setToolTipText(localeDelegate.getMessage("dbtransfer.import.step1.15", "Neue Entit\u00e4ten")); lbCompareDeleted.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.17", "Gel\u00f6schte Entit\u00e4ten")); lbCompareValueChanged.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.16", "Ge\u00e4nderte Entit\u00e4ten")); jpnPreviewFooter.add(lbCompare, "1,0,r,c"); jpnPreviewFooter.add(lbCompareNew, "2,0,r,c"); jpnPreviewFooter.add(lbCompareValueChanged, "3,0,r,c"); jpnPreviewFooter.add(lbCompareDeleted, "4,0,r,c"); return blnTransferWithWarnings; }
From source file:org.nuclos.client.dbtransfer.DBTransferImport.java
private PanelWizardStep newStep3(final MainFrameTab ifrm) { final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); final PanelWizardStep step = new PanelWizardStep( localeDelegate.getMessage("dbtransfer.import.step3.1", "System Parameter"), localeDelegate.getMessage("dbtransfer.import.step3.2", "Bestimmen Sie die Parameter dieses Systems. Sie k\u00f6nnen w\u00e4hlen zwischen dem aktuellen Zustand und dem aus der Konfigurationsdatei importierten Zustand (default). Sollte keine der beiden Vorgaben stimmen, so k\u00f6nnen Sie auch einen anderen Wert setzen.")) { @Override/*from w w w . j av a2 s . c om*/ public void prepare() { setupParameterPanel(importTransferObject.getParameter()); } @Override public void applyState() throws InvalidStateException { setSelectedIncomingParameter.clear(); setSelectedCurrentParameter.clear(); mapSelectedOtherParameter.clear(); for (ParameterEditor pe : lstParameterEditors) { if (pe.isCurrentValue()) setSelectedCurrentParameter.add(pe.getName()); if (pe.isIncomingValue()) setSelectedIncomingParameter.add(pe.getName()); if (pe.isOtherValue()) mapSelectedOtherParameter.put(pe.getName(), pe.getValue()); } } }; step.setComplete(true); utils.initJPanel(step, new double[] { TableLayout.FILL }, new double[] { TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED }); rbCurrentAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { resetParameterEditors(true); } }); rbIncomingAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { resetParameterEditors(false); } }); final JScrollPane scroll = new JScrollPane(jpnParameter); scroll.setPreferredSize(new Dimension(680, 250)); scroll.setBorder(new LineBorder(Color.LIGHT_GRAY, 1)); scroll.getVerticalScrollBar().setUnitIncrement(20); scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scroll.getViewport().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Dimension parameterPanelSize = new Dimension(scroll.getViewport().getWidth(), jpnParameter.getPreferredSize().height); jpnParameter.setPreferredSize(parameterPanelSize); } }); step.add(jpnParameterHeader, "0,0"); step.add(scroll, "0,1"); step.add(jpnParameterFooter, "0,2"); return step; }
From source file:org.openmicroscopy.shoola.agents.dataBrowser.browser.BrowserModel.java
/** * Implemented as specified by the {@link Browser} interface. * @see Browser#scrollToNode(ImageDisplay) *///from w ww. j a v a2 s . co m public void scrollToNode(ImageDisplay node) { if (node == null) return; JScrollPane pane = rootDisplay.getDeskDecorator(); Rectangle bounds = node.getBounds(); Rectangle viewRect = pane.getViewport().getViewRect(); if (viewRect.contains(bounds)) return; JScrollBar hBar = pane.getHorizontalScrollBar(); if (hBar.isVisible()) { int x = bounds.x; int max = hBar.getMaximum(); if (x > max) x = max; hBar.setValue(x); } JScrollBar vBar = pane.getVerticalScrollBar(); if (vBar.isVisible()) { int y = bounds.y; int max = vBar.getMaximum(); if (y > max) y = max; vBar.setValue(y); } }
From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUI.java
/** * Creates the component hosting the debug text. * // w w w. j a v a2s .com * @return See above. */ private JComponent createDebugTab() { debugTextPane = new JTextPane(); debugTextPane.setEditable(false); StyledDocument doc = (StyledDocument) debugTextPane.getDocument(); Style style = doc.addStyle(STYLE, null); StyleConstants.setForeground(style, Color.black); StyleConstants.setFontFamily(style, "SansSerif"); StyleConstants.setFontSize(style, 12); StyleConstants.setBold(style, false); JScrollPane sp = new JScrollPane(debugTextPane); sp.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { try { debugTextPane.setCaretPosition(debugTextPane.getDocument().getLength()); } catch (IllegalArgumentException ex) { // } } }); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(sp, BorderLayout.CENTER); return panel; }
From source file:org.optaplanner.mes.common.swingui.SolverAndPersistenceFrame.java
private JComponent createScoreFieldPanel() { scoreFieldPanel = new JPanel(); scoreTextArea = new JTextArea(); scoreFieldPanel.add(scoreTextArea);/*from w w w .j av a 2s.c om*/ scoreFieldPanel.setLayout(new BoxLayout(scoreFieldPanel, BoxLayout.Y_AXIS)); JScrollPane scrollPane = new JScrollPane(scoreFieldPanel); scrollPane.getVerticalScrollBar().setUnitIncrement(25); scrollPane.setMinimumSize(new Dimension(100, 80)); // Size fits into screen resolution 1024*768 scrollPane.setPreferredSize(new Dimension(180, 200)); scoreFieldTitlePanel = new JPanel(new BorderLayout()); scoreFieldTitlePanel.add(scrollPane, BorderLayout.CENTER); scoreFieldTitlePanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createTitledBorder("Score"))); return scoreFieldTitlePanel; }
From source file:org.pentaho.reporting.designer.core.ReportDesignerFrame.java
private JComponent createPaletteToolBar() { final JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false);/*from ww w . java 2 s . c o m*/ toolBar.setOrientation(JToolBar.VERTICAL); final ElementMetaData[] datas = ElementTypeRegistry.getInstance().getAllElementTypes(); Arrays.sort(datas, new GroupedMetaDataComparator()); Object grouping = null; boolean firstElement = true; for (int i = 0; i < datas.length; i++) { final ElementMetaData data = datas[i]; if (data.isHidden()) { continue; } if (!WorkspaceSettings.getInstance().isVisible(data)) { continue; } final String currentGrouping = data.getGrouping(Locale.getDefault()); if (firstElement == false) { if (ObjectUtilities.equal(currentGrouping, grouping) == false) { grouping = currentGrouping; toolBar.addSeparator(); } } else { grouping = currentGrouping; firstElement = false; } final InsertElementAction action = new InsertElementAction(data); action.setReportDesignerContext(context); toolBar.add(new PaletteButton(data, context)); } final JScrollPane paletteScrollpane = new JScrollPane(toolBar); paletteScrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); paletteScrollpane .addComponentListener(new ScrollbarSyncHandler(paletteScrollpane.getVerticalScrollBar(), toolBar)); return paletteScrollpane; }
From source file:org.pmedv.blackboard.commands.CreateBoardCommand.java
@Override public void execute(ActionEvent e) { final ApplicationContext ctx = AppContext.getContext(); final ApplicationWindowAdvisor advisor = ctx.getBean(ApplicationWindowAdvisor.class); final ApplicationWindow win = ctx.getBean(ApplicationWindow.class); /*//from ww w . j a va 2 s . c o m * Get the resource service */ final ResourceService resources = ctx.getBean(ResourceService.class); /* * The infonode docking framework must be invoked later since swing is * not thread safe. */ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { BoardEditorModel model = new BoardEditorModel(); model.addDefaultLayers(); model.setWidth(IOUtils.BOARD_DEFAULT_WIDTH); model.setHeight(IOUtils.BOARD_DEFAULT_HEIGHT); String title = resources.getResourceByKey("CreateBoardCommand.name"); String subTitle = resources.getResourceByKey("CreateBoardCommand.dialog.subtitle"); BoardPropertiesDialog bpd = new BoardPropertiesDialog(title, subTitle, resources.getIcon("icon.dialog.board"), model); bpd.setVisible(true); if (bpd.getResult() == AbstractNiceDialog.OPTION_CANCEL) return; final BoardEditor editor = new BoardEditor(model); // the center panel centers the editor inside the view no matter which dimensions it has CenterPanel panel = new CenterPanel(); // go for the zoom JXLayer<?> zoomLayer = TransformUtils.createTransformJXLayer(editor, 1, new QualityHints()); panel.getCenterPanel().add(zoomLayer); editor.setZoomLayer(zoomLayer); panel.setBoardEditor(editor); // put the panel into a scroll pane JScrollPane s = new JScrollPane(panel); s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); s.getVerticalScrollBar().setUnitIncrement(512); // create new view and connect the view with the editor editorView = new View(title, resources.getIcon("icon.editor"), s); editor.setView(editorView); editor.setFileState(FileState.NEW_AND_UNSAVED); editor.setCurrentFile(null); // check all available open views ArrayList<View> views = EditorUtils.getCurrentPerspectiveViews(advisor.getCurrentPerspective()); // we need this index for a new untitled view int lastUntitledIndex = 0; for (View v : views) { // found a view with an untitled editor if (v.getViewProperties().getTitle().startsWith("untitled")) { // select index if it's greater than the last int index = 0; if (v.getViewProperties().getTitle().contains("*")) { int end = v.getViewProperties().getTitle().lastIndexOf("*"); index = Integer.valueOf(v.getViewProperties().getTitle().substring(8, end)); } else { index = Integer.valueOf(v.getViewProperties().getTitle().substring(8)); } if (index > lastUntitledIndex) lastUntitledIndex = index; } } // and finally add one in order to get the right name lastUntitledIndex++; editor.getView().getViewProperties().setTitle("untitled" + lastUntitledIndex); final int index = editor.getView().hashCode(); EditorUtils.registerEditorListeners(editor); openEditor(editorView, index); log.info("Opening editor : " + title); // notifies the GUI about the editor change if a tab is switched by the mouse editorView.addTabMouseButtonListener(new MouseButtonListener() { @Override public void mouseButtonEvent(MouseEvent e) { handleMouseEvent(e, editor); } }); // wee need to know if a mouse click inside an editor occurs editor.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { handleMouseEvent(e, editor); } }); // This listener handles the close of an editor tab editorView.addListener(new DockingWindowAdapter() { @Override public void windowClosing(DockingWindow arg0) throws OperationAbortedException { if (editor != null) if (editor.getFileState().equals(FileState.DIRTY)) { int result = JOptionPane.showConfirmDialog(win, resources.getResourceByKey("msg.warning.notsaved"), resources.getResourceByKey("msg.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.NO_OPTION) { throw new OperationAbortedException("Aborted."); } } advisor.getCurrentPerspective().getViewMap().removeView(index); editor.notifyListeners(EventType.EDITOR_CLOSED); } @Override public void windowClosed(DockingWindow window) { editor.notifyListeners(EventType.EDITOR_CLOSED); } }); editor.updateStatusBar(); editor.notifyListeners(EventType.EDITOR_CHANGED); ctx.getBean(SetSelectModeCommand.class).execute(null); } }); }
From source file:org.revager.tools.GUITools.java
/** * Scrolls the given scroll pane to top. * /*from ww w . j a v a 2s. c o m*/ * @param scrollPane */ public static void scrollToTop(final JScrollPane scrollPane) { SwingUtilities.invokeLater( () -> scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMinimum())); }
From source file:org.revager.tools.GUITools.java
/** * Scrolls the given scroll pane to bottom. * /* w w w . j av a 2 s.c om*/ * @param scrollPane */ public static void scrollToBottom(final JScrollPane scrollPane) { SwingUtilities.invokeLater( () -> scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum())); }
From source file:org.yccheok.jstock.gui.Utils.java
private static int getScrollBarWidth(JComboBox comboBox, JScrollPane scrollPane) { int scrollBarWidth = 0; if (comboBox.getItemCount() > comboBox.getMaximumRowCount()) { JScrollBar vertical = scrollPane.getVerticalScrollBar(); scrollBarWidth = vertical.getPreferredSize().width; }// ww w . ja va 2s . com return scrollBarWidth; }