List of usage examples for javax.swing JPanel validate
public void validate()
From source file:udpserver.UDPui.java
/** * Creates new form UDPui/*from w ww. j a v a2 s .c o m*/ */ public UDPui() { // <editor-fold defaultstate="collapsed" desc="Graph"> series = new XYSeries("ECG Reading"); series.setMaximumItemCount(50); XYSeriesCollection dataset = new XYSeriesCollection(series); JFreeChart chart = ChartFactory.createXYLineChart("ECG Reading", "Time (seconds)", "Voltage (volt)", dataset); final XYPlot plot = chart.getXYPlot(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); JPanel jPanel1 = new JPanel(); jPanel1.setLayout(new java.awt.BorderLayout()); jPanel1.setVisible(true); jPanel1.setSize(600, 500); jPanel1.add(new ChartPanel(chart), BorderLayout.CENTER); jPanel1.validate(); add(jPanel1); // </editor-fold> initComponents(); receiveUDP(); // tempReceiveUDP(); // new UDPServer(valuePane); }
From source file:jgnash.ui.report.compiled.RunningAccountBalanceChart.java
private JPanel createPanel() { LocalDate end = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()); LocalDate start = end.minusYears(1); startDateField.setDate(start);/*from w w w.ja v a2 s.c om*/ JButton refreshButton = new JButton(rb.getString("Button.Refresh")); refreshButton.setIcon(IconUtils.getIcon("/jgnash/resource/view-refresh.png")); subAccountCheckBox = new JCheckBox(rb.getString("Button.IncludeSubAccounts")); subAccountCheckBox.setSelected(true); hideLockedAccountCheckBox = new JCheckBox(rb.getString("Button.HideLockedAccount")); hidePlaceholderAccountCheckBox = new JCheckBox(rb.getString("Button.HidePlaceholderAccount")); JFreeChart chart = createVerticalXYBarChart(combo.getSelectedAccount()); final ChartPanel chartPanel = new ChartPanel(chart); FormLayout layout = new FormLayout("p, 4dlu, p:g", ""); DefaultFormBuilder builder = new DefaultFormBuilder(layout); FormLayout dLayout = new FormLayout("p, 4dlu, p, 8dlu, p, 4dlu, p, 8dlu, p", ""); DefaultFormBuilder dBuilder = new DefaultFormBuilder(dLayout); dBuilder.append(rb.getString("Label.StartDate"), startDateField); dBuilder.append(rb.getString("Label.EndDate"), endDateField); dBuilder.append(refreshButton); FormLayout cbLayout = new FormLayout("p, 4dlu, p, 4dlu, p, 4dlu", ""); DefaultFormBuilder cbBuilder = new DefaultFormBuilder(cbLayout); cbBuilder.append(subAccountCheckBox); cbBuilder.append(hideLockedAccountCheckBox); cbBuilder.append(hidePlaceholderAccountCheckBox); builder.append(rb.getString("Label.Account"), combo); builder.nextLine(); builder.append(" "); builder.append(cbBuilder.getPanel()); builder.nextLine(); builder.appendRelatedComponentsGapRow(); builder.nextLine(); builder.append(dBuilder.getPanel(), 3); builder.nextLine(); builder.appendUnrelatedComponentsGapRow(); builder.nextLine(); builder.appendRow(RowSpec.decode("fill:p:g")); builder.append(chartPanel, 3); final JPanel panel = builder.getPanel(); ActionListener listener = e -> { updateSubAccountBox(); Account a = combo.getSelectedAccount(); if (a == null) { return; } chartPanel.setChart(createVerticalXYBarChart(a)); panel.validate(); }; hideLockedAccountCheckBox.addActionListener(e -> { combo.setHideLocked(hideLockedAccountCheckBox.isSelected()); updateSubAccountBox(); Account a = combo.getSelectedAccount(); if (a == null) { return; } chartPanel.setChart(createVerticalXYBarChart(a)); panel.validate(); }); hidePlaceholderAccountCheckBox.addActionListener(e -> { combo.setHidePlaceholder(hidePlaceholderAccountCheckBox.isSelected()); updateSubAccountBox(); Account a = combo.getSelectedAccount(); if (a == null) { return; } chartPanel.setChart(createVerticalXYBarChart(a)); panel.validate(); }); updateSubAccountBox(); combo.addActionListener(listener); refreshButton.addActionListener(listener); return panel; }
From source file:jgnash.ui.report.compiled.MonthlyAccountBalanceChart.java
private JPanel createPanel() { LocalDate end = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()); LocalDate start = end.minusYears(1); startDateField.setDate(start);//www . j a v a 2s . c om JButton refreshButton = new JButton(rb.getString("Button.Refresh")); refreshButton.setIcon(IconUtils.getIcon("/jgnash/resource/view-refresh.png")); subAccountCheckBox = new JCheckBox(rb.getString("Button.IncludeSubAccounts")); subAccountCheckBox.setSelected(true); hideLockedAccountCheckBox = new JCheckBox(rb.getString("Button.HideLockedAccount")); hidePlaceholderAccountCheckBox = new JCheckBox(rb.getString("Button.HidePlaceholderAccount")); Account a = combo.getSelectedAccount(); JFreeChart chart = createVerticalXYBarChart(a); final ChartPanel chartPanel = new ChartPanel(chart); FormLayout layout = new FormLayout("p, 4dlu, p:g", ""); DefaultFormBuilder builder = new DefaultFormBuilder(layout); FormLayout dLayout = new FormLayout("p, 4dlu, p, 8dlu, p, 4dlu, p, 8dlu, p", ""); DefaultFormBuilder dBuilder = new DefaultFormBuilder(dLayout); dBuilder.append(rb.getString("Label.StartDate"), startDateField); dBuilder.append(rb.getString("Label.EndDate"), endDateField); dBuilder.append(refreshButton); FormLayout cbLayout = new FormLayout("p, 4dlu, p, 4dlu, p, 4dlu", ""); DefaultFormBuilder cbBuilder = new DefaultFormBuilder(cbLayout); cbBuilder.append(subAccountCheckBox); cbBuilder.append(hideLockedAccountCheckBox); cbBuilder.append(hidePlaceholderAccountCheckBox); builder.append(rb.getString("Label.Account"), combo); builder.nextLine(); builder.append(" "); builder.append(cbBuilder.getPanel()); builder.nextLine(); builder.appendRelatedComponentsGapRow(); builder.nextLine(); builder.append(dBuilder.getPanel(), 3); builder.nextLine(); builder.appendUnrelatedComponentsGapRow(); builder.nextLine(); builder.appendRow(RowSpec.decode("fill:p:g")); builder.append(chartPanel, 3); final JPanel panel = builder.getPanel(); ActionListener listener = e -> { try { Account account = combo.getSelectedAccount(); if (account == null) { return; } updateSubAccountBox(); chartPanel.setChart(createVerticalXYBarChart(account)); panel.validate(); } catch (final Exception ex) { Logger.getLogger(MonthlyAccountBalanceChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }; combo.addActionListener(listener); hideLockedAccountCheckBox.addActionListener(e -> { combo.setHideLocked(hideLockedAccountCheckBox.isSelected()); try { Account account = combo.getSelectedAccount(); if (account == null) { return; } updateSubAccountBox(); chartPanel.setChart(createVerticalXYBarChart(account)); panel.validate(); } catch (final Exception ex) { Logger.getLogger(MonthlyAccountBalanceChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }); hidePlaceholderAccountCheckBox.addActionListener(e -> { combo.setHidePlaceholder(hidePlaceholderAccountCheckBox.isSelected()); try { Account account = combo.getSelectedAccount(); if (account == null) { return; } updateSubAccountBox(); chartPanel.setChart(createVerticalXYBarChart(account)); panel.validate(); } catch (final Exception ex) { Logger.getLogger(MonthlyAccountBalanceChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }); refreshButton.addActionListener(listener); updateSubAccountBox(); return panel; }
From source file:ec.nbdemetra.ui.demo.ComponentsDemo.java
public ComponentsDemo() { initStaticResources();//from www .ja va 2 s .co 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:com.anrisoftware.prefdialog.simpledialog.SimpleDialog.java
private void removeRestoreButton() { JPanel buttonsPanel = dialogPanel.getButtonsPanel(); JButton restoreButton = getRestoreButton(); buttonsPanel.remove(restoreButton);//from ww w. j a va2s. com buttonsPanel.remove(dialogPanel.getRestoreStrut()); restoreButton.setVisible(false); buttonsPanel.validate(); }
From source file:com.anrisoftware.prefdialog.simpledialog.SimpleDialog.java
private void removeApproveButton() { JPanel buttonsPanel = dialogPanel.getButtonsPanel(); JButton approveButton = getApproveButton(); buttonsPanel.remove(approveButton);// w ww. ja v a 2 s . c o m buttonsPanel.remove(dialogPanel.getApproveStrut()); approveButton.setVisible(false); buttonsPanel.validate(); }
From source file:jgnash.ui.report.compiled.MonthlyAccountBalanceChartCompare.java
private JPanel createPanel() { LocalDate end = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()); LocalDate start = end.minusYears(1); startDateField.setDate(start);/* ww w. ja v a 2 s . c om*/ JButton refreshButton = new JButton(rb.getString("Button.Refresh")); refreshButton.setIcon(IconUtils.getIcon("/jgnash/resource/view-refresh.png")); subAccountCheckBox = new JCheckBox(rb.getString("Button.IncludeSubAccounts")); subAccountCheckBox.setSelected(true); hideLockedAccountCheckBox = new JCheckBox(rb.getString("Button.HideLockedAccount")); hidePlaceholderAccountCheckBox = new JCheckBox(rb.getString("Button.HidePlaceholderAccount")); jcb_compare = new JCheckBox(rb.getString("Button.Compare")); jcb_compare.setSelected(true); Account a = combo1.getSelectedAccount(); Account a2 = combo2.getSelectedAccount(); JFreeChart chart = createVerticalXYBarChart(a, a2); final ChartPanel chartPanel = new ChartPanel(chart); FormLayout layout = new FormLayout("p, 4dlu, p:g", ""); DefaultFormBuilder builder = new DefaultFormBuilder(layout); FormLayout dLayout = new FormLayout("p, 4dlu, p, 8dlu, p, 4dlu, p, 8dlu, p", ""); DefaultFormBuilder dBuilder = new DefaultFormBuilder(dLayout); dBuilder.append(rb.getString("Label.StartDate"), startDateField); dBuilder.append(rb.getString("Label.EndDate"), endDateField); dBuilder.append(refreshButton); FormLayout cbLayout = new FormLayout("p, 4dlu, p, 4dlu, p, 4dlu", ""); DefaultFormBuilder cbBuilder = new DefaultFormBuilder(cbLayout); cbBuilder.append(subAccountCheckBox); cbBuilder.append(hideLockedAccountCheckBox); cbBuilder.append(hidePlaceholderAccountCheckBox); builder.append(rb.getString("Label.Account"), combo1); builder.nextLine(); builder.append(rb.getString("Label.Compare"), combo2); builder.nextLine(); builder.append(jcb_compare); builder.append(cbBuilder.getPanel()); builder.nextLine(); builder.appendRelatedComponentsGapRow(); builder.nextLine(); builder.append(dBuilder.getPanel(), 3); builder.nextLine(); builder.appendUnrelatedComponentsGapRow(); builder.nextLine(); builder.appendRow(RowSpec.decode("fill:p:g")); builder.append(chartPanel, 3); final JPanel panel = builder.getPanel(); ActionListener listener = e -> { try { if (e.getSource() == jcb_compare) { combo2.setEnabled(jcb_compare.isSelected()); } Account account = combo1.getSelectedAccount(); if (account == null) { return; } Account account2 = combo2.getSelectedAccount(); if (jcb_compare.isSelected() && account2 == null) { return; } updateSubAccountBox(); chartPanel.setChart(createVerticalXYBarChart(account, account2)); panel.validate(); } catch (final Exception ex) { Logger.getLogger(MonthlyAccountBalanceChartCompare.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }; combo1.addActionListener(listener); combo2.addActionListener(listener); jcb_compare.addActionListener(listener); subAccountCheckBox.addActionListener(listener); hideLockedAccountCheckBox.addActionListener(e -> { combo1.setHideLocked(hideLockedAccountCheckBox.isSelected()); combo2.setHideLocked(hideLockedAccountCheckBox.isSelected()); try { Account account = combo1.getSelectedAccount(); if (account == null) { return; } Account account2 = combo2.getSelectedAccount(); if (jcb_compare.isSelected() && account2 == null) { return; } updateSubAccountBox(); chartPanel.setChart(createVerticalXYBarChart(account, account2)); panel.validate(); } catch (final Exception ex) { Logger.getLogger(MonthlyAccountBalanceChartCompare.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }); hidePlaceholderAccountCheckBox.addActionListener(e -> { combo1.setHidePlaceholder(hidePlaceholderAccountCheckBox.isSelected()); combo2.setHidePlaceholder(hidePlaceholderAccountCheckBox.isSelected()); try { Account account = combo1.getSelectedAccount(); if (account == null) { return; } Account account2 = combo2.getSelectedAccount(); if (jcb_compare.isSelected() && account2 == null) { return; } updateSubAccountBox(); chartPanel.setChart(createVerticalXYBarChart(account, account2)); panel.validate(); } catch (final Exception ex) { Logger.getLogger(MonthlyAccountBalanceChartCompare.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }); refreshButton.addActionListener(listener); updateSubAccountBox(); return panel; }
From source file:com.anrisoftware.prefdialog.simpledialog.SimpleDialog.java
private void readdRestoreButton() { JButton cancelButton = getCancelButton(); JButton restoreButton = getRestoreButton(); JPanel buttonsPanel = dialogPanel.getButtonsPanel(); restoreAction.setDialog(this); restoreAction.setTexts(texts);/* w ww. java 2 s. c om*/ restoreButton.setVisible(true); restoreButton.setAction(restoreAction); buttonsPanel.remove(cancelButton); buttonsPanel.add(restoreButton); buttonsPanel.add(dialogPanel.getRestoreStrut()); buttonsPanel.add(cancelButton); buttonsPanel.validate(); }
From source file:com.anrisoftware.prefdialog.simpledialog.SimpleDialog.java
private void readdApproveButton() { JButton cancelButton = getCancelButton(); JButton approveButton = getApproveButton(); JPanel buttonsPanel = dialogPanel.getButtonsPanel(); approveAction.setDialog(this); approveAction.setTexts(texts);//from w ww . j a v a2s. co m approveButton.setVisible(true); approveButton.setAction(approveAction); buttonsPanel.remove(cancelButton); buttonsPanel.add(approveButton); buttonsPanel.add(dialogPanel.getApproveStrut()); buttonsPanel.add(cancelButton); buttonsPanel.validate(); }
From source file:FindHullWindowLogic.java
static void drawPointsOnChart(JPanel panelWhenInside, ArrayList<Point2D> convexHull) { panelWhenInside.removeAll();/*from w w w.java2 s . c o m*/ panelWhenInside.setLayout(new java.awt.BorderLayout()); XYSeries seriersAllPoints = new XYSeries("All points"); addPointsToSeries(seriersAllPoints); int pairsNumber = 0; if (convexHull != null) pairsNumber = convexHull.size() - 1; XYSeries covnexHullDivideOnPiars[] = new XYSeries[pairsNumber]; for (int i = 0; i < covnexHullDivideOnPiars.length; i++) { covnexHullDivideOnPiars[i] = new XYSeries("Convex hull pair " + i); } if (convexHull != null) { divideOnPairsAndConvertConvexHullIntoSeries(covnexHullDivideOnPiars, convexHull); } // Add the seriersAllPoints to your data set XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(seriersAllPoints); for (int i = 0; i < covnexHullDivideOnPiars.length; i++) { dataset.addSeries(covnexHullDivideOnPiars[i]); } // Generate the graph JFreeChart chart = ChartFactory.createXYLineChart(null, // Title null, // x-axis Label null, // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation false, // Show Legend false, // Use tooltips false // Configure chart to generate URLs? ); final XYPlot plot = chart.getXYPlot(); ChartPanel chartPanel = new ChartPanel(chart); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.BLACK); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShape(0, ShapeUtilities.createDiamond(3)); for (int i = 1; i <= covnexHullDivideOnPiars.length; i++) { renderer.setSeriesPaint(i, Color.red); renderer.setSeriesLinesVisible(i, true); renderer.setSeriesStroke(i, new BasicStroke(1.0f)); } plot.setRenderer(renderer); panelWhenInside.add(chartPanel, BorderLayout.CENTER); panelWhenInside.validate(); }