List of usage examples for javax.swing BorderFactory createEmptyBorder
public static Border createEmptyBorder(int top, int left, int bottom, int right)
From source file:api3.transform.PlotWave.java
public void plot(double[][] signal, String name, long samplerate) { frame.setTitle(name);//from w ww.ja v a2s .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:ProgressBarDemo.java
public ProgressBarDemo() { super(new BorderLayout()); // Create the demo's UI. startButton = new JButton("Start"); startButton.setActionCommand("start"); startButton.addActionListener(this); progressBar = new JProgressBar(0, 100); progressBar.setValue(0);//from w w w . j av a 2 s . c o m progressBar.setStringPainted(true); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false); JPanel panel = new JPanel(); panel.add(startButton); panel.add(progressBar); add(panel, BorderLayout.PAGE_START); add(new JScrollPane(taskOutput), BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:org.pmedv.jake.app.PlayerView.java
private JPanel createTopPanel() { JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); buttonPanel.setBackground(Colors.LIGHT_GRAY); ImageIcon playIcon = resources.getIcon("icon.play"); ImageIcon stopIcon = resources.getIcon("icon.stop"); ImageIcon nextIcon = resources.getIcon("icon.next"); ImageIcon prevIcon = resources.getIcon("icon.last"); prevButton = new CmdJButton(prevIcon, "Plays the previous song", null); nextButton = new CmdJButton(nextIcon, "Plays the next song", null); startButton = new CmdJButton(playIcon, "Starts playing", null); stopButton = new CmdJButton(stopIcon, "Stops playing", null); buttonPanel.add(startButton);//from w w w. java2s. c o m buttonPanel.add(stopButton); buttonPanel.add(prevButton); buttonPanel.add(nextButton); buttonPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0), BorderFactory.createLineBorder(Color.LIGHT_GRAY))); timeField = new JTextField(5); timeField.setEditable(false); timeField.setBackground(Colors.SOFT_BLUE_ICE); titleField = new JMarqueeTextField(30); titleField.setEditable(false); titleField.setBackground(Colors.SOFT_BLUE_ICE); buttonPanel.add(timeField); buttonPanel.add(titleField); randomBox = new JCheckBox("R"); buttonPanel.add(randomBox); return buttonPanel; }
From source file:be.ac.ua.comp.scarletnebula.gui.keywizards.AbstractFinalKeyWizardPage.java
protected AbstractFinalKeyWizardPage(final CloudProvider provider, final String toptext, final String checkKeyname) { super(new BorderLayout()); final BetterTextLabel toptextLabel = new BetterTextLabel(toptext); toptextLabel.setBorder(BorderFactory.createEmptyBorder(20, 20, 0, 20)); makeDefault = new JCheckBox("Make this the default keypair.", true); if (KeyManager.getKeyNames(provider.getName()).isEmpty() || provider.getDefaultKeypair().isEmpty()) { makeDefault.setEnabled(false);//from w ww. j ava 2s . c om } makeDefault.setBorder(BorderFactory.createEmptyBorder(0, 20, 10, 20)); keyValidityMessage.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); add(keyValidityMessage, BorderLayout.CENTER); add(makeDefault, BorderLayout.SOUTH); final JPanel textAndThrobber = new JPanel(new BorderLayout()); textAndThrobber.add(toptextLabel, BorderLayout.NORTH); if (!checkKeyname.isEmpty()) { final ThrobberBarWithText throbber = new ThrobberBarWithText("Verifying key uniqueness..."); final CollapsablePanel throbberPanel = new CollapsablePanel(throbber, false); throbberPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); final SwingWorkerWithThrobber<Boolean, String> checkKeyWorker = new TestKeyExistsWorker(throbberPanel, checkKeyname, provider); checkKeyWorker.addPropertyChangeListener(new SetWarningMessagePropertyListener(checkKeyWorker)); checkKeyWorker.execute(); textAndThrobber.add(throbberPanel, BorderLayout.SOUTH); } add(textAndThrobber, BorderLayout.NORTH); }
From source file:captureplugin.drivers.defaultdriver.AdditionalParams.java
/** * Create GUI/*from www.java2 s .c o m*/ */ private void createGUI() { setTitle(mLocalizer.msg("Additional", "Additional Commands")); UiUtilities.registerForClosing(this); JPanel content = (JPanel) getContentPane(); content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); content.setLayout(new BorderLayout()); content.add(createListPanel(), BorderLayout.WEST); content.add(createDetailsPanel(), BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK)); JButton cancel = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okPressed(); } }); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); } }); buttonPanel.add(ok); buttonPanel.add(cancel); content.add(buttonPanel, BorderLayout.SOUTH); mList.setSelectedIndex(0); mList.setCellRenderer(new ParamEntryCellRenderer()); CapturePlugin.getInstance().layoutWindow("additionalParams", this, new Dimension(400, 300)); }
From source file:de.atomfrede.tools.evalutation.ui.ExceptionDialog.java
@Override public JComponent createContentPanel() { // TODO use here nicer layout, maybe with an icon JPanel panel = new JPanel(new BorderLayout(10, 10)); panel.setBorder(BorderFactory.createEmptyBorder(20, 40, 40, 40)); JLabel label = new JLabel("<html>An error occured!<br/>" + exception.toString() + "</html>"); label.setHorizontalAlignment(SwingConstants.LEFT); panel.add(label, BorderLayout.CENTER); panel.add(new JLabel(Icons.IC_DIALOG_ERROR_LARGE), BorderLayout.WEST); setSize(panel.getPreferredSize());/* w w w. ja v a2s . co m*/ return panel; }
From source file:org.cds06.speleograph.graph.DateAxisEditor.java
public DateAxisEditor(DateAxis dateAxis) { super(SpeleoGraphApp.getInstance(), true); this.axis = dateAxis; this.setTitle(I18nSupport.translate("graph.dateAxisEditor")); JPanel panel = new JPanel(); panel.setLayout(/* ww w . jav a 2 s .com*/ new FormLayout("r:p,4dlu,p:grow,4dlu", "p:grow,p,4dlu:grow,p,4dlu:grow,p,4dlu:grow,p,p:grow")); CellConstraints cc = new CellConstraints(); panel.add(new JLabel("Format :"), cc.xy(1, 2)); panel.add(dateSelector, cc.xy(3, 2)); panel.add(new JLabel("Date dbut :"), cc.xy(1, 4)); panel.add(minDate, cc.xy(3, 4)); panel.add(new JLabel("Date fin :"), cc.xy(1, 6)); panel.add(maxDate, cc.xy(3, 6)); ButtonBarBuilder barBuilder = new ButtonBarBuilder(); barBuilder.addGlue(); //Cancel button barBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("cancel")); } @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); //Ok button barBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("ok")); } @Override public void actionPerformed(ActionEvent e) { axis.setDateFormatOverride((DateFormat) dateSelector.getSelectedItem()); axis.setMinimumDate(minDate.getDate()); axis.setMaximumDate(maxDate.getDate()); setVisible(false); } }); panel.add(barBuilder.build(), cc.xyw(1, 8, 3)); minDate.setDate(dateAxis.getMinimumDate()); maxDate.setDate(dateAxis.getMaximumDate()); if (dateAxis.getDateFormatOverride() != null && dateAxis.getDateFormatOverride() instanceof HumanSimpleDateFormat) { dateSelector.setSelectedItem(dateAxis.getDateFormatOverride()); } setContentPane(panel); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setSize(panel.getPreferredSize().width + 100, panel.getPreferredSize().height + 100); }
From source file:DocumentEventDemo.java
public DocumentEventDemo() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); JButton button = new JButton("Clear"); button.addActionListener(this); textField = new JTextField(20); textField.addActionListener(new MyTextActionListener()); textField.getDocument().addDocumentListener(new MyDocumentListener()); textField.getDocument().putProperty("name", "Text Field"); textArea = new JTextArea(); textArea.getDocument().addDocumentListener(new MyDocumentListener()); textArea.getDocument().putProperty("name", "Text Area"); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setPreferredSize(new Dimension(200, 75)); displayArea = new JTextArea(); displayArea.setEditable(false);/* w w w. ja v a 2 s . c om*/ JScrollPane displayScrollPane = new JScrollPane(displayArea); displayScrollPane.setPreferredSize(new Dimension(200, 75)); c.gridx = 0; c.gridy = 0; c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; gridbag.setConstraints(textField, c); add(textField); c.gridx = 0; c.gridy = 1; c.weightx = 0.0; c.gridheight = 2; c.fill = GridBagConstraints.BOTH; gridbag.setConstraints(scrollPane, c); add(scrollPane); c.gridx = 1; c.gridy = 0; c.weightx = 1.0; c.weighty = 1.0; gridbag.setConstraints(displayScrollPane, c); add(displayScrollPane); c.gridx = 1; c.gridy = 2; c.weightx = 0.0; c.gridheight = 1; c.weighty = 0.0; c.fill = GridBagConstraints.HORIZONTAL; gridbag.setConstraints(button, c); add(button); setPreferredSize(new Dimension(450, 250)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:InternalFrameEventDemo.java
protected void createDisplayWindow() { JButton b1 = new JButton("Show internal frame"); b1.setActionCommand(SHOW);/*from w ww . j a v a 2 s . c om*/ b1.addActionListener(this); JButton b2 = new JButton("Clear event info"); b2.setActionCommand(CLEAR); b2.addActionListener(this); display = new JTextArea(3, 30); display.setEditable(false); JScrollPane textScroller = new JScrollPane(display); // Have to supply a preferred size, or else the scroll // area will try to stay as large as the text area. textScroller.setPreferredSize(new Dimension(200, 75)); textScroller.setMinimumSize(new Dimension(10, 10)); displayWindow = new JInternalFrame("Event Watcher", true, // resizable false, // not closable false, // not maximizable true); // iconifiable JPanel contentPane = new JPanel(); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); b1.setAlignmentX(CENTER_ALIGNMENT); contentPane.add(b1); contentPane.add(Box.createRigidArea(new Dimension(0, 5))); contentPane.add(textScroller); contentPane.add(Box.createRigidArea(new Dimension(0, 5))); b2.setAlignmentX(CENTER_ALIGNMENT); contentPane.add(b2); displayWindow.setContentPane(contentPane); displayWindow.pack(); displayWindow.setVisible(true); }
From source file:events.ListSelectionDemo.java
public ListSelectionDemo() { super(new BorderLayout()); String[] listData = { "one", "two", "three", "four", "five", "six", "seven" }; String[] columnNames = { "French", "Spanish", "Italian" }; list = new JList(listData); listSelectionModel = list.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); JScrollPane listPane = new JScrollPane(list); JPanel controlPane = new JPanel(); String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" }; final JComboBox comboBox = new JComboBox(modes); comboBox.setSelectedIndex(2);/*from www .j av a 2 s .c o m*/ comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newMode = (String) comboBox.getSelectedItem(); if (newMode.equals("SINGLE_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } else { listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } output.append("----------" + "Mode: " + newMode + "----------" + newline); } }); controlPane.add(new JLabel("Selection mode:")); controlPane.add(comboBox); //Build output area. output = new JTextArea(1, 10); output.setEditable(false); JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); //Do the layout. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS)); JPanel listContainer = new JPanel(new GridLayout(1, 1)); listContainer.setBorder(BorderFactory.createTitledBorder("List")); listContainer.add(listPane); topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); topHalf.add(listContainer); //topHalf.add(tableContainer); topHalf.setMinimumSize(new Dimension(100, 50)); topHalf.setPreferredSize(new Dimension(100, 110)); splitPane.add(topHalf); JPanel bottomHalf = new JPanel(new BorderLayout()); bottomHalf.add(controlPane, BorderLayout.PAGE_START); bottomHalf.add(outputPane, BorderLayout.CENTER); //XXX: next line needed if bottomHalf is a scroll pane: //bottomHalf.setMinimumSize(new Dimension(400, 50)); bottomHalf.setPreferredSize(new Dimension(450, 135)); splitPane.add(bottomHalf); }