List of usage examples for javax.swing JPanel setBorder
@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.") public void setBorder(Border border)
From source file:ColorApp.java
public ColorApp() { super();/*from ww w. ja va2 s . c om*/ Container container = getContentPane(); displayPanel = new DisplayPanel(); container.add(displayPanel); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(3, 2)); panel.setBorder(new TitledBorder("Click a Button to Perform the Associated Operation and Reset...")); brightenButton = new JButton("Brightness >>"); brightenButton.addActionListener(new ButtonListener()); darkenButton = new JButton("Darkness >>"); darkenButton.addActionListener(new ButtonListener()); contrastIncButton = new JButton("Contrast >>"); contrastIncButton.addActionListener(new ButtonListener()); contrastDecButton = new JButton("Contrast <<"); contrastDecButton.addActionListener(new ButtonListener()); reverseButton = new JButton("Negative"); reverseButton.addActionListener(new ButtonListener()); resetButton = new JButton("Reset"); resetButton.addActionListener(new ButtonListener()); panel.add(brightenButton); panel.add(darkenButton); panel.add(contrastIncButton); panel.add(contrastDecButton); panel.add(reverseButton); panel.add(resetButton); container.add(BorderLayout.SOUTH, panel); addWindowListener(new WindowEventHandler()); setSize(displayPanel.getWidth(), displayPanel.getHeight() + 25); show(); }
From source file:dk.dma.epd.shore.gui.notification.StrategicRouteNotificationDetailPanel.java
/** * {@inheritDoc}/*from w w w . j a v a 2s . co m*/ */ @Override protected JPanel createInfoPanel() { // Initialize member variables here, since this method // is called by super's constructor mmsiTxt = new JLabel(" "); nameTxt = new JLabel(" "); callSignTxt = new JLabel(" "); destinationTxt = new JLabel(" "); sogTxt = new JLabel(" "); typeTxt = new JLabel(" "); lengthTxt = new JLabel(" "); widthTxt = new JLabel(" "); draughtTxt = new JLabel(" "); cogTxt = new JLabel(" "); String[] infoTitles = { "MMSI:", "Name:", "Call Sign:", "Destination:", "SOG:", "Type:", "Lenght:", "Width:", "Draught:", "COG:" }; infoLabels = new JLabel[] { mmsiTxt, nameTxt, callSignTxt, destinationTxt, sogTxt, typeTxt, lengthTxt, widthTxt, draughtTxt, cogTxt }; int[] infoCols = { 5, 5 }; JPanel infoPanel = new JPanel(new GridBagLayout()); Insets insets2 = new Insets(2, 5, 2, 5); infoPanel.setBorder(BorderFactory.createTitledBorder("Ship Info")); for (int col = 0, index = 0; col < infoCols.length; col++) { for (int row = 0; row < infoCols[col]; row++, index++) { infoPanel.add(bold(new JLabel(infoTitles[index])), new GridBagConstraints(col * 2, row, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0)); infoPanel.add(minSize(infoLabels[index], 40), new GridBagConstraints(col * 2 + 1, row, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets2, 0, 0)); } } return infoPanel; }
From source file:uk.co.petertribble.solview.explorer.CpuInfoPanel.java
private void addAccessory() { Kstat ks = hi.getKstat();//from ww w .j a v a 2 s. c o m if (ks != null) { Kstat ksc = proctree.makeCpuKstat(ks); kap = new AccessoryCpuPanel(ksc, 1, jkstat); JPanel jp = new JPanel(new BorderLayout()); jp.add(kap); jp.setBorder(BorderFactory.createTitledBorder("CPU activity")); jvp.add(jp); kbc = new KstatAreaChart(jkstat, ksc, mystats, true); kbc.setColors(mycolors); jvp.add(new ChartPanel(kbc.getChart())); } }
From source file:org.cytoscape.dyn.internal.graphMetrics.SaveChartDialog.java
public SaveChartDialog(JFrame frame, JFreeChart chart) { super(frame, "Save Chart to File", false); this.chart = chart; JPanel sizePanel = new JPanel(new GridLayout(2, 3, 4, 4)); sizePanel.setBorder(BorderFactory.createTitledBorder("Image Size")); // Add a spinner for choosing width sizePanel.add(new JLabel("Width:", SwingConstants.RIGHT)); int width = ChartPanel.DEFAULT_WIDTH; int minWidth = ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH; int maxWidth = ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH; SpinnerModel widthSettings = new SpinnerNumberModel(width, minWidth, maxWidth, 1); sizePanel.add(widthSpinner = new JSpinner(widthSettings)); sizePanel.add(new JLabel("pixels")); // Add a spinner for choosing height sizePanel.add(new JLabel("Height:", SwingConstants.RIGHT)); int height = ChartPanel.DEFAULT_HEIGHT; int minHeight = ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT; int maxHeight = ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT; SpinnerModel heightSettings = new SpinnerNumberModel(height, minHeight, maxHeight, 1); sizePanel.add(heightSpinner = new JSpinner(heightSettings)); sizePanel.add(new JLabel("pixels")); JPanel buttonsPanel = new JPanel(new GridLayout(1, 2, 4, 0)); saveChartButton = new JButton("Save"); saveChartButton.setMaximumSize(new Dimension(Short.MAX_VALUE, saveChartButton.getHeight())); saveChartButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.setMaximumSize(new Dimension(Short.MAX_VALUE, cancelButton.getHeight())); cancelButton.addActionListener(this); buttonsPanel.add(saveChartButton);// w w w . ja v a 2 s . c om buttonsPanel.add(cancelButton); Box buttonsBox = Box.createHorizontalBox(); buttonsBox.add(Box.createHorizontalGlue()); buttonsBox.add(buttonsPanel); buttonsBox.add(Box.createHorizontalGlue()); Container contentPane = getContentPane(); contentPane.add(sizePanel, BorderLayout.NORTH); contentPane.add(Box.createVerticalStrut(3)); contentPane.add(buttonsBox, BorderLayout.PAGE_END); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getRootPane().setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); pack(); setModal(true); setResizable(false); setLocationRelativeTo(frame); }
From source file:com.opendoorlogistics.components.reports.ReporterPanel.java
public ReporterPanel(final ComponentConfigurationEditorAPI api, final ReporterConfig config) { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // setAlignmentX(LEFT_ALIGNMENT); // add config panel ReporterConfigPanel configPanel = new ReporterConfigPanel(config); configPanel.setBorder(createBorder("Export and processing options")); add(configPanel);//from w ww . j a v a2s .c o m // add gap add(Box.createRigidArea(new Dimension(1, 10))); // add tools panel JPanel toolContainer = new JPanel(); toolContainer.setLayout(new BorderLayout()); toolContainer.setBorder(createBorder("Tools")); add(toolContainer); JPanel tools = new JPanel(); toolContainer.add(tools, BorderLayout.NORTH); toolContainer.setMaximumSize(new Dimension(Integer.MAX_VALUE, api.isInstruction() ? 120 : 80)); // tools.setLayout(new BoxLayout(tools, BoxLayout.X_AXIS)); tools.setLayout(new GridLayout(api == null || api.isInstruction() ? 2 : 1, 3)); JButton compileButton = new JButton("Compile .jrxml file"); compileButton.setToolTipText("Compile a JasperReports .jrxml file"); compileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { File file = ReporterTools.chooseJRXMLFile(api.getComponentPreferences(), LAST_JRXML_TO_COMPILE, ReporterPanel.this); if (file == null) { return; } final ExecutionReport report = api.getApi().uiFactory().createExecutionReport(); try { JasperDesign design = JRXmlLoader.load(file); if (design == null) { throw new RuntimeException("File to load jrxml: " + file.getAbsolutePath()); } String filename = FilenameUtils.removeExtension(file.getAbsolutePath()) + ".jasper"; JasperCompileManager.compileReportToFile(design, filename); } catch (Throwable e2) { report.setFailed(e2); report.setFailed("Failed to compile file " + file.getAbsolutePath()); } finally { if (report.isFailed()) { Window window = SwingUtilities.getWindowAncestor(ReporterPanel.this); api.getApi().uiFactory() .createExecutionReportDialog( JFrame.class.isInstance(window) ? (JFrame) window : null, "Compiling jrxml file", report, true) .setVisible(true); } else { JOptionPane.showMessageDialog(ReporterPanel.this, "Compiled jxrml successfully: " + file.getAbsolutePath()); } } } }); tools.add(compileButton); for (final OrientationEnum orientation : new OrientationEnum[] { OrientationEnum.LANDSCAPE, OrientationEnum.PORTRAIT }) { // create export button JButton button = new JButton("Export " + orientation.getName().toLowerCase() + " template"); button.setToolTipText( "Export template (editable .jrxml and compiled .jasper) based on the input tables (" + orientation.getName().toLowerCase() + ")"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ReporterTools.exportReportTemplate(api, config, orientation, ReporterPanel.this); } }); tools.add(button); // create view button if (api.isInstruction()) { final String title = "View basic " + orientation.getName().toLowerCase() + " report"; button = new JButton(title); button.setToolTipText("View basic report based on the input tables (" + orientation.getName().toLowerCase() + ")"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (api != null) { api.executeInPlace(title, orientation == OrientationEnum.LANDSCAPE ? ReporterComponent.VIEW_BASIC_LANDSCAPE : ReporterComponent.VIEW_BASIC_PORTRAIT); } } }); tools.add(button); } } }
From source file:ShowDocument.java
public URLWindow(AppletContext appletContext) { super("Show a Document!"); this.appletContext = appletContext; JPanel contentPane = new JPanel(new GridBagLayout()); setContentPane(contentPane);/*from w w w. ja va 2 s . c o m*/ contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; JLabel label1 = new JLabel("URL of document to show: ", JLabel.TRAILING); add(label1, c); urlField = new JTextField("http://java.sun.com/", 20); label1.setLabelFor(urlField); urlField.addActionListener(this); c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; add(urlField, c); JLabel label2 = new JLabel("Window/frame to show it in: ", JLabel.TRAILING); c.gridwidth = 1; c.weightx = 0.0; add(label2, c); String[] strings = { "(browser's choice)", //don't specify "My Personal Window", //a window named "My Personal Window" "_blank", //a new, unnamed window "_self", "_parent", "_top" //the Frame that contained this applet }; choice = new JComboBox(strings); label2.setLabelFor(choice); c.fill = GridBagConstraints.NONE; c.gridwidth = GridBagConstraints.REMAINDER; c.insets = new Insets(5, 0, 0, 0); c.anchor = GridBagConstraints.LINE_START; add(choice, c); JButton button = new JButton("Show document"); button.addActionListener(this); c.weighty = 1.0; c.ipadx = 10; c.ipady = 10; c.insets = new Insets(10, 0, 0, 0); c.anchor = GridBagConstraints.PAGE_END; add(button, c); }
From source file:org.jfree.chart.demo.selection.SelectionDemo4.java
/** * Creates a new demo./*from w ww . java2 s . co m*/ * * @param title the frame title. */ public SelectionDemo4(String title) { super(title); ChartPanel chartPanel = (ChartPanel) createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); this.dataset = (HistogramDataset) plot.getDataset(); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.add(chartPanel); this.model = new DefaultTableModel(new String[] { "Item:", "Bin Start:", "Bin End:", "Value:" }, 0); this.table = new JTable(this.model); JPanel p = new JPanel(new BorderLayout()); JScrollPane scroller = new JScrollPane(this.table); p.add(scroller); p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "), new EmptyBorder(4, 4, 4, 4))); split.add(p); setContentPane(split); }
From source file:BorderDemo.java
void addCompForBorder(Border border, String description, Container container) { JPanel comp = new JPanel(false); JLabel label = new JLabel(description, JLabel.CENTER); comp.setLayout(new GridLayout(1, 1)); comp.add(label);//from w ww . ja v a 2 s. c o m comp.setBorder(border); container.add(Box.createRigidArea(new Dimension(0, 10))); container.add(comp); }
From source file:api3.transform.PlotWave.java
public void plot(double[][] signal, String name, long samplerate) { frame.setTitle(name);// w ww .j ava 2 s.c o m XYSeries[] soundWave = new XYSeries[signal.length]; for (int j = 0; j < signal.length; ++j) { soundWave[j] = new XYSeries("sygnal" + j); for (int i = 0; i < signal[0].length; ++i) { double index = (samplerate == 0) ? i : 1000.0 * (double) i / (double) samplerate; soundWave[j].add(index, signal[j][i]); } } XYSeriesCollection dataset = new XYSeriesCollection(); for (int j = 0; j < signal.length; ++j) { dataset.addSeries(soundWave[j]); } JFreeChart chart = // (samplerate ==0 )? // ChartFactory.createXYBarChart( // name, // "prbka", // false, // "warto", // new XYBarDataset(dataset,0.0625), // PlotOrientation.VERTICAL, // true,false,false) // : ChartFactory.createXYLineChart(name, "prbka", "warto", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { int value = slider.getValue(); double minimum = domainAxis.getRange().getLowerBound(); double maximum = domainAxis.getRange().getUpperBound(); double delta = (0.1f * (domainAxis.getRange().getLength())); if (value < lastValue) { // left minimum = minimum - delta; maximum = maximum - delta; } else { // right minimum = minimum + delta; maximum = maximum + delta; } DateRange range = new DateRange(minimum, maximum); domainAxis.setRange(range); lastValue = value; if (lastValue == slider.getMinimum() || lastValue == slider.getMaximum()) { slider.setValue(SLIDER_DEFAULT_VALUE); } } }); plot.addRangeMarker(new ValueMarker(0, Color.BLACK, new BasicStroke(1))); ChartPanel chartPanel = new ChartPanel(chart); Border border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createEtchedBorder()); chartPanel.setBorder(border); chartPanel.addMouseWheelListener(addZoomWheel()); panel.add(chartPanel); JPanel dashboard = new JPanel(new BorderLayout()); dashboard.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4)); dashboard.add(slider); panel.add(dashboard, BorderLayout.SOUTH); frame.getContentPane().add((JPanel) panel, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
From source file:BorderDemo.java
public BorderDemo() { super(new GridLayout(1, 0)); // Keep references to the next few borders, // for use in titles and compound borders. Border blackline, raisedetched, loweredetched, raisedbevel, loweredbevel, empty; // A border that puts 10 extra pixels at the sides and // bottom of each pane. Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10); blackline = BorderFactory.createLineBorder(Color.black); raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); raisedbevel = BorderFactory.createRaisedBevelBorder(); loweredbevel = BorderFactory.createLoweredBevelBorder(); empty = BorderFactory.createEmptyBorder(); // First pane: simple borders JPanel simpleBorders = new JPanel(); simpleBorders.setBorder(paneEdge); simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS)); addCompForBorder(blackline, "line border", simpleBorders); addCompForBorder(raisedetched, "raised etched border", simpleBorders); addCompForBorder(loweredetched, "lowered etched border", simpleBorders); addCompForBorder(raisedbevel, "raised bevel border", simpleBorders); addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders); addCompForBorder(empty, "empty border", simpleBorders); // Second pane: matte borders JPanel matteBorders = new JPanel(); matteBorders.setBorder(paneEdge);/*from w ww .ja va2 s . co m*/ matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS)); ImageIcon icon = createImageIcon("images/wavy.gif", "wavy-line border icon"); // 20x22 Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon); if (icon != null) { addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders); } else { addCompForBorder(border, "matte border (-1,-1,-1,-1,<null-icon>)", matteBorders); } border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red); addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders); border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon); if (icon != null) { addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders); } else { addCompForBorder(border, "matte border (0,20,0,0,<null-icon>)", matteBorders); } // Third pane: titled borders JPanel titledBorders = new JPanel(); titledBorders.setBorder(paneEdge); titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS)); TitledBorder titled; titled = BorderFactory.createTitledBorder("title"); addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders); titled = BorderFactory.createTitledBorder(blackline, "title"); addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(loweredetched, "title"); addCompForTitledBorder(titled, "titled lowered etched border" + " (right just., default pos.)", TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(loweredbevel, "title"); addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders); titled = BorderFactory.createTitledBorder(empty, "title"); addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders); // Fourth pane: compound borders JPanel compoundBorders = new JPanel(); compoundBorders.setBorder(paneEdge); compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS)); Border redline = BorderFactory.createLineBorder(Color.red); Border compound; compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel); addCompForBorder(compound, "compound border (two bevels)", compoundBorders); compound = BorderFactory.createCompoundBorder(redline, compound); addCompForBorder(compound, "compound border (add a red outline)", compoundBorders); titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER, TitledBorder.BELOW_BOTTOM); addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Simple", null, simpleBorders, null); tabbedPane.addTab("Matte", null, matteBorders, null); tabbedPane.addTab("Titled", null, titledBorders, null); tabbedPane.addTab("Compound", null, compoundBorders, null); tabbedPane.setSelectedIndex(0); String toolTip = new String( "<html>Blue Wavy Line border art crew:<br> Bill Pauley<br> Cris St. Aubyn<br> Ben Wronsky<br> Nathan Walrath<br> Tommy Adams, special consultant</html>"); tabbedPane.setToolTipTextAt(1, toolTip); add(tabbedPane); }