List of usage examples for java.awt.event AdjustmentListener AdjustmentListener
AdjustmentListener
From source file:de.codesourcery.jasm16.utils.ASTInspector.java
private void setupUI() throws MalformedURLException { // editor pane editorPane = new JTextPane(); editorScrollPane = new JScrollPane(editorPane); editorPane.addCaretListener(listener); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(400, 600)); editorScrollPane.setMinimumSize(new Dimension(100, 100)); final AdjustmentListener adjustmentListener = new AdjustmentListener() { @Override// w ww . j a va 2 s. c o m public void adjustmentValueChanged(AdjustmentEvent e) { if (!e.getValueIsAdjusting()) { if (currentUnit != null) { doSemanticHighlighting(currentUnit); } } } }; editorScrollPane.getVerticalScrollBar().addAdjustmentListener(adjustmentListener); editorScrollPane.getHorizontalScrollBar().addAdjustmentListener(adjustmentListener); // button panel final JPanel topPanel = new JPanel(); final JToolBar toolbar = new JToolBar(); final JButton showASTButton = new JButton("Show AST"); showASTButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean currentlyVisible = astInspector != null ? astInspector.isVisible() : false; if (currentlyVisible) { showASTButton.setText("Show AST"); } else { showASTButton.setText("Hide AST"); } if (currentlyVisible) { astInspector.setVisible(false); } else { showASTInspector(); } } }); fileChooser.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser chooser; if (lastOpenDirectory != null && lastOpenDirectory.isDirectory()) { chooser = new JFileChooser(lastOpenDirectory); } else { lastOpenDirectory = null; chooser = new JFileChooser(); } final FileFilter filter = new FileFilter() { @Override public boolean accept(File f) { if (f.isDirectory()) { return true; } return f.isFile() && (f.getName().endsWith(".asm") || f.getName().endsWith(".dasm") || f.getName().endsWith(".dasm16")); } @Override public String getDescription() { return "DCPU-16 assembler sources"; } }; chooser.setFileFilter(filter); int returnVal = chooser.showOpenDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { File newFile = chooser.getSelectedFile(); if (newFile.isFile()) { lastOpenDirectory = newFile.getParentFile(); try { openFile(newFile); } catch (IOException e1) { statusModel.addError("Failed to read from file " + newFile.getAbsolutePath(), e1); } } } } }); toolbar.add(fileChooser); toolbar.add(showASTButton); final ComboBoxModel<String> model = new ComboBoxModel<String>() { private ICompilerPhase selected; private final List<String> realModel = new ArrayList<String>(); { for (ICompilerPhase p : compiler.getCompilerPhases()) { realModel.add(p.getName()); if (p.getName().equals(ICompilerPhase.PHASE_GENERATE_CODE)) { selected = p; } } } @Override public Object getSelectedItem() { return selected != null ? selected.getName() : null; } private ICompilerPhase getPhaseByName(String name) { for (ICompilerPhase p : compiler.getCompilerPhases()) { if (p.getName().equals(name)) { return p; } } return null; } @Override public void setSelectedItem(Object name) { selected = getPhaseByName((String) name); } @Override public void addListDataListener(ListDataListener l) { } @Override public String getElementAt(int index) { return realModel.get(index); } @Override public int getSize() { return realModel.size(); } @Override public void removeListDataListener(ListDataListener l) { } }; comboBox.setModel(model); comboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (model.getSelectedItem() != null) { ICompilerPhase oldPhase = findDisabledPhase(); if (oldPhase != null) { oldPhase.setStopAfterExecution(false); } compiler.getCompilerPhaseByName((String) model.getSelectedItem()).setStopAfterExecution(true); try { compile(); } catch (IOException e1) { e1.printStackTrace(); } } } private ICompilerPhase findDisabledPhase() { for (ICompilerPhase p : compiler.getCompilerPhases()) { if (p.isStopAfterExecution()) { return p; } } return null; } }); toolbar.add(new JLabel("Stop compilation after: ")); toolbar.add(comboBox); cursorPosition.setSize(new Dimension(400, 15)); cursorPosition.setEditable(false); statusArea.setPreferredSize(new Dimension(400, 100)); statusArea.setModel(statusModel); /** * TOOLBAR * SOURCE * cursor position * status area */ topPanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; topPanel.add(toolbar, cnstrs); cnstrs = constraints(0, 1, GridBagConstraints.BOTH); cnstrs.gridwidth = GridBagConstraints.REMAINDER; topPanel.add(editorScrollPane, cnstrs); cnstrs = constraints(0, 2, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; topPanel.add(cursorPosition, cnstrs); cnstrs = constraints(0, 3, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; final JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new GridBagLayout()); statusArea.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); statusArea.addMouseListener(new MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { final int row = statusArea.rowAtPoint(e.getPoint()); StatusMessage message = statusModel.getMessage(row); if (message.getLocation() != null) { moveCursorTo(message.getLocation()); } } }; }); statusArea.setFillsViewportHeight(true); statusArea.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); final JScrollPane statusPane = new JScrollPane(statusArea); statusPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); statusPane.setPreferredSize(new Dimension(400, 100)); statusPane.setMinimumSize(new Dimension(100, 20)); cnstrs = constraints(0, 0, GridBagConstraints.BOTH); cnstrs.weightx = 1; cnstrs.weighty = 1; cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = GridBagConstraints.REMAINDER; bottomPanel.add(statusPane, cnstrs); // setup frame frame = new JFrame( "DCPU-16 assembler " + Compiler.VERSION + " (c) 2012 by tobias.gierke@code-sourcery.de"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel); splitPane.setBackground(Color.WHITE); frame.getContentPane().add(splitPane); frame.pack(); frame.setVisible(true); splitPane.setDividerLocation(0.9); }
From source file:br.com.bgslibrary.gui.MainFrame.java
private void autoscroll() { if (autoscrollCheckBox.isSelected()) { adjustmentListener = new AdjustmentListener() { @Override//from ww w. j ava 2 s . c o m public void adjustmentValueChanged(AdjustmentEvent e) { e.getAdjustable().setValue(e.getAdjustable().getMaximum()); } }; logTextScrollPane.getVerticalScrollBar().addAdjustmentListener(adjustmentListener); } else logTextScrollPane.getVerticalScrollBar().removeAdjustmentListener(adjustmentListener); }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
private void peaksDataInitializations() { String classElements[] = _ecurveclass.getName().split("\\."); elutionTableLabel.setText("<html><body><center>Elution Data<br><font size='-1'>(" + classElements[classElements.length - 1] + ")</font></center></body></html>"); elutionTableLabel.setHorizontalAlignment(JLabel.CENTER); elutionTableLabel.setHorizontalTextPosition(JLabel.CENTER); if (transDefHeader == null || transDefHeader.getAQUApairs() == null || transDefHeader.getAQUApairs().size() == 0) { buttonFindMate.setVisible(false); } else {/*from w ww.j ava2 s . co m*/ buttonFindMate.setVisible(true); } peaksScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); peaksScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); peaksTable = new JTable(new PeaksTableModel()); //peaksTable.setPreferredScrollableViewportSize(new Dimension(500, 700)); peaksTable.setSelectionModel(new peaksTableSelectionModel()); peaksTable.setAutoscrolls(true); peaksTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); int totalTableRows = 1; for (MRMTransition curTrans : _mrmTransitions) totalTableRows += (1 + curTrans.getDaughters().size()); ((PeaksTableModel) (peaksTable.getModel())).data = new Object[totalTableRows - 1][peaksData.values().length]; for (peaksData pd : EnumSet.allOf(peaksData.class)) { peaksTable.getColumnModel().getColumn(pd.colno).setPreferredWidth(pd.colWidth); } peaksTable.doLayout(); ((DefaultCellEditor) peaksTable.getDefaultEditor(peaksData.Accept.colClass)).setClickCountToStart(1); int i = 0; for (MRMTransition curTrans : _mrmTransitions) { curTrans.setGraphData(makeParentSeries(curTrans)); int curPrecursorIndex = i; curTrans.setTableRow(curPrecursorIndex); for (peaksData pd : EnumSet.allOf(peaksData.class)) { ((PeaksTableModel) (peaksTable.getModel())).data[i][pd.colno] = null; pd.makeVisible(true); } ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Precursor.colno] = curTrans; for (MRMDaughter d : curTrans.getDaughters().values()) { i++; d.setGraphData(d.makeDaughterSeries()); d.setContinDaughterData(d.makeDaughterSeries(d, true)); d.setElutionDataTableRow(i); ElutionCurveStrategy bes = ElutionCurveStrategy.getInstance(curTrans, d, _ecurveclass); bes.calculateParentElutionCurves(null); bes.calculateDaughterElutionCurves(null); bes.calculateBestCurves(); d.calculateQuality(); curTrans.getElutionCurves().put(d, bes); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = new Boolean( !Utils.allYsAre0(d)); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Peptide.colno] = ""; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Precursor.colno] = curTrans; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Daughter.colno] = d; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.CoStart.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.CoEnd.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.CoDelta.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.AUC.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MaxPeak.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MidTime.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Quality.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Label.colno] = ""; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Code.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.LHRatio.colno] = null; ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Comment.colno] = ""; if (transDefHeader != null && transDefHeader.getDToTD() != null && transDefHeader.getDToTD().get(d) != null) { TransitionDefinition td = transDefHeader.getDToTD().get(d); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Peptide.colno] = td.getPeptide(); ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.Peptide.colno] = td.getPeptide(); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Code.colno] = new Integer( td.getAQUAcode()); } ElutionCurve bestPrecursorCurve = bes.getBestParentCurve(); if (bestPrecursorCurve == null || bestPrecursorCurve.getMinElutionTimeSecs() <= 0.0) { ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.AUC.colno] = new Float(-1); ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.MaxPeak.colno] = new Float(-1); ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.Quality.colno] = new Float(-1); ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.MidTime.colno] = new Float(-1); } else { ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.AUC.colno] = new Float( bestPrecursorCurve.getAUC()); ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.MaxPeak.colno] = new Float( bestPrecursorCurve.getHighestPointY()); ((PeaksTableModel) (peaksTable .getModel())).data[curPrecursorIndex][peaksData.Quality.colno] = new Float( curTrans.getQuality()); } ElutionCurve bestDaughterCurve = bes.getBestDaughterCurve(); if (bestDaughterCurve == null || bestDaughterCurve.getMinElutionTimeSecs() <= 0.0) { ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = new Boolean( false); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.AUC.colno] = new Float(-1); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MaxPeak.colno] = new Float(-1); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Quality.colno] = new Float(-1); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MidTime.colno] = new Float(-1); } else { ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.AUC.colno] = new Float( bestDaughterCurve.getAUC()); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MaxPeak.colno] = new Float( bestDaughterCurve.getHighestPointY()); d.setBestElutionCurve(bestDaughterCurve); ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Quality.colno] = new Float( d.getQuality()); if (_minPeakCutoff > 0 && bestDaughterCurve.getHighestPointY() < _minPeakCutoff) ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = new Boolean( false); if (_minAreaCutoff > 0 && bestDaughterCurve.getAUC() < _minAreaCutoff) ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = new Boolean( false); } } curTrans.setElutionRegionStart(curTrans.calculateMinOfAllBestDaughterCurves()); curTrans.setElutionRegionEnd(curTrans.calculateMaxOfAllBestDaughterCurves()); curTrans.calcMaxYofAllDaughters(); for (int j = curPrecursorIndex; j <= i; j++) { ((PeaksTableModel) (peaksTable.getModel())).data[j][peaksData.CoStart.colno] = new Float( curTrans.getElutionRegionStart()); ((PeaksTableModel) (peaksTable.getModel())).data[j][peaksData.CoEnd.colno] = new Float( curTrans.getElutionRegionEnd()); ((PeaksTableModel) (peaksTable.getModel())).data[j][peaksData.CoDelta.colno] = new Float( curTrans.getElutionRegionEnd() - curTrans.getElutionRegionStart()); ((PeaksTableModel) (peaksTable.getModel())).data[j][peaksData.MidTime.colno] = new Float( curTrans.getCalcXatMaxYAllDaughters()); } i++; } peaksTable.setDefaultRenderer(MRMTransition.class, new MRMTransitionTableRenderer(false)); peaksTable.setDefaultRenderer(MRMDaughter.class, new MRMDaughterTableRenderer(false)); peaksTable.setDefaultRenderer(Number.class, new MRMNumberTableRenderer()); peaksTable.setDefaultRenderer(Integer.class, new MRMNumberTableRenderer()); peaksTable.setDefaultRenderer(Boolean.class, new MRMBooleanRenderer()); peaksTable.getColumnModel().getColumn(peaksData.CoStart.colno).setCellEditor(new NumberTableCellEditor()); peaksTable.getColumnModel().getColumn(peaksData.CoEnd.colno).setCellEditor(new NumberTableCellEditor()); peaksTable.getColumnModel().getColumn(peaksData.Code.colno).setCellEditor(new NumberTableCellEditor()); peaksTable.getColumnModel().getColumn(peaksData.LHRatio.colno).setCellEditor(new NumberTableCellEditor()); peaksScrollPane.getViewport().setView(peaksTable); if (transDefHeader == null) { peaksData.Peptide.makeVisible(false); peaksData.Label.makeVisible(false); peaksData.LHRatio.makeVisible(false); peaksData.Code.makeVisible(false); } else { if (transDefHeader.getAQUApairs() == null || transDefHeader.getAQUApairs().isEmpty()) { peaksData.Label.makeVisible(false); peaksData.LHRatio.makeVisible(false); peaksData.Code.makeVisible(false); } } // "Quality" column, currently unused, is invisible unless one or more of its // values is not -1 peaksData.Quality.makeVisible(!Utils.qualColIsEmpty()); peaksScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent ae) { if (!ae.getValueIsAdjusting()) { peaksTable.repaint(); } } }); peaksTable.getModel().addTableModelListener(new peaksTableListener()); _ptmlsl = new PeaksTableListSelectionListener(); peaksTable.getSelectionModel().addListSelectionListener(_ptmlsl); }
From source file:com.xilinx.kintex7.MainScreen.java
private JPanel testAndStats() { JPanel tstats = new JPanel(); tstats.setLayout(new BoxLayout(tstats, BoxLayout.Y_AXIS)); JPanel ledPanel = new JPanel(new BorderLayout()); JPanel iledPanel = new JPanel(); iledPanel.setLayout(new BoxLayout(iledPanel, BoxLayout.X_AXIS)); led_ddr3 = new JLabel("DDR3", new ImageIcon(led1), JLabel.CENTER); led_phy0 = new JLabel("10G PHY-0", new ImageIcon(led1), JLabel.CENTER); led_phy1 = new JLabel("10G PHY-1", new ImageIcon(led1), JLabel.CENTER); JPanel le1 = new JPanel(new BorderLayout()); le1.add(led_ddr3, BorderLayout.CENTER); JPanel le2 = new JPanel(new BorderLayout()); le2.add(led_phy0, BorderLayout.CENTER); JPanel le3 = new JPanel(new BorderLayout()); le3.add(led_phy1, BorderLayout.CENTER); iledPanel.add(le1);//w w w. ja va 2 s.co m iledPanel.add(le2); iledPanel.add(le3); ledPanel.add(iledPanel, BorderLayout.CENTER); tstats.add(ledPanel); JPanel tstats1 = new JPanel(); tstats1.setLayout(new BoxLayout(tstats1, BoxLayout.Y_AXIS)); tstats1.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(""), BorderFactory.createRaisedBevelBorder())); tstats1.add(testPanelItems()); JPanel dmaInner = new JPanel(new BorderLayout()); JPanel dmaPanel = new JPanel(new BorderLayout()); dmaPanel.setBackground(new Color(130, 170, 180)); table1 = new MyTableModel(dummy_data, dmaColumnNames0); dmaStats1 = new JTable(table1); try { dmaStats1.setDefaultRenderer(Object.class, new CustomTableCellRenderer()); } catch (Exception e) { } JTableHeader dmaHeader = dmaStats1.getTableHeader(); dmaHeader.setForeground(new Color(92, 25, 25)); dmaPanel.add(dmaHeader, BorderLayout.PAGE_START); dmaPanel.add(dmaStats1, BorderLayout.CENTER); dmaInner.add(dmaPanel, BorderLayout.CENTER); tstats1.add(dmaInner); tstats.add(tstats1); JPanel trnPanel = new JPanel(new GridLayout(1, 1)); trnPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("PCIe Statistics"), BorderFactory.createRaisedBevelBorder())); JPanel trn1 = new JPanel(new FlowLayout()); trn1.add(new JLabel("Transmit (writes in Gbps): ")); trnLTX = new JTextField("0.0", 5); trnLTX.setEditable(false); trn1.add(trnLTX); trn1.add(new JLabel("Receive (reads in Gbps): ")); trnLRX = new JTextField("0.0", 5); trnLRX.setEditable(false); trn1.add(trnLRX); trnPanel.add(trn1); tstats.add(trnPanel); JPanel tstats2 = new JPanel(); tstats2.setLayout(new BoxLayout(tstats2, BoxLayout.Y_AXIS)); tstats2.add(testPanelItems1()); tstats2.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(""), BorderFactory.createRaisedBevelBorder())); JPanel dmaPanel1 = new JPanel(new BorderLayout()); table2 = new MyTableModel(dummy_data, dmaColumnNames1); dmaStats2 = new JTable(table2); try { dmaStats2.setDefaultRenderer(Object.class, new CustomTableCellRenderer()); } catch (Exception e) { } JTableHeader dmaHeader1 = dmaStats2.getTableHeader(); dmaHeader1.setForeground(new Color(92, 25, 25)); dmaPanel1.add(dmaHeader1, BorderLayout.PAGE_START); dmaPanel1.add(dmaStats2, BorderLayout.CENTER); tstats2.add(dmaPanel1); tstats.add(tstats2); JPanel tstats3 = new JPanel(new BorderLayout()); tstats3.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Message Log"), BorderFactory.createRaisedBevelBorder())); textArea = new CustomTextPane(); final JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); // keep scrollbar at end showing latest messages scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { BoundedRangeModel brm = scrollPane.getVerticalScrollBar().getModel(); boolean wasAtBottom = true; @Override public void adjustmentValueChanged(AdjustmentEvent ae) { if (!brm.getValueIsAdjusting()) { if (wasAtBottom) brm.setValue(brm.getMaximum()); } else wasAtBottom = ((brm.getValue() + brm.getExtent()) == brm.getMaximum()); } }); textArea.setEditable(false); tstats3.add(scrollPane, BorderLayout.CENTER); tstats.add(tstats3); return tstats; }
From source file:de.codesourcery.jasm16.ide.ui.views.SourceCodeView.java
private final JPanel createPanel() { disableDocumentListener(); // necessary because setting colors on editor pane triggers document change listeners (is considered a style change...) try {// w ww. j a va 2 s .c o m editorPane.setEditable(editable); editorPane.getDocument().addUndoableEditListener(undoListener); editorPane.setCaretColor(Color.WHITE); setupKeyBindings(editorPane); setColors(editorPane); editorScrollPane = new JScrollPane(editorPane); setColors(editorScrollPane); editorPane.addCaretListener(listener); editorPane.addMouseListener(mouseListener); editorPane.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0) // ctrl pressed { final ASTNode node = getASTNodeForLocation(e.getPoint()); if (node instanceof SymbolReferenceNode) { maybeUnderlineIdentifierAt(e.getPoint()); } else { clearUnderlineHighlight(); } } else if (compilationUnit != null) { String tooltipText = null; if (compilationUnit != null) { final ASTNode node = getASTNodeForLocation(e.getPoint()); if (node instanceof InvokeMacroNode) { tooltipText = ExpandMacrosPhase.expandInvocation((InvokeMacroNode) node, compilationUnit); if (tooltipText != null) { tooltipText = "<html>" + tooltipText.replace("\n", "<br>") + "</html>"; } } } if (!StringUtils.equals(editorPane.getToolTipText(), tooltipText)) { editorPane.setToolTipText(tooltipText); } } } }); editorPane.addMouseListener(popupListener); } finally { enableDocumentListener(); } EditorContainer.addEditorCloseKeyListener(editorPane, this); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(400, 600)); editorScrollPane.setMinimumSize(new Dimension(100, 100)); final AdjustmentListener adjustmentListener = new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { if (!e.getValueIsAdjusting()) { if (compilationUnit != null) { doHighlighting(compilationUnit, false); } } } }; editorScrollPane.getVerticalScrollBar().addAdjustmentListener(adjustmentListener); editorScrollPane.getHorizontalScrollBar().addAdjustmentListener(adjustmentListener); // button panel final JPanel topPanel = new JPanel(); final JToolBar toolbar = new JToolBar(); setColors(toolbar); cursorPosition.setSize(new Dimension(400, 15)); cursorPosition.setEditable(false); setColors(cursorPosition); /** * TOOLBAR * SOURCE * cursor position * status area */ topPanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; topPanel.add(toolbar, cnstrs); cnstrs = constraints(0, 1, GridBagConstraints.BOTH); cnstrs.gridwidth = GridBagConstraints.REMAINDER; topPanel.add(editorScrollPane, cnstrs); cnstrs = constraints(0, 2, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; topPanel.add(cursorPosition, cnstrs); cnstrs = constraints(0, 3, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0; // setup result panel final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); setColors(panel); cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH); panel.add(topPanel, cnstrs); return panel; }
From source file:base.BasePlayer.Main.java
void setButtons() { try {/*w w w .ja v a2 s. c o m*/ // filemenu.setFont(font); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.NORTHWEST; c.insets = new Insets(1, 4, 4, 2); //c.insets = new Insets(5, 5, 2, 5); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; /* opensamples.setMargin(new Insets(0, 0, 0,0)); opensamples.setPreferredSize(buttonDimension); addtracks.setMargin(new Insets(0, 0, 0, 0)); addtracks.setPreferredSize(buttonDimension); addcontrols.setMargin(new Insets(0, 0, 0, 0)); addcontrols.setPreferredSize(buttonDimension); */ menubar.setOpaque(true); panel.add(menubar, c); c.gridx = 1; setbut = new JButton("", settingsIcon); setbut.setToolTipText("Settings"); setbut.setOpaque(false); setbut.setContentAreaFilled(false); setbut.setBackground(Main.panel.getBackground()); setbut.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { Settings.frame.setLocation( frame.getLocationOnScreen().x + frame.getWidth() / 2 - Settings.frame.getWidth() / 2, frame.getLocationOnScreen().y + frame.getHeight() / 6); Settings.frame.setState(JFrame.NORMAL); Settings.frame.setVisible(true); } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { setbut.setOpaque(true); Main.setbut.setBackground(Color.white); Main.setbut.revalidate(); } @Override public void mouseExited(MouseEvent e) { setbut.setOpaque(false); Main.setbut.revalidate(); } }); setbut.setBorder(null); c.insets = new Insets(0, 2, 0, 0); menubar.add(setbut, c); // c.gridx = 1; // c.gridx = 2; // c.gridx = 3; // zoomout.setMargin(new Insets(0, 0, 0, 0)); // panel.add(zoomout, c); /* JMenuItem empty2 = new JMenuItem(""); empty2.setEnabled(false); menubar.add(empty2); c.gridx = 4;*/ // chromosomeDropdown.setPreferredSize(buttonDimension); // panel.add(chromosomeDropdown, c); // c.gridx = 5; // back.setMargin(new Insets(0, 0, 0, 0)); // forward.setMargin(new Insets(0, 0, 0, 0)); // back.setPreferredSize(new Dimension(back.getFontMetrics(back.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight())); // forward.setPreferredSize(new Dimension(forward.getFontMetrics(forward.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight())); //back.setMinimumSize(new Dimension(back.getFontMetrics(back.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight())); // forward.setMinimumSize(new Dimension(forward.getFontMetrics(forward.getFont()).stringWidth("<")+10,(int)fieldDimension.getHeight())); // panel.add(back, c); // c.gridx = 7; // panel.add(forward, c); chromosomeDropdown.setMaximumRowCount(25); chromosomeDropdown.setEnabled(true); chromosomeDropdown.addActionListener(ChromoDropActionListener); chromosomeDropdown.addMouseListener(this); c.gridwidth = 10; c.gridx = 0; c.gridy = 1; bedScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); bedScroll.getViewport().setPreferredSize(bedDimensions); drawScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); drawScroll.getViewport().setPreferredSize(drawDimensions); chromScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); chromScroll.getViewport().setPreferredSize(chromDimensions); drawScroll.getVerticalScrollBar().setAutoscrolls(false); // chromScroll.getViewport().setPreferredSize(new Dimension(drawWidth,chromHeight-20)); // drawScroll.setBorder(BorderFactory.createEmptyBorder()); //chromScroll.setBorder(BorderFactory.createLoweredBevelBorder()); // drawScroll.setBorder(BorderFactory.createLoweredBevelBorder()); // bedScroll.setBorder(BorderFactory.createLoweredBevelBorder()); // chromScroll.setBorder(BorderFactory.createEmptyBorder()); // bedScroll.setBorder(BorderFactory.createEmptyBorder()); controlScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); controlScroll.getViewport().setPreferredSize(bedDimensions); controlScroll.getViewport().add(controlDraw); controlDraw.setVisible(false); controlScroll.setVisible(false); chromScroll.setBorder(BorderFactory.createEmptyBorder()); drawScroll.setBorder(BorderFactory.createEmptyBorder()); bedScroll.setBorder(BorderFactory.createLoweredBevelBorder()); controlScroll.setBorder(BorderFactory.createLoweredBevelBorder()); addSplit(chromosomeDropdown.getItemAt(0)); chromScroll.getViewport().add(chromDraw); drawScroll.getViewport().add(drawCanvas); drawScroll.addMouseListener(this); bedCanvas = new BedCanvas(drawWidth, 200); bedScroll.getViewport().add(bedCanvas); frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH); c.weightx = 1.0; c.weighty = 1.0; c.fill = GridBagConstraints.BOTH; trackPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, bedScroll, controlScroll); trackPane.setUI(new BasicSplitPaneUI() { public BasicSplitPaneDivider createDefaultDivider() { return new BasicSplitPaneDivider(this) { private static final long serialVersionUID = 1L; public void setBorder(Border b) { } @Override public void paint(Graphics g) { g.setColor(Color.lightGray); g.fillRect(0, 0, getSize().width, getSize().height); super.paint(g); } }; } }); trackPane.setBorder(null); trackPane.setDividerSize(0); trackPane.setPreferredSize(drawDimensions); trackPane.setResizeWeight(0.0); trackPane.setContinuousLayout(true); trackPane.setVisible(false); varpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, trackPane, drawScroll); varpane.setUI(new BasicSplitPaneUI() { public BasicSplitPaneDivider createDefaultDivider() { return new BasicSplitPaneDivider(this) { private static final long serialVersionUID = 1L; public void setBorder(Border b) { } @Override public void paint(Graphics g) { g.setColor(Color.lightGray); g.fillRect(0, 0, getSize().width, getSize().height); super.paint(g); } }; } }); varpane.setBorder(null); varpane.setDividerSize(0); varpane.setPreferredSize(drawDimensions); varpane.setResizeWeight(0.0); varpane.setContinuousLayout(true); bedScroll.setVisible(false); controlScroll.setVisible(false); chrompan = new JPanel() { private static final long serialVersionUID = 1L; protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Draw.sidecolor); g.fillRect(0, 0, this.getWidth(), this.getHeight()); g.setColor(Color.gray); g.fillRect(0, 0, 3, this.getHeight()); g.setColor(Color.lightGray); g.fillRect(2, 0, 2, this.getHeight()); } }; chrompan.setLayout(new GridBagLayout()); GridBagConstraints gb = new GridBagConstraints(); gb.anchor = GridBagConstraints.NORTHWEST; gb.insets = new Insets(2, 10, 2, 2); gb.gridx = 0; gb.gridy = 0; gb.gridwidth = 1; gb.fill = GridBagConstraints.HORIZONTAL; refDropdown.setBackground(Color.white); refDropdown.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.lightGray)); refDropdown.setBorder(BorderFactory.createCompoundBorder(refDropdown.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); geneDropdown.setBackground(Color.white); geneDropdown.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.lightGray)); geneDropdown.setBorder(BorderFactory.createCompoundBorder(geneDropdown.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); geneDropdown.addActionListener(annoDropActionListener); JLabel refLabel = new JLabel("Reference genome:"); JLabel geneLabel = new JLabel("Gene annotation:"); chromLabel.setName("header"); chrompan.add(chromLabel, gb); gb.gridy++; chrompan.add(new JSeparator(), gb); gb.gridy++; gb.insets = new Insets(0, 10, 0, 2); chrompan.add(refLabel, gb); gb.gridy++; chrompan.add(refDropdown, gb); gb.gridy++; chrompan.add(geneLabel, gb); gb.gridy++; chrompan.add(geneDropdown, gb); gb.gridy++; gb.insets = new Insets(20, 10, 0, 2); JLabel memory = new JLabel("Memory usage:"); memory.setName("header"); chrompan.add(memory, gb); gb.insets = new Insets(0, 10, 0, 2); gb.gridy++; chrompan.add(memLabel, gb); gb.weightx = 1; gb.weighty = 1; gb.gridwidth = GridBagConstraints.REMAINDER; chrompan.add(new JLabel(), gb); chrompan.setMinimumSize(new Dimension(1, 1)); chrompan.addComponentListener(this); upPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, chrompan, chromScroll); drawScroll.addComponentListener(this); //upPanel.setBorder(BorderFactory.createLoweredBevelBorder()); upPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.white)); upPanel.setDividerLocation(Main.sidebarWidth - 2); chrompan.setBackground(Draw.sidecolor); BasicSplitPaneUI chromPaneUI = (BasicSplitPaneUI) upPanel.getUI(); chromPaneDivider = chromPaneUI.getDivider(); chromPaneDivider.addMouseListener(this); upPanel.setDividerSize(3); upPanel.setUI(new BasicSplitPaneUI() { public BasicSplitPaneDivider createDefaultDivider() { return new BasicSplitPaneDivider(this) { private static final long serialVersionUID = 1L; public void setBorder(Border b) { } @Override public void paint(Graphics g) { g.setColor(Color.lightGray); g.fillRect(0, 0, getSize().width, getSize().height); super.paint(g); } }; } }); splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upPanel, varpane); splitPane.setUI(new BasicSplitPaneUI() { public BasicSplitPaneDivider createDefaultDivider() { return new BasicSplitPaneDivider(this) { private static final long serialVersionUID = 1L; public void setBorder(Border b) { } @Override public void paint(Graphics g) { g.setColor(Color.lightGray); g.fillRect(0, 0, getSize().width, getSize().height); super.paint(g); } }; } }); BasicSplitPaneUI basicSplitPaneUI = (BasicSplitPaneUI) splitPane.getUI(); splitPaneDivider = basicSplitPaneUI.getDivider(); // splitPaneDivider.addMouseListener(this); basicSplitPaneUI = (BasicSplitPaneUI) trackPane.getUI(); trackPaneDivider = basicSplitPaneUI.getDivider(); // trackPaneDivider.addMouseListener(this); BasicSplitPaneUI splitPaneUI = (BasicSplitPaneUI) varpane.getUI(); varPaneDivider = splitPaneUI.getDivider(); // varPaneDivider.addMouseListener(this); splitPane.setDividerSize(3); splitPane.setPreferredSize(drawDimensions); splitPane.setContinuousLayout(true); panel.add(splitPane, c); add(panel, c); openvcfs.addActionListener(this); openbams.addActionListener(this); addtracks.addActionListener(this); addcontrols.addActionListener(this); openProject.addActionListener(this); saveProject.addActionListener(this); saveProjectAs.addActionListener(this); dosomething.addActionListener(this); clear.addActionListener(this); // drawScroll.getVerticalScrollBar().addMouseMotionListener(this); drawScroll.getVerticalScrollBar().addMouseListener(this); drawScroll.getVerticalScrollBar().addMouseMotionListener(this); drawScroll.getVerticalScrollBar().addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { Draw.setGlasspane(true); if (e.getWheelRotation() < 0) { if (drawCanvas.drawVariables.visiblestart > 0) { drawCanvas.drawVariables.visiblestart--; } Draw.setScrollbar((int) (drawCanvas.drawVariables.visiblestart * drawCanvas.drawVariables.sampleHeight)); } else { if (drawCanvas.drawVariables.visiblestart + drawCanvas.drawVariables.visiblesamples < Main.samples) { drawCanvas.drawVariables.visiblestart++; } Draw.setScrollbar((int) (drawCanvas.drawVariables.visiblestart * drawCanvas.drawVariables.sampleHeight)); } } } ); drawScroll.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent event) { //System.out.println(drawCanvas.drawVariables.visiblestart +" " +(short)(Main.drawScroll.getVerticalScrollBar().getValue()/drawCanvas.drawVariables.sampleHeight)); if (drawCanvas.drawVariables.visiblestart != (short) (Main.drawScroll.getVerticalScrollBar() .getValue() / drawCanvas.drawVariables.sampleHeight)) { if (!drawCanvas.sidebar) { drawCanvas.drawVariables.visiblestart = (short) (Main.drawScroll.getVerticalScrollBar() .getValue() / drawCanvas.drawVariables.sampleHeight); } if (drawCanvas.splits.size() > 1) { for (int i = 0; i < drawCanvas.splits.size(); i++) { drawCanvas.splits.get(i).updateReads = true; } } else { Draw.updateReads = true; Draw.updatevars = true; } Draw.updatevars = true; Main.drawCanvas.repaint(); } } }); zoomout.addActionListener(this); FileRead.head = new VarNode(0, (byte) 0, "N", (short) 0, (short) 0, false, (float) 0, (float) 0, null, null, new Sample("", (short) 1, null), null, null); drawCanvas.current = FileRead.head; frame.addComponentListener(this); frame.addMouseListener(this); frame.setGlassPane(glassPane); glassPane.setOpaque(false); glassPane.setVisible(false); positionField.setText("chr1:1-" + MethodLibrary.formatNumber(drawCanvas.splits.get(0).chromEnd)); positionField.setToolTipText("Current chromosomal region"); widthLabel.setText(MethodLibrary.formatNumber(drawCanvas.splits.get(0).chromEnd) + "bp"); widthLabel.setToolTipText("Current region width in base pairs"); } catch (Exception e) { e.printStackTrace(); } }
From source file:base.BasePlayer.FileRead.java
static void setTable(BedTrack track) { JScrollPane addpane = new JScrollPane(); addpane.setPreferredSize(new Dimension(500, 400)); BedTable add = new BedTable((int) Main.screenSize.width, (int) Main.screenSize.height, addpane, track); addpane.getViewport().add(add);/*from w ww . j a v a 2 s. c om*/ addpane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent event) { if (VariantHandler.tabs.getSelectedIndex() > 2) { VariantHandler.tables.get(VariantHandler.tabs.getSelectedIndex() - 3).repaint(); } } }); VariantHandler.tables.add(add); VariantHandler.tablescrolls.add(addpane); track.setTable(add); add.resizeTable(VariantHandler.tableScroll.getViewport().getWidth()); if (track.file != null) { /*if(track.file.getName().length() > 10) { VariantHandler.tabs.add(track.file.getName().substring(0, 10) +"...", addpane); add.setName(track.file.getName().substring(0, 10) +"..."); } else {*/ VariantHandler.tabs.add(track.file.getName().replace(".pfm", ""), addpane); add.setName(track.file.getName()); // } } else { /*if(FilenameUtils.getName(track.url.getFile()).length() > 10) { VariantHandler.tabs.add(FilenameUtils.getName(track.url.getFile()).substring(0, 10) +"...", addpane); add.setName(FilenameUtils.getName(track.url.getFile()).substring(0, 10) +"..."); } else {*/ VariantHandler.tabs.add(FilenameUtils.getName(track.url.getFile()), addpane); add.setName(FilenameUtils.getName(track.url.getFile())); // } } //VariantHandler.clusterTable.addHeaderColumn(track); MethodLibrary.addHeaderColumns(track); VariantHandler.tabs.revalidate(); }
From source file:ome.formats.importer.gui.GuiImporter.java
/** * Main entry class for the application//www . ja va 2s .co m * * @param config - ImportConfig file */ public GuiImporter(ImportConfig config) { //super(TITLE); //javax.swing.ToolTipManager.sharedInstance().setDismissDelay(0); this.setConfig(config); this.bounds = config.getUIBounds(); Level level = org.apache.log4j.Level.toLevel(config.getDebugLevel()); LogAppender.setLoggingLevel(level); historyHandler = new HistoryHandler(this); setHistoryTable(historyHandler.table); // Add a shutdown hook for when app closes Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { log.debug("Running shutdown hook."); shutdown(); } }); // Set app defaults setTitle(config.getAppTitle()); setIconImage(GuiCommonElements.getImageIcon(GuiImporter.ICON).getImage()); setPreferredSize(new Dimension(bounds.width, bounds.height)); setSize(bounds.width, bounds.height); setLocation(bounds.x, bounds.y); setLayout(new BorderLayout()); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); pack(); addWindowListener(this); // capture move info addComponentListener(new ComponentAdapter() { public void componentMoved(ComponentEvent evt) { bounds = getBounds(); } }); // capture resize info addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent evt) { bounds = getBounds(); } }); // menu bar menubar = new JMenuBar(); fileMenu = new JMenu("File"); menubar.add(fileMenu); login = new JMenuItem("Login to the server...", GuiCommonElements.getImageIcon(LOGIN_ICON)); login.setActionCommand("login"); login.addActionListener(this); fileMenu.add(login); options = new JMenuItem("Options...", GuiCommonElements.getImageIcon(CONFIG_ICON)); options.setActionCommand("options"); options.addActionListener(this); fileMenu.add(options); fileQuit = new JMenuItem("Quit", GuiCommonElements.getImageIcon(QUIT_ICON)); fileQuit.setActionCommand("quit"); fileQuit.addActionListener(this); fileMenu.add(fileQuit); helpMenu = new JMenu("Help"); menubar.add(helpMenu); helpComment = new JMenuItem("Send a Comment...", GuiCommonElements.getImageIcon(COMMENT_ICON)); helpComment.setActionCommand("comment"); helpComment.addActionListener(this); helpHome = new JMenuItem("Visit Importer Homepage...", GuiCommonElements.getImageIcon(HOME_ICON)); helpHome.setActionCommand("home"); helpHome.addActionListener(this); helpForums = new JMenuItem("Visit the OMERO Forums...", GuiCommonElements.getImageIcon(FORUM_ICON)); helpForums.setActionCommand("forums"); helpForums.addActionListener(this); helpAbout = new JMenuItem("About the Importer...", GuiCommonElements.getImageIcon(ABOUT_ICON)); helpAbout.setActionCommand("about"); helpAbout.addActionListener(this); helpMenu.add(helpComment); helpMenu.add(helpHome); helpMenu.add(helpForums); // Help --> Show log file location... JMenuItem helpShowLog = new JMenuItem("Show log file location...", GuiCommonElements.getImageIcon(LOGFILE_ICON)); helpShowLog.setActionCommand(show_log_file); helpShowLog.addActionListener(this); helpMenu.add(helpShowLog); helpMenu.add(helpAbout); // Help --> About setJMenuBar(menubar); // tabbed panes tPane = new JTabbedPane(); tPane.setOpaque(false); // content panes must be opaque // file chooser pane JPanel filePanel = new JPanel(new BorderLayout()); setStatusBar(new StatusBar()); getStatusBar().setStatusIcon("gfx/server_disconn16.png", "Server disconnected."); getStatusBar().setProgress(false, 0, ""); this.getContentPane().add(getStatusBar(), BorderLayout.SOUTH); // The file chooser sub-pane setFileQueueHandler(new FileQueueHandler(scanEx, importEx, this, config)); //splitPane.setResizeWeight(0.5); filePanel.add(getFileQueueHandler(), BorderLayout.CENTER); tPane.addTab("File Chooser", GuiCommonElements.getImageIcon(CHOOSER_ICON), filePanel, "Add and delete images here to the import queue."); tPane.setMnemonicAt(0, KeyEvent.VK_1); // history pane historyPanel = new JPanel(); historyPanel.setOpaque(false); historyPanel.setLayout(new BorderLayout()); tPane.addTab("Import History", GuiCommonElements.getImageIcon(HISTORY_ICON), historyPanel, "Import history is displayed here."); tPane.setMnemonicAt(0, KeyEvent.VK_4); // output text pane JPanel outputPanel = new JPanel(); outputPanel.setLayout(new BorderLayout()); outputTextPane = new JTextPane(); outputTextPane.setEditable(false); JScrollPane outputScrollPane = new JScrollPane(); outputScrollPane.getViewport().add(outputTextPane); outputScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { try { outputTextPane.setCaretPosition(outputTextPane.getDocument().getLength()); } catch (IllegalArgumentException e1) { log.error("Error setting cursor:" + e1); } } }); outputPanel.add(outputScrollPane, BorderLayout.CENTER); tPane.addTab("Output Text", GuiCommonElements.getImageIcon(OUTPUT_ICON), outputPanel, "Standard output text goes here."); tPane.setMnemonicAt(0, KeyEvent.VK_2); // debug pane JPanel debugPanel = new JPanel(); debugPanel.setLayout(new BorderLayout()); debugTextPane = new JTextPane(); debugTextPane.setEditable(false); JScrollPane debugScrollPane = new JScrollPane(); debugScrollPane.getViewport().add(debugTextPane); debugScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { try { debugTextPane.setCaretPosition(debugTextPane.getDocument().getLength()); } catch (IllegalArgumentException e1) { log.error("Error setting cursor:" + e1); } } }); debugPanel.add(debugScrollPane, BorderLayout.CENTER); tPane.addTab("Debug Text", GuiCommonElements.getImageIcon(BUG_ICON), debugPanel, "Debug messages are displayed here."); tPane.setMnemonicAt(0, KeyEvent.VK_3); // Error Pane errorPanel = new JPanel(); errorPanel.setOpaque(false); errorPanel.setLayout(new BorderLayout()); tPane.addTab("Import Errors", GuiCommonElements.getImageIcon(ERROR_ICON), errorPanel, "Import errors are displayed here."); tPane.setMnemonicAt(0, KeyEvent.VK_5); tPane.setSelectedIndex(0); if (getHistoryTable().db.historyEnabled == false) tPane.setEnabledAt(historyTabIndex, false); // Add the tabbed pane to this panel. add(tPane); this.setVisible(false); historyPanel.add(historyHandler, BorderLayout.CENTER); tPane.setEnabledAt(historyTabIndex, false); setLoginHandler(new LoginHandler(this, getHistoryTable())); LogAppender.getInstance().setTextArea(debugTextPane); appendToOutputLn("> Starting the importer (revision " + getPrintableKeyword(Version.revision) + ")."); appendToOutputLn("> Build date: " + getPrintableKeyword(Version.revisionDate)); appendToOutputLn("> Release date: " + Version.releaseDate); // TODO : should this be a third executor? setErrorHandler(new ErrorHandler(importEx, config)); getErrorHandler().addObserver(this); errorPanel.add(getErrorHandler(), BorderLayout.CENTER); macMenuFix(); //displayLoginDialog(this, true); }
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 . c o m * @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:ua.com.fielden.platform.example.swing.egi.EgiExample.java
private void addTotalsFooterTo(final EntityGridInspector egi, final JPanel topPanel) { // final JPanel panel = new JPanel(new MigLayout("insets 0", "[]", "[]0[]push[]")); // panel.add(egi.getTableHeader(), "grow, wrap"); // panel.add(egi, "grow, wrap"); final JScrollPane scrollPane = new JScrollPane(egi); topPanel.add(scrollPane, "grow, wrap"); final JPanel footer = new JPanel(new MigLayout("nogrid, insets 0")); // footer.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); final List<JComponent> totalsComponents = new ArrayList<JComponent>(); for (int i = 0; i < egi.getColumnCount(); i++) { final TableColumn column = egi.getColumnModel().getColumn(i); final JComponent totalsComponent = i % 2 == 0 ? new JTextField("totals " + i) : new JLabel(); totalsComponent.setPreferredSize(new Dimension(column.getPreferredWidth(), 30)); footer.add(totalsComponent, "grow"); totalsComponents.add(totalsComponent); }/*from w ww. j a va2 s .co m*/ final JScrollPane footerPane = new JScrollPane(footer, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); topPanel.add(footerPane, "grow, wrap, h 40::"); topPanel.add(scrollPane.getHorizontalScrollBar(), "grow, wrap"); scrollPane.getHorizontalScrollBar().addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(final AdjustmentEvent e) { footerPane.getViewport().setViewPosition(new Point(e.getValue(), 0)); } }); egi.getColumnModel().addColumnModelListener(new TableColumnModelListener() { @Override public void columnAdded(final TableColumnModelEvent e) { } @Override public void columnMarginChanged(final ChangeEvent e) { final TableColumn column = egi.getTableHeader().getResizingColumn(); if (column != null) { final JComponent totalsComponent = totalsComponents .get(egi.convertColumnIndexToView(column.getModelIndex())); totalsComponent.setPreferredSize(new Dimension(column.getWidth(), totalsComponent.getHeight())); footer.revalidate(); } } @Override public void columnMoved(final TableColumnModelEvent e) { final JComponent fromComponent = totalsComponents.get(e.getFromIndex()); totalsComponents.set(e.getFromIndex(), totalsComponents.get(e.getToIndex())); totalsComponents.set(e.getToIndex(), fromComponent); footer.removeAll(); for (int i = 0; i < egi.getColumnCount(); i++) { footer.add(totalsComponents.get(i), "grow, gap 0 0 0 0"); } footer.revalidate(); } @Override public void columnRemoved(final TableColumnModelEvent e) { } @Override public void columnSelectionChanged(final ListSelectionEvent e) { } }); // // return panel; }