List of usage examples for javax.swing JScrollPane getVerticalScrollBar
@Transient
public JScrollBar getVerticalScrollBar()
From source file:brainleg.app.intellij.ui.EForm.java
private void configureHtmlPane() { if (htmlPane == null) { htmlPane = new JEditorPane(); htmlPane.setEditable(false);/*from w w w .ja v a 2 s . c o m*/ HTMLEditorKit kit = new HTMLEditorKit(); htmlPane.setEditorKit(kit); JScrollPane scrollPane = new JBScrollPane(htmlPane); scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { Adjustable source = e.getAdjustable(); // check if user is currently dragging the scrollbar's knob if (e.getValueIsAdjusting()) { return; } int orient = source.getOrientation(); if (orient == Adjustable.HORIZONTAL) { return; //we are not interested in horizontal scroll } // get the type of adjustment which caused the value changed event int type = e.getAdjustmentType(); switch (type) { case AdjustmentEvent.UNIT_INCREMENT: // System.out.println("increased by one unit"); break; case AdjustmentEvent.UNIT_DECREMENT: // System.out.println("decreased by one unit"); break; case AdjustmentEvent.BLOCK_INCREMENT: // System.out.println("increased by one block"); break; case AdjustmentEvent.BLOCK_DECREMENT: // System.out.println("decreased by one block"); break; case AdjustmentEvent.TRACK: // System.out.println("knob on the scrollbar was dragged"); break; } // get the current value in the adjustment event int value = e.getValue(); // System.out.println("Current Value: " + value); if (value > 200) { //this is about click middle mouse flip - i.e. about 15% of vertical space (approx) markExceptionAsDontShowNotificationFor(); } } }); StyleSheet styleSheet = kit.getStyleSheet(); CssUtil.addStyles(styleSheet); configureNewHtmlDocument(); htmlPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { URL url = e.getURL(); if (url != null) { BrowserUtil.launchBrowser(url.toString()); } } catch (Throwable t) { t.printStackTrace(); } } } }); solutionPanel.add(scrollPane); } }
From source file:com.web.vehiclerouting.optaplanner.common.swingui.SolverAndPersistenceFrame.java
private JComponent createQuickOpenPanel(List<Action> quickOpenActionList, List<File> fileList, String title) { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); if (fileList.isEmpty()) { JLabel noneLabel = new JLabel("None"); noneLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); panel.add(noneLabel);//from w w w . j a v a2 s . c om } else { for (File file : fileList) { Action quickOpenAction = new QuickOpenAction(file); quickOpenActionList.add(quickOpenAction); JButton quickOpenButton = new JButton(quickOpenAction); quickOpenButton.setHorizontalAlignment(SwingConstants.LEFT); quickOpenButton.setMargin(new Insets(0, 0, 0, 0)); panel.add(quickOpenButton); } } JScrollPane scrollPane = new JScrollPane(panel); scrollPane.getVerticalScrollBar().setUnitIncrement(25); scrollPane.setMinimumSize(new Dimension(100, 80)); // Size fits into screen resolution 1024*768 scrollPane.setPreferredSize(new Dimension(180, 200)); JPanel titlePanel = new JPanel(new BorderLayout()); titlePanel.add(scrollPane, BorderLayout.CENTER); titlePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createTitledBorder(title))); return titlePanel; }
From source file:io.github.jeremgamer.editor.panels.Others.java
public Others(final JFrame frame, final OtherPanel op, final PanelSave ps) { this.frame = frame; this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;/*from w ww . j a va 2 s.c o m*/ try { add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); } catch (IOException e) { e.printStackTrace(); } add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") String name = jop.showInputDialog((JFrame) SwingUtilities.windowForComponent(otherList), "Nommez le composant :", "Crer un composant", JOptionPane.QUESTION_MESSAGE); if (name != null) { for (int i = 0; i < data.getSize(); i++) { if (data.get(i).equals(name)) { name += "1"; } } data.addElement(name); new OtherSave(name); ActionPanel.updateLists(); PanelsPanel.updateLists(); } } catch (IOException e) { e.printStackTrace(); } } }); JButton remove = null; try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { if (otherList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/others/" + otherList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(otherList), "tes-vous sr de vouloir supprimer ce composant?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { File dir = new File("projects/" + Editor.getProjectName() + "/panels"); for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { if (!f.isDirectory()) { try { ps.load(f); } catch (IOException e) { e.printStackTrace(); } OtherSave os = new OtherSave(); try { os.load(file); } catch (IOException e1) { e1.printStackTrace(); } String type = null; switch (os.getInt("type")) { case 0: type = "Zone de saisie"; break; case 1: type = "Zone de saisie de mot de passe"; break; case 2: type = "Zone de saisie (Grande)"; break; case 3: type = "Case cocher"; break; case 4: type = "Menu droulant"; break; case 5: type = "Barre de progression"; break; case 6: type = "Slider"; break; case 7: type = "Spinner"; break; } for (String section : ps.getSectionsContaining( otherList.getSelectedValue() + " (" + type + ")")) { ps.removeSection(section); try { ps.save(f); } catch (IOException e) { e.printStackTrace(); } } } } if (otherList.getSelectedValue().equals(op.getFileName())) { op.setFileName(""); } op.hide(); file.delete(); data.remove(otherList.getSelectedIndex()); ActionPanel.updateLists(); OtherPanel.updateLists(); PanelsPanel.updateLists(); } } } catch (NullPointerException npe) { npe.printStackTrace(); } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.add(add); buttons.add(remove); updateList(); otherList.addMouseListener(new MouseAdapter() { @SuppressWarnings("unchecked") public void mouseClicked(MouseEvent evt) { JList<String> list = (JList<String>) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { op.show(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { op.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { op.hideThenShow(); previousSelection = list.getSelectedValue(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { op.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { op.show(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { op.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { op.hideThenShow(); previousSelection = list.getSelectedValue(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { op.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(otherList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); OtherPanel.updateLists(); }
From source file:com.employee.scheduler.common.swingui.SolverAndPersistenceFrame.java
private JComponent createQuickOpenPanel(JPanel panel, String title, List<Action> quickOpenActionList, List<File> fileList) { panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); refreshQuickOpenPanel(panel, quickOpenActionList, fileList); JScrollPane scrollPane = new JScrollPane(panel); scrollPane.getVerticalScrollBar().setUnitIncrement(25); scrollPane.setMinimumSize(new Dimension(100, 80)); // Size fits into screen resolution 1024*768 scrollPane.setPreferredSize(new Dimension(180, 200)); JPanel titlePanel = new JPanel(new BorderLayout()); titlePanel.add(scrollPane, BorderLayout.CENTER); titlePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createTitledBorder(title))); return titlePanel; }
From source file:EditorDropTarget4.java
public void autoscroll(Point location) { JScrollPane scroller = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, this); if (scroller != null) { JScrollBar hBar = scroller.getHorizontalScrollBar(); JScrollBar vBar = scroller.getVerticalScrollBar(); Rectangle r = getVisibleRect(); if (location.x <= r.x + scrollInsets.left) { // Need to scroll left hBar.setValue(hBar.getValue() - hBar.getUnitIncrement(-1)); }/* w ww .jav a2s . c om*/ if (location.y <= r.y + scrollInsets.top) { // Need to scroll up vBar.setValue(vBar.getValue() - vBar.getUnitIncrement(-1)); } if (location.x >= r.x + r.width - scrollInsets.right) { // Need to scroll right hBar.setValue(hBar.getValue() + hBar.getUnitIncrement(1)); } if (location.y >= r.y + r.height - scrollInsets.bottom) { // Need to scroll down vBar.setValue(vBar.getValue() + vBar.getUnitIncrement(1)); } } }
From source file:coreferenceresolver.gui.MarkupGUI.java
public MarkupGUI() throws IOException { highlightPainters = new ArrayList<>(); for (int i = 0; i < COLORS.length; ++i) { DefaultHighlighter.DefaultHighlightPainter highlightPainter = new DefaultHighlighter.DefaultHighlightPainter( COLORS[i]);/*w w w. ja v a 2 s . c o m*/ highlightPainters.add(highlightPainter); } defaulPath = FileUtils.readFileToString(new File(".\\src\\coreferenceresolver\\gui\\defaultpath")); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(new BorderLayout()); this.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize()); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); //create menu items JMenuItem importMenuItem = new JMenuItem("Import"); JMenuItem exportMenuItem = new JMenuItem("Export"); fileMenu.add(importMenuItem); fileMenu.add(exportMenuItem); menuBar.add(fileMenu); this.setJMenuBar(menuBar); ScrollablePanel mainPanel = new ScrollablePanel(); mainPanel.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.NONE); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); //IMPORT BUTTON importMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // MarkupGUI.reviewElements.clear(); // MarkupGUI.markupReviews.clear(); JFileChooser markupFileChooser = new JFileChooser(defaulPath); markupFileChooser.setDialogTitle("Choose your markup file"); markupFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { final JDialog d = new JDialog(); JPanel p1 = new JPanel(new GridBagLayout()); p1.add(new JLabel("Please Wait..."), new GridBagConstraints()); d.getContentPane().add(p1); d.setSize(100, 100); d.setLocationRelativeTo(null); d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); d.setModal(true); SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() { protected Void doInBackground() throws IOException, BadLocationException { readMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath()); for (int i = 0; i < markupReviews.size(); ++i) { mainPanel.add(newReviewPanel(markupReviews.get(i), i)); } return null; } protected void done() { MarkupGUI.this.revalidate(); d.dispose(); } }; worker.execute(); d.setVisible(true); } else { return; } } }); //EXPORT BUTTON: GET NEW VALUE (REF, TYPE) OF NPs exportMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser markupFileChooser = new JFileChooser(defaulPath); markupFileChooser.setDialogTitle("Choose where your markup file saved"); markupFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { final JDialog d = new JDialog(); JPanel p1 = new JPanel(new GridBagLayout()); p1.add(new JLabel("Please Wait..."), new GridBagConstraints()); d.getContentPane().add(p1); d.setSize(100, 100); d.setLocationRelativeTo(null); d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); d.setModal(true); SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() { protected Void doInBackground() throws IOException { for (Review review : markupReviews) { generateNPsRef(review); } int i = 0; for (ReviewElement reviewElement : reviewElements) { int j = 0; for (Element element : reviewElement.elements) { String newType = element.typeSpinner.getValue().toString(); if (newType.equals("Object")) { markupReviews.get(i).getNounPhrases().get(j).setType(0); } else if (newType.equals("Attribute")) { markupReviews.get(i).getNounPhrases().get(j).setType(3); } else if (newType.equals("Other")) { markupReviews.get(i).getNounPhrases().get(j).setType(1); } else if (newType.equals("Candidate")) { markupReviews.get(i).getNounPhrases().get(j).setType(2); } ++j; } ++i; } initMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath() + File.separator + "markup.out.txt"); return null; } protected void done() { d.dispose(); try { Desktop.getDesktop() .open(new File(markupFileChooser.getSelectedFile().getAbsolutePath())); } catch (IOException ex) { Logger.getLogger(MarkupGUI.class.getName()).log(Level.SEVERE, null, ex); } } }; worker.execute(); d.setVisible(true); } else { return; } } }); JScrollPane scrollMainPane = new JScrollPane(mainPanel); scrollMainPane.getVerticalScrollBar().setUnitIncrement(16); scrollMainPane.setPreferredSize(new Dimension(this.getWidth(), this.getHeight())); scrollMainPane.setSize(this.getWidth(), this.getHeight()); this.setResizable(false); this.add(scrollMainPane, BorderLayout.CENTER); this.setExtendedState(JFrame.MAXIMIZED_BOTH); this.pack(); }
From source file:com.diversityarrays.dal.server.ServerGui.java
public ServerGui(Image serverIconImage, IDalServer svr, DalServerFactory factory, File wwwRoot, DalServerPreferences prefs) {//w ww . j a va 2s. c o m this.serverIconImage = serverIconImage; this.dalServerFactory = factory; this.wwwRoot = wwwRoot; this.preferences = prefs; JMenuBar menuBar = new JMenuBar(); JMenu serverMenu = new JMenu("Server"); menuBar.add(serverMenu); serverMenu.add(serverStartAction); serverMenu.add(serverStopAction); serverMenu.add(exitAction); JMenu commandMenu = new JMenu("Command"); menuBar.add(commandMenu); commandMenu.add(doSql); JMenu urlMenu = new JMenu("URL"); menuBar.add(urlMenu); urlMenu.add(new JMenuItem(copyDalUrlAction)); urlMenu.add(new JMenuItem(showDalUrlQRcodeAction)); setJMenuBar(menuBar); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); messages.setFont(GuiUtil.createMonospacedFont(12)); messages.setEditable(false); setServer(svr); quietOption.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean q = quietOption.isSelected(); if (server != null) { server.setQuiet(q); } } }); JScrollPane scrollPane = new JScrollPane(messages, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); final JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar(); JButton clear = new JButton(new AbstractAction("Clear") { @Override public void actionPerformed(ActionEvent e) { messages.setText(""); } }); final boolean[] follow = new boolean[] { true }; final JCheckBox followTail = new JCheckBox("Follow", follow[0]); followTail.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { follow[0] = followTail.isSelected(); } }); final OutputStream os = new OutputStream() { @Override public void write(int b) throws IOException { char ch = (char) b; messages.append(new Character(ch).toString()); if (ch == '\n' && follow[0]) { verticalScrollBar.setValue(verticalScrollBar.getMaximum()); } } }; TeePrintStream pso = new TeePrintStream(System.out, os); TeePrintStream pse = new TeePrintStream(System.err, os); System.setErr(pse); System.setOut(pso); Box box = Box.createHorizontalBox(); box.add(clear); box.add(followTail); box.add(quietOption); box.add(Box.createHorizontalGlue()); JPanel bottom = new JPanel(new BorderLayout()); bottom.add(BorderLayout.NORTH, box); bottom.add(BorderLayout.SOUTH, statusInfoLine); Container cp = getContentPane(); cp.add(BorderLayout.CENTER, scrollPane); cp.add(BorderLayout.SOUTH, bottom); pack(); setSize(640, 480); final MemoryUsageMonitor mum = new MemoryUsageMonitor(); mum.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { statusInfoLine.setMessage(mum.getMemoryUsage()); } }); if (server == null) { // If initial server is null, allow user to specify addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { removeWindowListener(this); serverStartAction.actionPerformed(null); } }); } else { addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { removeWindowListener(this); ensureDatabaseInitialisedThenStartServer(); } }); } }
From source file:net.sf.mzmine.chartbasics.graphicsexport.GraphicsExportDialog.java
/** * Create the dialog./*from w w w. java2 s. co m*/ */ public GraphicsExportDialog() { final JFrame thisframe = this; // parameters = new GraphicsExportParameters(); chartParam = new ChartThemeParameters(); parametersAndComponents = new HashMap<String, JComponent>(); String[] formats = parameters.getParameter(GraphicsExportParameters.exportFormat).getChoices(); chooser.addChoosableFileFilter(new FileTypeFilter(formats, "Export images")); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); // setBounds(100, 100, 808, 795); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new MigLayout("", "[][][grow]", "[][][][grow]")); { StringParameter p = parameters.getParameter(GraphicsExportParameters.path); StringComponent txtPath = p.createEditingComponent(); contentPanel.add(txtPath, "flowx,cell 0 0,growx"); parametersAndComponents.put(p.getName(), txtPath); } { btnPath = new JButton("Path"); btnPath.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { choosePath(); } }); contentPanel.add(btnPath, "cell 1 0"); } { StringParameter p = parameters.getParameter(GraphicsExportParameters.filename); StringComponent txtFileName = p.createEditingComponent(); contentPanel.add(txtFileName, "cell 0 1,growx"); parametersAndComponents.put(p.getName(), txtFileName); } { JLabel lblFilename = new JLabel("filename"); contentPanel.add(lblFilename, "cell 1 1"); } { JPanel pnSettingsLeft = new JPanel(); pnSettingsLeft.setMinimumSize(new Dimension(260, 260)); contentPanel.add(pnSettingsLeft, "cell 0 3,grow"); pnSettingsLeft.setLayout(new BorderLayout(0, 0)); { GridBagPanel pn = new GridBagPanel(); { // add unit UserParameter p; JComponent comp; // add unit p = (UserParameter) parameters.getParameter(GraphicsExportParameters.unit); comp = p.createEditingComponent(); comp.setToolTipText(p.getDescription()); comp.setEnabled(true); pn.add(comp, 2, 2); parametersAndComponents.put(p.getName(), comp); int i = 0; // add export settings Parameter[] param = parameters.getParameters(); for (int pi = 3; pi < param.length; pi++) { p = (UserParameter) param[pi]; comp = p.createEditingComponent(); comp.setToolTipText(p.getDescription()); comp.setEnabled(true); pn.add(new JLabel(p.getName()), 0, i); pn.add(comp, 1, i, 1, 1, 1, 1); // add to map parametersAndComponents.put(p.getName(), comp); i++; } // add separator pn.add(new JSeparator(), 0, i, 5, 1, 1, 1, GridBagConstraints.BOTH); i++; // add Apply theme button JButton btnApply2 = new JButton("Apply theme"); btnApply2.addActionListener(e -> applyTheme()); pn.add(btnApply2, 0, i, 5, 1, 1, 1, GridBagConstraints.BOTH); i++; // add chart settings param = chartParam.getParameters(); for (int pi = 0; pi < param.length; pi++) { p = (UserParameter) param[pi]; comp = p.createEditingComponent(); comp.setToolTipText(p.getDescription()); comp.setEnabled(true); pn.add(new JLabel(p.getName()), 0, i); pn.add(comp, 1, i, 4, 1); // add to map parametersAndComponents.put(p.getName(), comp); i++; } // add listener to master font JFontSpecs master = (JFontSpecs) parametersAndComponents .get(chartParam.getParameter(ChartThemeParameters.masterFont).getName()); master.addListener(fspec -> { if (listenersEnabled) handleMasterFontChanged(fspec); }); } JScrollPane scrollPane = new JScrollPane(pn); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); pnSettingsLeft.add(scrollPane, BorderLayout.CENTER); scrollPane.getVerticalScrollBar().setUnitIncrement(18); scrollPane.revalidate(); scrollPane.repaint(); } } { { pnChartPreview = new JPanel(); pnChartPreview.setLayout(null); contentPanel.add(pnChartPreview, "cell 1 3 2 1,grow"); } } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("Save"); okButton.addActionListener(e -> saveGraphicsAs()); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { btnRenewPreview = new JButton("Renew Preview"); btnRenewPreview.addActionListener(e -> renewPreview()); buttonPane.add(btnRenewPreview); } { btnApply = new JButton("Apply theme"); btnApply.addActionListener(e -> applyTheme()); buttonPane.add(btnApply); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(e -> setVisible(false)); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } // set all to components updateComponentsFromParameters(); }
From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileGraphicDetailPanel.java
private void init() { this.setMinimumSize(new Dimension(200, 100)); this.setLayout(new BorderLayout()); JPanel panel = new JPanel(); panel.setBackground(Color.WHITE); panel.setLayout(new BorderLayout()); panel.add(createControls(), BorderLayout.WEST); panel.add(createGraphicPanel(), BorderLayout.CENTER); JScrollPane scroll = new JScrollPane(panel); scroll.getVerticalScrollBar().setUnitIncrement(UIAgent.VERTICAL_UNIT_SCROLL); this.add(scroll); }
From source file:com.qspin.qtaste.ui.reporter.TestCaseReportTable.java
public void putEntry(TestResult tr, String campaignReportName) { boolean isInteractiveCommand = tr.getTestCaseDirectory().endsWith("QTaste_interactive"); String testReportName = TestResultsReportManager.getInstance().getReportName(); boolean isManualSUTStartOrStop = testReportName != null && testReportName.startsWith("Manual SUT"); if (interactive) { if (!isInteractiveCommand && !isManualSUTStartOrStop) { return; }//from www . j av a2 s.c o m } else { if (isInteractiveCommand) { return; } if (campaignReportName != null && !campaignReportName.equals(runName)) { return; } if (campaignReportName == null && !runName.equals("Run1")) { return; } } if (!testCases.containsKey(tr)) { Object[] cols = new Object[7]; cols[TEST_CASE] = convertToUniqueTc(tr); cols[DETAILS] = tr.getExtraResultDetails(); if (tr.getReturnValue() != null) { cols[RESULT] = tr.getReturnValue(); } cols[STATUS] = getImage(tr.getStatus()); if (tr.getStatus() != TestResult.Status.RUNNING) { cols[EXEC_TIME] = tr.getFormattedElapsedTime(false); } TestBedConfiguration testbed = TestBedConfiguration.getInstance(); cols[TESTBED] = testbed.getFile().getName().replace("." + StaticConfiguration.CAMPAIGN_FILE_EXTENSION, ""); cols[TC] = tr; //tcModel.addRow(cols); Integer rowNum = new Integer(tcModel.getRowCount()); testCases.put(tr, rowNum); long currentScrollBarMax = 0; JScrollPane scrollPane = (JScrollPane) tcTable.getParent().getParent(); JScrollBar scrollbar = scrollPane.getVerticalScrollBar(); if (scrollbar != null) { if (scrollbar.getMouseListeners().length == 1) { scrollPane.addMouseWheelListener(new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent e) { userScrollPosition = true; } }); scrollbar.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { userScrollPosition = true; } @Override public void mousePressed(MouseEvent e) { userScrollPosition = true; } }); } currentScrollBarMax = scrollbar.getMaximum() - scrollbar.getSize().height - tcTable.getRowHeight(); tcModel.addRow(cols); if (!userScrollPosition) { tcTable.scrollRectToVisible(tcTable.getCellRect(tcModel.getRowCount() - 1, 0, true)); return; } else if (scrollbar.getValue() >= currentScrollBarMax) { tcTable.scrollRectToVisible(tcTable.getCellRect(tcModel.getRowCount() - 1, 0, true)); userScrollPosition = false; return; } else { System.out.println("Scrollbar pos=" + scrollbar.getValue() + "; max=" + currentScrollBarMax + "height=" + scrollbar.getSize().height); } } else { tcModel.addRow(cols); } } else { updateTestCaseRow(tr); } }