List of usage examples for javax.swing JPanel add
public Component add(String name, Component comp)
From source file:Main.java
/** * Displays a message dialog with given information. *///from w w w .j a v a 2s . co m public static void showInformationDialog(Component component, String message) { final JPanel panel = new JPanel(new BorderLayout(5, 5)); final JLabel messageLabel = new JLabel(message); messageLabel.setFont(new Font("Dialog", Font.BOLD, messageLabel.getFont().getSize())); panel.add(messageLabel, BorderLayout.CENTER); // Adjust stack trace dimensions final Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); screenDimension.setSize(screenDimension.getWidth() * 0.7, screenDimension.getHeight() * 0.7); final Dimension maxStackTraceDimension = new Dimension(500, 500); maxStackTraceDimension.setSize(Math.min(maxStackTraceDimension.getWidth(), screenDimension.getWidth()), Math.min(maxStackTraceDimension.getHeight(), screenDimension.getHeight())); JOptionPane.showMessageDialog(component, panel, "Information", JOptionPane.INFORMATION_MESSAGE); }
From source file:eu.cassandra.csn.gui.Stats.java
/** * /*w w w . j a v a 2 s . c om*/ * @param frame */ public static JPanel setNetworkStats(JFrame frame) { String[][] data = new String[][] { { "Virtual Days:", "" }, { "Number of nodes:", "" }, { "Number of edges:", "" }, { "Graph diameter:", "" }, { "Vertex Betweenness Centrality:", "" }, { "Edge Betweenness Centrality:", "" }, { "Total consumption:", "" }, { "Average consumption:", "" }, { "Peak consumption:", "" }, { "Unconnected vertices:", "" }, { "Clusters:", "" } }; String[] columnName = new String[] { "Metric", "Value" }; tableModel = new MyDefaultTableModel(data, columnName); JTable table = new JTable(tableModel); JScrollPane scrollPane = new JScrollPane(table); table.setFillsViewportHeight(true); String[][] dataSelected = new String[5][]; String[] columnNameSelected = new String[] { "Name", "Type", "Total Consumption", "Peak Comsumption", "Avg Consumption" }; tableModelSelected = new MyDefaultTableModel(dataSelected, columnNameSelected); JTable tableSelected = new JTable(tableModelSelected); JScrollPane scrollPaneSelected = new JScrollPane(tableSelected); tableSelected.setFillsViewportHeight(true); tableSelected.setPreferredSize(new Dimension(1600, 100)); scrollPaneSelected.setPreferredSize(new Dimension(1600, 100)); JPanel statsPanel = new JPanel(new BorderLayout()); statsPanel.add(scrollPane, BorderLayout.CENTER); chartPanel = Charts.createGraph("Power Consumption", "Hours", "Power (W)", new Double[0]); statsPanel.add(chartPanel, BorderLayout.PAGE_END); //frame.add(statsPanel,BorderLayout.EAST); frame.add(scrollPaneSelected, BorderLayout.PAGE_END); return statsPanel; }
From source file:com.surenpi.autotest.suite.SuiteRunnerLauncher.java
/** * @param centerPanel//w ww .j a v a 2 s. c om */ private static void createButPanel(JPanel centerPanel) { JPanel butPanel = new JPanel(); centerPanel.add(butPanel, BorderLayout.SOUTH); JButton execBut = new JButton("Exec"); butPanel.add(execBut); execBut.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // runFromList(); } }); }
From source file:EdgeLayoutExample.java
public static JPanel createPanel() { JPanel outerPanel = new JPanel(); outerPanel.setLayout(new EdgeLayout()); outerPanel.add(new JButton("West1"), EdgeLayout.WEST); outerPanel.add(new JButton("North1"), EdgeLayout.NORTH); outerPanel.add(new JButton("West2"), EdgeLayout.WEST); outerPanel.add(new JButton("North2"), EdgeLayout.NORTH); outerPanel.add(new JButton("East1"), EdgeLayout.EAST); outerPanel.add(new JButton("South1"), EdgeLayout.SOUTH); outerPanel.add(new JButton("West3"), EdgeLayout.WEST); outerPanel.add(new JButton("West4"), EdgeLayout.WEST); outerPanel.add(new JButton("South2"), EdgeLayout.SOUTH); outerPanel.add(new JButton("South3"), EdgeLayout.SOUTH); outerPanel.add(new JButton("Center1"), EdgeLayout.CENTER); return outerPanel; }
From source file:Main.java
/** * Sets up the given window content pane by setting its border to provide a * good default spacer, and setting the content pane to the given components. * //from w ww . j a v a2s.c o m * @param aWindow * the window to setup, cannot be <code>null</code>; * @param aCenterComponent * the component that should appear at the center of the dialog; * @param aButtonPane * the component that should appear at the bottom of the dialog * @param defaultButton * the default button for this dialog; can be null for "none". * @see javax.swing.JRootPane#setDefaultButton(javax.swing.JButton) */ public static void setupWindowContentPane(final Window aWindow, final Component aCenterComponent, final Component aButtonPane, final JButton defaultButton) { final JPanel contentPane = new JPanel(new BorderLayout()); contentPane.setBorder(BorderFactory.createEmptyBorder(DIALOG_PADDING, DIALOG_PADDING, // DIALOG_PADDING, DIALOG_PADDING)); contentPane.add(aCenterComponent, BorderLayout.CENTER); contentPane.add(aButtonPane, BorderLayout.PAGE_END); if (aWindow instanceof JDialog) { ((JDialog) aWindow).setContentPane(contentPane); ((JDialog) aWindow).getRootPane().setDefaultButton(defaultButton); } else if (aWindow instanceof JFrame) { ((JFrame) aWindow).setContentPane(contentPane); ((JFrame) aWindow).getRootPane().setDefaultButton(defaultButton); } aWindow.pack(); }
From source file:com.intuit.tank.tools.debugger.PanelBuilder.java
static Component createRightPanel(final AgentDebuggerFrame frame) { JPanel ret = new JPanel(new BorderLayout()); ret.add(BorderLayout.NORTH, new InfoHeaderPanel(frame)); JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true); pane.setTopComponent(new VariablesPanel(frame)); pane.setBottomComponent(frame.getRequestResponsePanel()); pane.setDividerLocation(250);//from w w w . j a va2 s .co m pane.setResizeWeight(0.25D); ret.add(BorderLayout.CENTER, pane); return ret; }
From source file:Main.java
public static JPanel createTextComponentPane(String labelText, JTextComponent textComp, Font font, Color bgColor, boolean isVertical) { JPanel outPane = new JPanel(); outPane.setLayout(new BorderLayout()); outPane.setBorder(new EmptyBorder(5, 5, 5, 5)); JLabel labelOut = new JLabel(labelText, SwingConstants.LEFT); if (isVertical) { outPane.add(labelOut, BorderLayout.NORTH); } else {// w w w.j a va2 s .c o m outPane.add(labelOut, BorderLayout.WEST); } if (textComp instanceof JTextArea) { outPane.add(createScrollPane((JTextArea) textComp, font, bgColor), BorderLayout.CENTER); } else { textComp.setBackground(bgColor); textComp.setFont(font); outPane.add(textComp, BorderLayout.CENTER); } return outPane; }
From source file:com.surenpi.autotest.suite.SuiteRunnerLauncher.java
/** * @param centerPanel/* w w w.jav a 2 s.c o m*/ * @param urlList */ private static void createItemsPanel(JPanel centerPanel, List<URL> urlList) { JPanel itemsPanel = new JPanel(); centerPanel.add(itemsPanel, BorderLayout.CENTER); if (CollectionUtils.isEmpty(urlList)) { return; } for (URL url : urlList) { String text = url.getFile(); JCheckBox box = new JCheckBox(new File(text).getName()); box.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCheckBox source = (JCheckBox) e.getSource(); if (source.isSelected()) { runnerList.add(source.getText()); } else { runnerList.remove(source.getText()); } } }); itemsPanel.add(box); } }
From source file:pt.lsts.neptus.util.bathymetry.TidCachedData.java
public static void test(String[] args) throws Exception { TidReader.main(args);//from w w w .j a v a 2s. co m JFreeChart timeSeriesChart = null; TimeSeriesCollection tsc = new TimeSeriesCollection(); ValueMarker marker = new ValueMarker(System.currentTimeMillis()); ValueMarker levelMarker = new ValueMarker(0); String tmpFolder = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator", "/"); File tidFx = new File(tmpFolder + "tmp.tid"); TidCachedData tide = new TidCachedData(tidFx); TimeSeries ts = new TimeSeries(I18n.text("Tide level")); tsc.addSeries(ts); Date sDate = new GregorianCalendar(1993, 9, 28).getTime(); for (double i = -12; i < 12; i += 0.25) { Date d = new Date((long) (sDate.getTime() + (i * 6.45 * 1E3 * 60 * 60))); ts.addOrUpdate(new Millisecond(d), tide.getTidePrediction(d, false)); } JPanel panel = new JPanel(new BorderLayout()); timeSeriesChart = ChartFactory.createTimeSeriesChart(null, null, null, tsc, true, true, true); panel.add(new ChartPanel(timeSeriesChart), BorderLayout.CENTER); timeSeriesChart.getXYPlot().addDomainMarker(marker); levelMarker.setValue(TidePredictionFactory.getTideLevel(new Date())); timeSeriesChart.getXYPlot().addRangeMarker(levelMarker); GuiUtils.testFrame(panel); System.out.println("\n________________________________________"); long start = System.currentTimeMillis(); TidCachedData tcd = new TidCachedData(new File(ConfigFetch.getConfFolder() + "mra/Leixoes.tid")); System.out.println("Loading of " + tcd.getName() + " took " + MathMiscUtils.parseToEngineeringNotation((System.currentTimeMillis() - start) / 1E3, 2) + "s"); }
From source file:Main.java
public static JPanel createKV(final Component key, final Component value, final int keyWidth, final boolean fill) { initComponentHeight(key, value);/*from ww w . j a v a2 s . c o m*/ if (keyWidth > 0) { key.setPreferredSize(new Dimension(keyWidth, key.getPreferredSize().height)); } final JPanel jp = new JPanel(new GridBagLayout()); final GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.gridx = 0; gbc.gridy = 0; gbc.insets = new Insets(0, 0, 0, 4); jp.add(key, gbc); gbc.gridx = 1; gbc.insets = new Insets(0, 0, 0, 0); gbc.weightx = 1.0; if (fill) { gbc.fill = GridBagConstraints.HORIZONTAL; } jp.add(value, gbc); return jp; }