List of usage examples for javax.swing JPanel repaint
public void repaint()
From source file:de.main.sessioncreator.ReportingHelper.java
public void addReport(JPanel jp) { jp.removeAll();//from w ww .j a v a 2s . com PieDataset dataset = createDataset(); // based on the dataset we create the chart JFreeChart chart = createChart(dataset, "Sessions by Tester"); // we put the chart into a panel ChartPanel chartPanel = new ChartPanel(chart); chartPanel.updateUI(); chartPanel.setSize(490, 350); jp.revalidate(); jp.setOpaque(true); jp.add(chartPanel); jp.revalidate(); jp.setVisible(true); jp.setSize(700, 500); jp.revalidate(); jp.repaint(); }
From source file:executor.TesterMainGUIMode.java
/** * Add chart panel to the frame/*from w ww .j a v a 2 s.co m*/ */ private void addChartPanel(JPanel chartPanel) { removecurrentChartPanel(); this.currentChartPanel = chartPanel; chartPanel.setPreferredSize(new Dimension(frameWidth, frameHeight - controlPanelHeight)); chartPanel.setMinimumSize(new Dimension(frameWidth, 200)); chartPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)); getContentPane().add(chartPanel); this.validate(); chartPanel.repaint(); }
From source file:ec.nbdemetra.ui.demo.ComponentsDemo.java
public ComponentsDemo() { initStaticResources();// w w w.j a va 2 s . c o m final Map<Id, Component> demoData = lookupComponents(); final JPanel main = new JPanel(new BorderLayout()); final JTree tree = new JTree(); tree.setRootVisible(false); tree.setCellRenderer(new IdRenderer(demoData)); IdsTree.fill(tree, Lists.newArrayList(demoData.keySet())); expandAll(tree); tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { TreePath p = tree.getSelectionPath(); if (p != null) { main.removeAll(); DefaultMutableTreeNode node = (DefaultMutableTreeNode) p.getLastPathComponent(); Id id = IdsTree.translate(node); Component c = demoData.get(id); main.add(c != null ? c : new JPanel()); main.validate(); main.repaint(); } } }); JTsList dragDrop = new JTsList(); dragDrop.setShowHeader(false); dragDrop.setInformation(new ITsList.InfoType[] { ITsList.InfoType.TsIdentifier, ITsList.InfoType.Data }); dragDrop.setPreferredSize(new Dimension(200, 200)); dragDrop.setTsAction(DemoTsActions.DO_NOTHING); JSplitPane left = NbComponents.newJSplitPane(JSplitPane.VERTICAL_SPLIT, NbComponents.newJScrollPane(tree), dragDrop); JSplitPane splitPane = NbComponents.newJSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, main); splitPane.getLeftComponent().setPreferredSize(new Dimension(200, 400)); setLayout(new BorderLayout()); add(splitPane, BorderLayout.CENTER); }
From source file:org.obiba.onyx.jade.instrument.summitdoppler.VantageABIInstrumentRunner.java
protected JPanel buildFileSelectionSubPanel() { final JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(Box.createVerticalGlue()); JButton openButton = new JButton(resourceBundle.getString("Select_file")); openButton.setMnemonic('O'); openButton.setToolTipText(resourceBundle.getString("ToolTip.Select_file")); panel.add(openButton);/* w ww . j ava 2 s .c om*/ panel.add(Box.createRigidArea(new Dimension(10, 10))); JLabel fileLabel = new ABIFileLabel(); panel.add(fileLabel); // Open button listener. openButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int returnVal = fileChooser.showOpenDialog(appWindow); if (returnVal == JFileChooser.APPROVE_OPTION) { abiFile = fileChooser.getSelectedFile(); panel.repaint(); saveButton.setEnabled(true); } } }); panel.setAlignmentX(Component.LEFT_ALIGNMENT); return panel; }
From source file:loansystem.visual.panel.StartPage.java
private void dibujarGrafico(DefaultCategoryDataset datos, int tipoGrafico, String titulo, String ejeX, String ejeY, PlotOrientation orientacion, JPanel contenedor) { JFreeChart grafica = null;/* w w w . jav a2s .c o m*/ switch (tipoGrafico) { case BAR: grafica = ChartFactory.createBarChart3D(titulo, ejeX, ejeY, datos, orientacion, true, true, false); break; case LINE: break; case PIE: break; } grafica.getTitle().setPaint(Color.black); CategoryPlot p = grafica.getCategoryPlot(); p.setRangeGridlinePaint(Color.black); CategoryItemRenderer renderer = ((CategoryPlot) grafica.getPlot()).getRenderer(); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setBaseItemLabelsVisible(true); ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER); renderer.setBasePositiveItemLabelPosition(position); int style = Font.BOLD; Font font = new Font("Tahoma", style, 12); renderer.setItemLabelFont(font); ChartPanel panel = new ChartPanel(grafica); contenedor.add(panel); contenedor.revalidate(); contenedor.repaint(); }
From source file:com.enderville.enderinstaller.ui.Installer.java
private void buildOptionsPane() { JPanel p = getMainPane(); p.removeAll();//w w w. ja v a 2s.c o m JPanel leftPane = new JPanel(new MigLayout(new LC().fill(), new AC().index(1).fill().grow(), new AC().index(0).fill().grow().index(1).fill().grow())); leftPane.add(new JLabel("Please select which optional mods you would like to install."), new CC().spanX().wrap()); leftPane.add(new JLabel("Presets: "), new CC()); leftPane.add(getPresetDropdown(), new CC().grow().wrap()); leftPane.add(new JScrollPane(getModTree()), new CC().spanX().spanY().grow().wrap()); p.setLayout(new MigLayout(new LC().fill(), new AC().index(0).fill().grow().index(1).fill().grow(), new AC().fill())); p.add(leftPane, new CC().grow().width(":300:")); p.add(getModDescriptionPane(), new CC().grow().width(":300:300").wrap()); p.validate(); p.repaint(); }
From source file:dbseer.gui.panel.DBSeerLiveMonitorPanel.java
@Override public synchronized void actionPerformed(ActionEvent event) { for (int i = 0; i < transactionRenameButtons.size(); ++i) { if (event.getSource() == transactionRenameButtons.get(i)) { String newName = (String) JOptionPane.showInputDialog(this, "Enter the new name for this transaction type", "New Dataset", JOptionPane.PLAIN_MESSAGE, null, null, transactionNames.get(i)); if (newName == null || newName.trim().isEmpty()) { return; } else { newName = newName.trim(); transactionNames.set(i, newName); transactionLabels.get(i).setText(newName); DefaultTableModel model = (DefaultTableModel) monitorTable.getModel(); model.setValueAt(String.format("Current TPS of '%s' transactions", transactionNames.get(i)), 2 + (i * ROW_PER_TX_TYPE), 0); model.setValueAt(/* www .j a va 2 s . c o m*/ String.format("Current average latency of '%s' transactions", transactionNames.get(i)), 2 + (i * ROW_PER_TX_TYPE) + 1, 0); // TimeSeriesCollection collection = (TimeSeriesCollection) throughputChartPanel.getChart().getXYPlot().getDataset(); throughputCollection.getSeries(i).setKey(newName); latencyCollection.getSeries(i).setKey(newName); // if (DBSeerGUI.currentDataset != null) // { // DBSeerGUI.currentDataset.setTransactionTypeName(i, newName); // } for (DBSeerDataSet dataset : DBSeerGUI.liveDatasets) { dataset.setTransactionTypeName(i, newName); } return; } } } for (int i = 0; i < transactionViewSampleButtons.size(); ++i) { if (event.getSource() == transactionViewSampleButtons.get(i)) { final int type = i; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { DBSeerShowTransactionExampleFrame sampleFrame = new DBSeerShowTransactionExampleFrame(type); sampleFrame.pack(); sampleFrame.setLocationRelativeTo(DBSeerGUI.mainFrame); sampleFrame.setVisible(true); } }); } } for (int i = 0; i < transactionEnableDisableButtons.size(); ++i) { if (event.getSource() == transactionEnableDisableButtons.get(i)) { final XYItemRenderer throughputRenderer = throughputChartPanel.getChart().getXYPlot().getRenderer(); final XYItemRenderer latencyRenderer = latencyChartPanel.getChart().getXYPlot().getRenderer(); final int type = i; final JButton button = transactionEnableDisableButtons.get(i); final DBSeerDataSet dataset = DBSeerGUI.liveDataset; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (button.getText() == "Disable") { dataset.disableTransaction(type); throughputRenderer.setSeriesVisible(type, false); latencyRenderer.setSeriesVisible(type, false); button.setText("Enable"); } else if (button.getText() == "Enable") { dataset.enableTransaction(type); throughputRenderer.setSeriesVisible(type, true); latencyRenderer.setSeriesVisible(type, true); button.setText("Disable"); } } }); } } for (int i = 0; i < transactionDeleteButtons.size(); ++i) { if (event.getSource() == transactionDeleteButtons.get(i)) { synchronized (LiveMonitorInfo.LOCK) { try { DBSeerGUI.middlewareSocket.removeTransactionType(i); } catch (IOException e) { DBSeerExceptionHandler.handleException(e); } throughputCollection.removeSeries(i); latencyCollection.removeSeries(i); DefaultTableModel model = (DefaultTableModel) monitorTable.getModel(); int newTxSize = transactionNames.size() - 1; for (int j = 0; j < transactionNames.size(); ++j) { model.setValueAt(String.format("Current TPS of '%s' transactions", transactionNames.get(j)), 2 + (j * ROW_PER_TX_TYPE), 0); model.setValueAt(String.format("Current average latency of '%s' transactions", transactionNames.get(j)), 2 + (j * ROW_PER_TX_TYPE) + 1, 0); model.setValueAt("", 2 + (j * ROW_PER_TX_TYPE), 1); model.setValueAt("", 2 + (j * ROW_PER_TX_TYPE) + 1, 1); } model.setValueAt("", 2 + (newTxSize * ROW_PER_TX_TYPE), 0); model.setValueAt("", 2 + (newTxSize * ROW_PER_TX_TYPE), 1); model.setValueAt("", 2 + (newTxSize * ROW_PER_TX_TYPE) + 1, 0); model.setValueAt("", 2 + (newTxSize * ROW_PER_TX_TYPE) + 1, 1); final JPanel panel = transactionTypesPanel; final JLabel label = transactionLabels.remove(i); final JButton renameButton = transactionRenameButtons.remove(i); final JButton exampleButton = transactionViewSampleButtons.remove(i); final JButton deleteButton = transactionDeleteButtons.remove(i); transactionNames.remove(i); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { panel.remove(label); panel.remove(renameButton); panel.remove(exampleButton); panel.remove(deleteButton); panel.revalidate(); panel.repaint(); } }); } break; } } }
From source file:com.polivoto.vistas.Charts.java
private void crearTabla(Pregunta pregunta) { JScrollPane scrollPanel = new JScrollPane(); JPanel panel = new JPanel(new GridLayout(0, 1)); if (pregunta.obtenerCantidadDePerfiles() > 1) { for (int i = 0; i < pregunta.obtenerCantidadDePerfiles(); i++) { JPanel p = hacerTabla(pregunta, ((ResultadoPorPerfil) pregunta.obtenerResultadoPorPerfil(i)).getOpciones(), ((ResultadoPorPerfil) pregunta.obtenerResultadoPorPerfil(i)).getPerfil()); panel.add(p);/* w w w. jav a 2 s.c om*/ } } JPanel p = hacerTabla(pregunta, pregunta.obtenerOpciones(), "Todos"); panel.add(p); scrollPanel.setViewportView(panel); scrollPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); JScrollBar vertical = scrollPanel.getVerticalScrollBar(); vertical.setValue(0); vertical.setUnitIncrement(30); panelGrafica.add(scrollPanel, BorderLayout.CENTER); panel.repaint(); panel.revalidate(); panelGrafica.repaint(); panelGrafica.revalidate(); }
From source file:Classes_Home.CriarGrafico.java
public void criargrafico(JPanel jPanel3) { String pcs[] = { "'HP'", "'IBM'", "'LENOVO'", "'POSITIVO'", "'NACIONAL'" }; for (int i = 0; i <= 4; i++) { String query = "SELECT * FROM `cpu` WHERE marca = " + pcs[i]; try { st = connection.createStatement(); rs = st.executeQuery(query); if (rs.last()) { int aux = rs.getRow(); vetorParaGrafico[i] = aux; }// w w w. ja v a2 s .com } catch (Exception e) { e.printStackTrace(); } } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(vetorParaGrafico[0], "Quantidade", "HP"); dataset.setValue(vetorParaGrafico[1], "Quantidade", "IBM"); dataset.setValue(vetorParaGrafico[2], "Quantidade", "LENOVO"); dataset.setValue(vetorParaGrafico[3], "Quantidade", "POSITIVO"); dataset.setValue(vetorParaGrafico[4], "Quantidade", "NACIONAL"); JFreeChart chart = ChartFactory.createBarChart3D(null, null, "Quantidade", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); CategoryItemRenderer renderer = p.getRenderer(); renderer.setSeriesPaint(0, new Color(80, 151, 204)); p.setRangeGridlinePaint(Color.BLACK); ChartPanel panel = new ChartPanel(chart); panel.setDomainZoomable(true); panel.setVisible(true); jPanel3.setLayout(new BorderLayout()); jPanel3.add(panel, BorderLayout.CENTER); jPanel3.revalidate(); jPanel3.repaint(); System.gc(); }
From source file:au.edu.uwa.csse.plot.Clustering.java
private void setUpView(Graph graph) throws IOException { //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm final AggregateLayout<Integer, Number> layout = new AggregateLayout<Integer, Number>( new FRLayout<Integer, Number>(graph)); vv = new VisualizationViewer<Integer, Number>(layout); vv.setBackground(Color.white); vv.setVertexToolTipTransformer(Plot.vertexLabelTransformer); //Tell the renderer to use our own customized color rendering vv.getRenderContext()/* w w w.jav a 2s. c o m*/ .setVertexFillPaintTransformer(MapTransformer.<Integer, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Integer, Paint>() { public Paint transform(Integer v) { if (vv.getPickedVertexState().isPicked(v)) { return Color.cyan; } else { return Color.BLACK; } } }); vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() { protected final Stroke THIN = new BasicStroke(1); protected final Stroke THICK = new BasicStroke(2); public Stroke transform(Number e) { Paint c = edgePaints.get(e); if (c == Color.LIGHT_GRAY) return THIN; else return THICK; } }); //add restart button JButton scramble = new JButton("Restart"); scramble.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Layout layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); final JToggleButton groupVertices = new JToggleButton("Group Clusters"); //Create slider to adjust the number of edges to remove when clustering final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL); edgeBetweennessSlider.setBackground(Color.WHITE); edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(graph.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); edgeBetweennessSlider.setMajorTickSpacing(10); edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black)); //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):")); //I also want the slider value to appear final JPanel eastControls = new JPanel(); eastControls.setOpaque(true); eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS)); eastControls.add(Box.createVerticalGlue()); eastControls.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); eastControls.setBorder(sliderBorder); //eastControls.add(eastSize); eastControls.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); edgeBetweennessSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int numEdgesToRemove = source.getValue(); clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected()); sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue()); eastControls.repaint(); vv.validate(); vv.repaint(); } } }); Container content = getContentPane(); content.add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); grid.add(scramble); grid.add(groupVertices); south.add(grid); south.add(eastControls); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); content.add(south, BorderLayout.SOUTH); }