List of usage examples for javax.swing JScrollPane getViewport
public JViewport getViewport()
JViewport
. From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java
/** Generates a new ChartGenerator with a blank chart. Before anything else, buildChart() is called. */ public ChartGenerator() { // create the chart buildChart();//from ww w . j ava2 s. c o m chart.getPlot().setBackgroundPaint(Color.WHITE); chart.setAntiAlias(true); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true); split.setBorder(new EmptyBorder(0, 0, 0, 0)); JScrollPane scroll = new JScrollPane(); JPanel b = new JPanel(); b.setLayout(new BorderLayout()); b.add(seriesAttributes, BorderLayout.NORTH); b.add(new JPanel(), BorderLayout.CENTER); scroll.getViewport().setView(b); scroll.setBackground(getBackground()); scroll.getViewport().setBackground(getBackground()); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); LabelledList list = new LabelledList("Chart Properties"); DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list); globalAttributes.add(pan1); JLabel j = new JLabel("Right-Click or Control-Click"); j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC)); list.add(j); j = new JLabel("on Chart for More Options"); j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC)); list.add(j); titleField = new PropertyField() { public String newValue(String newValue) { setTitle(newValue); getChartPanel().repaint(); return newValue; } }; titleField.setValue(chart.getTitle().getText()); list.add(new JLabel("Title"), titleField); buildGlobalAttributes(list); final JCheckBox legendCheck = new JCheckBox(); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LegendTitle title = new LegendTitle(chart.getPlot()); title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4)); chart.addLegend(title); } else { chart.removeLegend(); } } }; legendCheck.addItemListener(il); list.add(new JLabel("Legend"), legendCheck); legendCheck.setSelected(true); /* final JCheckBox aliasCheck = new JCheckBox(); aliasCheck.setSelected(chart.getAntiAlias()); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED ); } }; aliasCheck.addItemListener(il); list.add(new JLabel("Antialias"), aliasCheck); */ JPanel pdfButtonPanel = new JPanel(); pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output")); DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel); pdfButtonPanel.setLayout(new BorderLayout()); Box pdfbox = new Box(BoxLayout.Y_AXIS); pdfButtonPanel.add(pdfbox, BorderLayout.WEST); JButton pdfButton = new JButton("Save as PDF"); pdfbox.add(pdfButton); pdfButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE); fd.setFile(chart.getTitle().getText() + ".pdf"); fd.setVisible(true); String fileName = fd.getFile(); if (fileName != null) { Dimension dim = chartPanel.getPreferredSize(); PDFEncoder.generatePDF(chart, dim.width, dim.height, new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf"))); } } }); movieButton = new JButton("Create a Movie"); pdfbox.add(movieButton); pdfbox.add(Box.createGlue()); movieButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (movieMaker == null) { startMovie(); } else { stopMovie(); } } }); globalAttributes.add(pan2); // we add into an outer box so we can later on add more global seriesAttributes // as the user instructs and still have glue be last Box outerAttributes = Box.createVerticalBox(); outerAttributes.add(globalAttributes); outerAttributes.add(Box.createGlue()); p.add(outerAttributes, BorderLayout.NORTH); p.add(scroll, BorderLayout.CENTER); p.setMinimumSize(new Dimension(0, 0)); p.setPreferredSize(new Dimension(200, 0)); split.setLeftComponent(p); // Add scale and proportion fields Box header = Box.createHorizontalBox(); final double MAXIMUM_SCALE = 8; fixBox = new JCheckBox("Fill"); fixBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setFixed(fixBox.isSelected()); } }); header.add(fixBox); fixBox.setSelected(true); // add the scale field scaleField = new NumberTextField(" Scale: ", 1.0, true) { public double newValue(double newValue) { if (newValue <= 0.0) { newValue = currentValue; } if (newValue > MAXIMUM_SCALE) { newValue = currentValue; } scale = newValue; resizeChart(); return newValue; } }; scaleField.setToolTipText("Zoom in and out"); scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); scaleField.setEnabled(false); scaleField.setText(""); header.add(scaleField); // add the proportion field proportionField = new NumberTextField(" Proportion: ", 1.5, true) { public double newValue(double newValue) { if (newValue <= 0.0) { newValue = currentValue; } proportion = newValue; resizeChart(); return newValue; } }; proportionField.setToolTipText("Change the chart proportions (ratio of width to height)"); proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); header.add(proportionField); chartHolder.setMinimumSize(new Dimension(0, 0)); chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); chartHolder.getViewport().setBackground(Color.gray); JPanel p2 = new JPanel(); p2.setLayout(new BorderLayout()); p2.add(chartHolder, BorderLayout.CENTER); p2.add(header, BorderLayout.NORTH); split.setRightComponent(p2); setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); // set the default to be white, which looks good when printed chart.setBackgroundPaint(Color.WHITE); // JFreeChart has a hillariously broken way of handling font scaling. // It allows fonts to scale independently in X and Y. We hack a workaround here. chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT); chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT); chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion)); chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion)); chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION), (int) (DEFAULT_CHART_HEIGHT))); }
From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java
private JScrollPane addScrollPane(final Dimension dimension, final JList list) { JScrollPane scrollleft = new JScrollPane(list); scrollleft.setOpaque(false);//w ww . j av a2 s . c om scrollleft.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollleft.getViewport().setOpaque(false); scrollleft.setPreferredSize(dimension); return scrollleft; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java
/** * @param p/*www .j a va 2 s . co m*/ * @param wbRow */ protected void copyDataFromForm(final InputPanel p, final WorkbenchRow wbRow) { short col = p.getWbtmi().getViewOrder(); WorkbenchDataItem result = null; if (p.getComp() instanceof JTextComponent) { String data = ((JTextComponent) p.getComp()).getText(); String cellData = wbRow.getData(col); if (StringUtils.isNotEmpty(cellData) || data != null) { result = wbRow.setData(data == null ? "" : data, col, true); } } else if (p.getComp() instanceof GetSetValueIFace) { Object data = ((GetSetValueIFace) p.getComp()).getValue(); String cellData = wbRow.getData(col); if (StringUtils.isNotEmpty(cellData) || data != null) { result = wbRow.setData(data == null ? "" : data.toString(), col, true); } } else if (p.getComp() instanceof JScrollPane) { JScrollPane sc = (JScrollPane) p.getComp(); Component comp = sc.getViewport().getView(); if (comp instanceof JTextArea) { result = wbRow.setData(((JTextArea) comp).getText(), col, true); } } else if (p.getComp() instanceof JComboBox) { JComboBox cb = (JComboBox) p.getComp(); result = wbRow.setData(cb.getSelectedItem().toString(), col, true); } else { log.error("Can't get data from control[" + p.getLabelText() + "]"); } if (result != null && workbenchPane.getTask() instanceof SGRTask) { wbRow.setSgrStatus((byte) 1); } }
From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java
/** * Sets the data into the form for a given index. * @param index the index of the record to be set *//*from www .j a v a 2 s . c o m*/ protected void setDataIntoForm(final int index) { if (index < 0) { ignoreChanges = true; for (InputPanel panel : uiComps) { panel.getLabel().setEnabled(false); Component comp = panel.getComp(); comp.setEnabled(false); if (comp instanceof JTextComponent) { ((JTextComponent) comp).setText(""); } else if (comp instanceof JCheckBox) { ((JCheckBox) comp).setSelected(false); } } ignoreChanges = false; SwingUtilities.invokeLater(new Runnable() { public void run() { workbenchPane.getResultSetController().getNewRecBtn().requestFocus(); } }); return; } else if (index == 0 && workbench.getWorkbenchRowsAsList().size() == 1) { for (InputPanel panel : uiComps) { panel.getLabel().setEnabled(true); panel.getComp().setEnabled(true); } } ignoreChanges = true; // turn off change notification int modelIndex = workbenchPane.getSpreadSheet().convertRowIndexToModel(index); WorkbenchRow wbRow = workbench.getWorkbenchRowsAsList().get(modelIndex); for (InputPanel p : uiComps) { int col = p.getWbtmi().getViewOrder(); if (p.getComp() instanceof GetSetValueIFace) { ((GetSetValueIFace) p.getComp()).setValue(wbRow.getData(col), wbRow.getData(col)); } else if (p.getComp() instanceof JComboBox) { ((JComboBox) p.getComp()).setSelectedItem(wbRow.getData(col)); } else if (p.getComp() instanceof JScrollPane) { JScrollPane sc = (JScrollPane) p.getComp(); Component comp = sc.getViewport().getView(); if (comp instanceof JTextArea) { ((JTextArea) comp).setText(wbRow.getData(col)); } } else { ((JTextComponent) p.getComp()).setText(wbRow.getData(col)); } } ignoreChanges = false; }
From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java
private JPanel getElementos() { JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEADING)); panel.setOpaque(false);//from w w w. ja v a 2 s. co m panel.setBorder(new TitledBorder("Elementos a Consultar")); JLabel jLabel = new JLabel("Recursos", SwingConstants.RIGHT); jLabel.setPreferredSize(ConsultaHistoricos.DIMENSION_LABEL); panel.add(jLabel); recursos = new JList(new DefaultListModel()); recursos.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK), "selectAll"); recursos.getActionMap().put("selectAll", new AbstractAction() { private static final long serialVersionUID = -5515338515763292526L; @Override public void actionPerformed(ActionEvent e) { recursos.setSelectionInterval(0, recursos.getModel().getSize() - 1); } }); recursos.addListSelectionListener(listSelectionListener); final JScrollPane jScrollPaneR = new JScrollPane(recursos, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); jScrollPaneR.getViewport().setPreferredSize(DIMENSION_JLIST); panel.add(jScrollPaneR); jLabel = new JLabel("Incidencias", SwingConstants.RIGHT); jLabel.setPreferredSize(ConsultaHistoricos.DIMENSION_LABEL); panel.add(jLabel); incidencias = new JList(new DefaultListModel()); incidencias.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK), "selectAll"); incidencias.getActionMap().put("selectAll", new AbstractAction() { private static final long serialVersionUID = -5515338515763292526L; @Override public void actionPerformed(ActionEvent e) { incidencias.setSelectionInterval(0, incidencias.getModel().getSize() - 1); } }); incidencias.addListSelectionListener(listSelectionListener); final JScrollPane jScrollPaneI = new JScrollPane(incidencias, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); jScrollPaneI.getViewport().setPreferredSize(DIMENSION_JLIST); panel.setPreferredSize(DIMENSION_2JLIST); panel.add(jScrollPaneI); return panel; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java
/** * Creates the proper UI component for the Mapping item. * @param dbFieldType the field type//from w ww . j ava2 s .co m * @param caption the caption * @param fieldName the name of the field * @param dataFieldLength the length of the definition for that field * @param fieldType the field type * @return a UI component for editing */ protected JComponent createUIComp(final Class<?> dbFieldTypeArg, final String caption, final String fieldName, final Short fieldType, final Short fieldLength, final short columns, final short rows, final WorkbenchTemplateMappingItem wbtmi) { short uiType = WorkbenchTemplateMappingItem.UNKNOWN; //System.out.println(wbtmi.getCaption()+" "+wbtmi.getDataType()+" "+wbtmi.getFieldLength()); Class<?> dbFieldType = dbFieldTypeArg; if (dbFieldType == null) { // if we can't find a class for the field (i.e. Genus Species, or other 'fake' fields), we say it's a string dbFieldType = String.class; } JComponent comp; Component focusComp; // handle dates if (dbFieldType.equals(Calendar.class) || dbFieldType.equals(Date.class)) { //ValFormattedTextField txt = new ValFormattedTextField("Date"); //txt.setColumns(columns == -1 ? DEFAULT_TEXTFIELD_COLS : columns); ValTextField txt = new ValTextField(columns); txt.getDocument().addDocumentListener(docListener); comp = txt; focusComp = comp; uiType = WorkbenchTemplateMappingItem.TEXTFIELD_DATE; } // else if (dbFieldType.equals(Boolean.class)) // strings // { // ValCheckBox checkBox = new ValCheckBox(caption, false, false); // checkBox.addChangeListener(changeListener); // comp = checkBox; // focusComp = comp; // uiType = WorkbenchTemplateMappingItem.CHECKBOX; // } else if (useComboBox(wbtmi)) { //ValComboBox comboBox = new ValComboBox(getValues(wbtmi), true); final JComboBox comboBox = new JComboBox(getValues(wbtmi)); comboBox.setName("Form Combo"); comboBox.setEditable(true); comboBox.addActionListener(new ActionListener() { /* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(ActionEvent arg0) { if (arg0.getSource() == comboBox) { //System.out.println("ComboBox Action!" + ((JComboBox )arg0.getSource()).getName()); stateChange(); } } }); // comboBox.getEditor().getEditorComponent().addFocusListener(new FocusListener() { // // /* (non-Javadoc) // * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent) // */ // @Override // public void focusGained(FocusEvent arg0) { // System.out.println("FOCUS GAINED"); // // } // // /* (non-Javadoc) // * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent) // */ // @Override // public void focusLost(FocusEvent arg0) { // System.out.println("FOCUS LOST"); // // } // // }); comp = comboBox; focusComp = comp; uiType = WorkbenchTemplateMappingItem.COMBOBOX; } else if (useTextField(fieldName, fieldType, fieldLength)) { ValTextField txt = new ValTextField(columns); txt.getDocument().addDocumentListener(docListener); txt.setInputVerifier(new LengthInputVerifier(caption, fieldLength)); comp = txt; focusComp = comp; uiType = WorkbenchTemplateMappingItem.TEXTFIELD; } else { JScrollPane taScrollPane = createTextArea(columns, rows); ((JTextArea) taScrollPane.getViewport().getView()) .setInputVerifier(new LengthInputVerifier(caption, fieldLength)); comp = taScrollPane; focusComp = taScrollPane.getViewport().getView(); uiType = WorkbenchTemplateMappingItem.TEXTAREA; } wbtmi.setFieldType(uiType); focusComp.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { selectControl(e.getSource()); } public void focusLost(FocusEvent e) { //stateChange(); } }); comp.setEnabled(!readOnly); focusComp.setEnabled(!readOnly); comp.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (!readOnly) { if ((e.isControlDown() || e.isMetaDown()) && e.getKeyCode() == KeyEvent.VK_N) { workbenchPane.addRowAfter(); } } super.keyTyped(e); } }); return comp; }
From source file:es.emergya.ui.plugins.AdminPanel.java
/** * /*from w w w. j a v a2s . c om*/ * @param columnNames * nombres de las columnas de la tabla * @param filterOptions * lista de opciones de un combobox. Si esta vacio entonces es un * textfield * @param noFiltrarAction * @param filtrarAction */ public void generateTable(String[] columnNames, Object[][] filterOptions, AdminPanel.NoFiltrarAction noFiltrarAction, AdminPanel.FiltrarAction filtrarAction) { if (columnNames == null) { columnNames = new String[] {}; } if (filterOptions == null) { filterOptions = new Object[][] {}; } String filterString = "["; for (Object[] o : filterOptions) { filterString += Arrays.toString(o) + " "; } filterString += "]"; log.debug("generateTable( columnNames = " + Arrays.toString(columnNames) + ", filterOptions = " + filterString + ")"); tablePanel.removeAll(); int columnNamesLength = columnNames.length; if (!getCanDelete()) columnNamesLength++; MyTableModel dataModel = new MyTableModel(1, columnNamesLength + 2) { private static final long serialVersionUID = 1348355328684460769L; @Override public boolean isCellEditable(int row, int column) { return column != 0 && !invisibleFilterCols.contains(column); } }; filters = new JTable(dataModel) { private static final long serialVersionUID = -8266991359840905405L; @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); if (isCellEditable(row, column) && column != getColumnCount() - 1) { if (c instanceof JTextField) { ((JTextField) c).setBorder(new MatteBorder(1, 1, 1, 1, Color.BLACK)); } else if (c instanceof JComboBox) { ((JComboBox) c).setBorder(new MatteBorder(1, 1, 1, 1, Color.BLACK)); } else if (c instanceof JLabel) { ((JLabel) c).setBorder(new MatteBorder(1, 1, 1, 1, Color.BLACK)); } } return c; } }; filters.setSurrendersFocusOnKeystroke(true); filters.setShowGrid(false); filters.setRowHeight(22); filters.setOpaque(false); for (Integer i = 0; i < filterOptions.length; i++) { final Object[] items = filterOptions[i]; if (items != null && items.length > 1) { setComboBoxEditor(i, items); } else { final DefaultCellEditor defaultCellEditor = new DefaultCellEditor(new JTextField()); defaultCellEditor.setClickCountToStart(1); filters.getColumnModel().getColumn(i + 1).setCellEditor(defaultCellEditor); } } filters.setRowSelectionAllowed(false); filters.setDragEnabled(false); filters.setColumnSelectionAllowed(false); filters.setDefaultEditor(JButton.class, new JButtonCellEditor()); filters.setDefaultRenderer(Object.class, new DefaultTableRenderer() { private static final long serialVersionUID = -4811729559786534118L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (invisibleFilterCols.contains(column)) c = new JLabel(""); return c; } }); filters.setDefaultRenderer(JButton.class, new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JButton b = (JButton) value; b.setBorderPainted(false); b.setContentAreaFilled(false); return b; } }); filters.setDefaultRenderer(JLabel.class, new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return (JLabel) value; } }); filters.setDefaultEditor(JButton.class, new JButtonCellEditor()); filters.getModel().setValueAt(new JLabel(""), 0, 0); JButton jButton2 = new JButton(noFiltrarAction); JButton jButton = new JButton(filtrarAction); jButton.setBorderPainted(false); jButton2.setBorderPainted(false); jButton.setContentAreaFilled(false); jButton2.setContentAreaFilled(false); if (jButton.getIcon() != null) jButton.setPreferredSize( new Dimension(jButton.getIcon().getIconWidth(), jButton.getIcon().getIconHeight())); if (jButton2.getIcon() != null) jButton2.setPreferredSize( new Dimension(jButton2.getIcon().getIconWidth(), jButton2.getIcon().getIconHeight())); filters.getModel().setValueAt(jButton, 0, columnNamesLength - 1); filters.getColumnModel().getColumn(columnNamesLength - 1).setMinWidth(jButton.getWidth() + 24); filters.getModel().setValueAt(jButton2, 0, columnNamesLength); filters.getColumnModel().getColumn(columnNamesLength).setMinWidth(jButton2.getWidth() + 14); cuenta.setHorizontalAlignment(JLabel.CENTER); cuenta.setText("?/?"); filters.getModel().setValueAt(cuenta, 0, columnNamesLength + 1); tablePanel.add(filters, BorderLayout.NORTH); Vector<String> headers = new Vector<String>(); headers.add(""); headers.addAll(Arrays.asList(columnNames)); MyTableModel model = new MyTableModel(headers, 0); table = new JTable(model) { private static final long serialVersionUID = 949284378605881770L; private int highLightedRow = -1; private Rectangle dirtyRegion = null; public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); try { if (AdminPanel.this.myRendererColoring != null) c.setBackground(AdminPanel.this.myRendererColoring .getColor(AdminPanel.this.table.getValueAt(row, 1))); } catch (Throwable t) { log.error("Error al colorear la celda: " + t); } return c; } @Override protected void processMouseMotionEvent(MouseEvent e) { try { int row = rowAtPoint(e.getPoint()); Graphics g = getGraphics(); if (row == -1) { highLightedRow = -1; } // row changed if (highLightedRow != row) { if (null != dirtyRegion) { paintImmediately(dirtyRegion); } for (int j = 0; j < getRowCount(); j++) { if (row == j) { // highlight Rectangle firstRowRect = getCellRect(row, 0, false); Rectangle lastRowRect = getCellRect(row, getColumnCount() - 1, false); dirtyRegion = firstRowRect.union(lastRowRect); g.setColor(new Color(0xff, 0xff, 0, 100)); g.fillRect((int) dirtyRegion.getX(), (int) dirtyRegion.getY(), (int) dirtyRegion.getWidth(), (int) dirtyRegion.getHeight()); highLightedRow = row; } } } } catch (Exception ex) { } super.processMouseMotionEvent(e); } }; table.setRowHeight(22); table.setOpaque(false); // table.setAutoCreateRowSorter(true); table.setDragEnabled(false); table.getTableHeader().setReorderingAllowed(false); table.getTableHeader().setResizingAllowed(false); table.setDefaultEditor(JButton.class, new JButtonCellEditor()); table.setDefaultRenderer(JButton.class, new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JButton b = (JButton) value; if (b != null) { b.setBorderPainted(false); b.setContentAreaFilled(false); } return b; } }); JScrollPane jScrollPane = new JScrollPane(table); jScrollPane.setOpaque(false); jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); jScrollPane.getViewport().setOpaque(false); tablePanel.add(jScrollPane, BorderLayout.CENTER); }
From source file:net.lmxm.ute.gui.MainFrame.java
/** * Clear input validators for current editor. *//*from w ww . j ava 2 s . co m*/ private void clearInputValidatorsForCurrentEditor() { final JScrollPane scrollPane = getJobDetailsEditorScrollPane(); if (scrollPane != null) { final JViewport viewport = scrollPane.getViewport(); if (viewport != null) { final Component view = viewport.getView(); if (view instanceof AbstractEditorPanel) { ((AbstractEditorPanel) view).clearInputValidators(); } } } }
From source file:org.gwaspi.gui.reports.SampleQAHetzygPlotZoom.java
private void initGUI(final JFreeChart zoomChart, final ChartPanel zoomPanel) throws IOException { // setCursor(CursorUtils.WAIT_CURSOR); final JPanel pnl_ChartNavigator = new JPanel(); final JPanel pnl_Chart = new JPanel(); final JScrollPane scrl_Chart = new JScrollPane(); final JPanel pnl_Footer = new JPanel(); final JPanel pnl_FooterGroup1 = new JPanel(); final JPanel pnl_FooterGroup0 = new JPanel(); final JButton btn_Save = new JButton(); final JButton btn_Reset = new JButton(); final JLabel lbl_thresholds = new JLabel(); final JLabel lbl_hetzy = new JLabel(); final JTextField txt_hetzy = new JTextField(); final JButton btn_redraw = new JButton(); final JLabel lbl_missing = new JLabel(); final JTextField txt_missing = new JTextField(); final String titlePlot = Text.Reports.smplHetzyVsMissingRat; pnl_ChartNavigator.setBorder(GWASpiExplorerPanel.createMainTitledBorder(titlePlot)); // NOI18N pnl_Chart.setBorder(GWASpiExplorerPanel.createLineBorder()); scrl_Chart.getViewport().add(zoomPanel); pnl_Chart.add(scrl_Chart, BorderLayout.CENTER); // <editor-fold defaultstate="expanded" desc="LAYOUT1"> GroupLayout pnl_ChartLayout = new GroupLayout(pnl_Chart); pnl_Chart.setLayout(pnl_ChartLayout); pnl_ChartLayout.setHorizontalGroup(pnl_ChartLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(scrl_Chart, GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE)); pnl_ChartLayout.setVerticalGroup(pnl_ChartLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(scrl_Chart, GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE)); GroupLayout pnl_ChartNavigatorLayout = new GroupLayout(pnl_ChartNavigator); pnl_ChartNavigator.setLayout(pnl_ChartNavigatorLayout); pnl_ChartNavigatorLayout.setHorizontalGroup(pnl_ChartNavigatorLayout .createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, pnl_ChartNavigatorLayout .createSequentialGroup().addContainerGap().addComponent(pnl_Chart, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); pnl_ChartNavigatorLayout/*from w w w .jav a2 s.com*/ .setVerticalGroup(pnl_ChartNavigatorLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(pnl_ChartNavigatorLayout .createSequentialGroup().addContainerGap().addComponent(pnl_Chart, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); // </editor-fold> lbl_thresholds.setText(Text.Reports.thresholds); lbl_hetzy.setText(Text.Reports.heterozygosity); txt_hetzy.setText(hetzyThreshold.toString()); lbl_missing.setText(Text.Reports.missRatio); txt_missing.setText(missingThreshold.toString()); btn_redraw.setAction(new RedrawAction(txt_hetzy, txt_missing)); final MatrixMetadata rdMatrixMetadata = getMatrixService().getMatrix(operationKey.getParentMatrixKey()); final String originFriendlyName = rdMatrixMetadata.getFriendlyName(); btn_Save.setAction(new SaveAsAction( "SampleQA_hetzyg-missingrat_" + Utils.stripNonAlphaNumeric(originFriendlyName) + ".png", scrl_Chart, zoomChart, this)); btn_Reset.setAction(new ResetAction()); //<editor-fold defaultstate="expanded" desc="FOOTER"> GroupLayout pnl_FooterGroup0Layout = new GroupLayout(pnl_FooterGroup0); pnl_FooterGroup0.setLayout(pnl_FooterGroup0Layout); pnl_FooterGroup0Layout.setHorizontalGroup(pnl_FooterGroup0Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(pnl_FooterGroup0Layout.createSequentialGroup().addContainerGap() .addGroup(pnl_FooterGroup0Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(pnl_FooterGroup0Layout.createSequentialGroup() .addGroup(pnl_FooterGroup0Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(lbl_hetzy).addComponent(lbl_missing)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnl_FooterGroup0Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(txt_hetzy, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE) .addGroup(pnl_FooterGroup0Layout.createSequentialGroup() .addComponent(txt_missing, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE) .addGap(6, 6, 6).addComponent(btn_redraw, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)))) .addComponent(lbl_thresholds)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); pnl_FooterGroup0Layout.setVerticalGroup(pnl_FooterGroup0Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(GroupLayout.Alignment.TRAILING, pnl_FooterGroup0Layout.createSequentialGroup() .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(lbl_thresholds) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnl_FooterGroup0Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lbl_hetzy).addComponent(txt_hetzy, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(pnl_FooterGroup0Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(btn_redraw, GroupLayout.Alignment.TRAILING, 0, 0, Short.MAX_VALUE) .addGroup(GroupLayout.Alignment.TRAILING, pnl_FooterGroup0Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lbl_missing).addComponent(txt_missing))))); GroupLayout pnl_FooterGroup1Layout = new GroupLayout(pnl_FooterGroup1); pnl_FooterGroup1.setLayout(pnl_FooterGroup1Layout); pnl_FooterGroup1Layout .setHorizontalGroup(pnl_FooterGroup1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(pnl_FooterGroup1Layout.createSequentialGroup().addContainerGap() .addComponent(btn_Reset, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(btn_Save, GroupLayout.PREFERRED_SIZE, 84, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); pnl_FooterGroup1Layout.linkSize(SwingConstants.HORIZONTAL, new Component[] { btn_Reset, btn_Save }); pnl_FooterGroup1Layout .setVerticalGroup(pnl_FooterGroup1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(pnl_FooterGroup1Layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(btn_Reset).addComponent(btn_Save))); pnl_FooterGroup1Layout.linkSize(SwingConstants.VERTICAL, new Component[] { btn_Reset, btn_Save }); GroupLayout pnl_FooterLayout = new GroupLayout(pnl_Footer); pnl_Footer.setLayout(pnl_FooterLayout); pnl_FooterLayout .setHorizontalGroup(pnl_FooterLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(GroupLayout.Alignment.TRAILING, pnl_FooterLayout.createSequentialGroup() .addComponent(pnl_FooterGroup0, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 174, Short.MAX_VALUE) .addComponent(pnl_FooterGroup1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap())); pnl_FooterLayout.setVerticalGroup(pnl_FooterLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(GroupLayout.Alignment.TRAILING, pnl_FooterLayout.createSequentialGroup() .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(pnl_FooterLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(pnl_FooterGroup0, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(pnl_FooterGroup1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap())); //</editor-fold> //<editor-fold defaultstate="expanded" desc="LAYOUT"> GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout .createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(pnl_ChartNavigator, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnl_Footer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout.createSequentialGroup() .addComponent(pnl_ChartNavigator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(pnl_Footer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap())); //</editor-fold> // setCursor(CursorUtils.DEFAULT_CURSOR); }
From source file:edu.ku.brc.specify.tasks.SystemSetupTask.java
/** * /*from www. jav a2s .c om*/ */ private void synonymCleanup() { JTextPane tp = new JTextPane(); JScrollPane js = new JScrollPane(); js.getViewport().add(tp); String text = ""; try { String template = "synonym_cleanup_%s.html"; String fileName = String.format(template, Locale.getDefault().getLanguage()); File file = XMLHelper.getConfigDir(fileName); if (!file.exists()) { fileName = String.format(template, "en"); file = XMLHelper.getConfigDir(fileName); } text = FileUtils.readFileToString(file); } catch (Exception ex) { ex.printStackTrace(); } JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); p.add(js, BorderLayout.CENTER); tp.setContentType("text/html"); tp.setText(text); tp.setCaretPosition(0); tp.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 18)); CustomDialog dlg = new CustomDialog((Frame) getTopWindow(), getI18nRS("SYN_CLEANUP"), true, CustomDialog.OKCANCELAPPLY, p); dlg.setOkLabel(getI18nRS("SYN_CLEANUP")); dlg.setCancelLabel(getI18nRS("Report")); dlg.setApplyLabel(getResourceString("CANCEL")); dlg.setCloseOnApplyClk(true); dlg.createUI(); dlg.setSize(600, 450); UIHelper.centerAndShow(dlg); if (dlg.getBtnPressed() == CustomDialog.OK_BTN || dlg.getBtnPressed() == CustomDialog.CANCEL_BTN) { boolean doCleanup = dlg.getBtnPressed() == CustomDialog.OK_BTN; SynonymCleanup synonymCleanup = new SynonymCleanup(doCleanup); synonymCleanup.execute(); // start the background task } }