List of usage examples for javax.swing BoxLayout BoxLayout
@ConstructorProperties({ "target", "axis" }) public BoxLayout(Container target, int axis)
From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java
private JComponent makeTextPanelSummary() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); JPanel summaryItems = new JPanel(); summaryItems.setLayout(new BoxLayout(summaryItems, BoxLayout.PAGE_AXIS)); summaryItems.add(makeButtons());/*from ww w . ja va 2 s.c o m*/ summaryItems.add(makeCheckboxes()); summaryItems.add(makeCheckboxesXsd()); summaryItems.add(makeResultsPanel()); JScrollPane summaryPane = new JScrollPane(summaryItems); p.add(summaryPane); return p; }
From source file:SciTK.Plot.java
/** * Load the initial UI//w w w. j a va2s . co m */ protected final void initUI() { setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); // create a ChartPanel, and make it default to 1/4 of screen size: chart_panel = new ChartPanel(chart); chart_panel.setPreferredSize(new Dimension(def_width, def_height)); //add the chart to the window: getContentPane().add(chart_panel); // create a menu bar: menubar = new JMenuBar(); // --------------------------------------------------------- // First dropdown menu: "File" // --------------------------------------------------------- file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); // Set up a save dialog option under the file menu: JMenuItem menu_file_save; ImageIcon menu_file_save_icon = null; try { menu_file_save_icon = new ImageIcon(getClass().getResource("/SciTK/resources/document-save-5.png")); menu_file_save = new JMenuItem("Save", menu_file_save_icon); } catch (Exception e) { menu_file_save = new JMenuItem("Save"); } menu_file_save.setMnemonic(KeyEvent.VK_S); menu_file_save.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu_file_save.setToolTipText("Save an image"); menu_file_save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveImage(); } }); file.add(menu_file_save); // Set up a save SVG dialog option under the file menu: JMenuItem menu_file_save_svg; try { menu_file_save_svg = new JMenuItem("Save VG", menu_file_save_icon); } catch (Exception e) { menu_file_save_svg = new JMenuItem("Save VG"); } menu_file_save_svg.setToolTipText("Save as vector graphics (SVG,PS,EPS)"); menu_file_save_svg.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveVectorGraphics(); } }); file.add(menu_file_save_svg); // Set up a save data dialog option under the file menu: JMenuItem menu_file_save_data; try { menu_file_save_data = new JMenuItem("Save data", menu_file_save_icon); } catch (Exception e) { menu_file_save_data = new JMenuItem("Save data"); } menu_file_save_data.setToolTipText("Save raw data to file"); menu_file_save_data.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveData(); } }); file.add(menu_file_save_data); // Set up a save data dialog option under the file menu: JMenuItem menu_file_print; try { ImageIcon menu_file_print_icon = new ImageIcon( getClass().getResource("/SciTK/resources/document-print-5.png")); menu_file_print = new JMenuItem("Print", menu_file_print_icon); } catch (Exception e) { menu_file_print = new JMenuItem("Print"); } menu_file_print.setToolTipText("Print image of chart"); menu_file_print.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { printPlot(); } }); file.add(menu_file_print); // menu item for exiting JMenuItem menu_file_exit; try { ImageIcon menu_file_exit_icon = new ImageIcon( getClass().getResource("/SciTK/resources/application-exit.png")); menu_file_exit = new JMenuItem("Exit", menu_file_exit_icon); } catch (Exception e) { menu_file_exit = new JMenuItem("Exit"); } menu_file_exit.setMnemonic(KeyEvent.VK_X); menu_file_exit.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu_file_exit.setToolTipText("Exit application"); menu_file_exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dispose(); } }); file.add(menu_file_exit); // --------------------------------------------------------- // Second dropdown menu: "Edit" // --------------------------------------------------------- edit = new JMenu("Edit"); edit.setMnemonic(KeyEvent.VK_E); // copy to clipboard JMenuItem menu_edit_copy_image; ImageIcon menu_edit_copy_icon = null; try { menu_edit_copy_icon = new ImageIcon(getClass().getResource("/SciTK/resources/edit-copy-7.png")); menu_edit_copy_image = new JMenuItem("Copy", menu_edit_copy_icon); } catch (Exception e) { menu_edit_copy_image = new JMenuItem("Copy"); } menu_edit_copy_image.setMnemonic(KeyEvent.VK_C); menu_edit_copy_image.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu_edit_copy_image.setToolTipText("Copy image to clipboard"); menu_edit_copy_image.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { copyImage(); } }); edit.add(menu_edit_copy_image); // copy data to clipboard JMenuItem menu_edit_copy_data; try { menu_edit_copy_data = new JMenuItem("Copy data", menu_edit_copy_icon); } catch (Exception e) { menu_edit_copy_data = new JMenuItem("Copy data"); } menu_edit_copy_data.setToolTipText("Copy data to clipboard"); menu_edit_copy_data.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { copyData(); } }); edit.add(menu_edit_copy_data); // set background color JMenuItem menu_edit_BackgroundColor; ImageIcon menu_edit_Color_icon = null; try { menu_edit_Color_icon = new ImageIcon(getClass().getResource("/SciTK/resources/color-wheel.png")); menu_edit_BackgroundColor = new JMenuItem("Background Color", menu_edit_Color_icon); } catch (Exception e) { menu_edit_BackgroundColor = new JMenuItem("Background Color"); } menu_edit_BackgroundColor.setToolTipText("Select background color"); menu_edit_BackgroundColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Color bgColor = plotColorChooser("Choose background color", (Color) chart.getBackgroundPaint()); setBackgroundColor(bgColor); } }); edit.add(menu_edit_BackgroundColor); // set plot color JMenuItem menu_edit_PlotColor; try { menu_edit_PlotColor = new JMenuItem("Window Color", menu_edit_Color_icon); } catch (Exception e) { menu_edit_PlotColor = new JMenuItem("Window Color"); } menu_edit_PlotColor.setToolTipText("Select plot window color"); menu_edit_PlotColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Color plotColor = plotColorChooser("Choose plot color", (Color) chart.getPlot().getBackgroundPaint()); setWindowBackground(plotColor); } }); edit.add(menu_edit_PlotColor); // set gridline color JMenuItem menu_edit_GridlineColor; try { menu_edit_GridlineColor = new JMenuItem("Gridline Color", menu_edit_Color_icon); } catch (Exception e) { menu_edit_GridlineColor = new JMenuItem("Gridline Color"); } menu_edit_GridlineColor.setToolTipText("Select grid color"); menu_edit_GridlineColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Color gridColor = plotColorChooser("Choose grid color", (Color) chart.getPlot().getBackgroundPaint()); setGridlineColor(gridColor); } }); edit.add(menu_edit_GridlineColor); // edit chart preferences JMenuItem menu_edit_preferences; try { ImageIcon menu_edit_preferences_icon = new ImageIcon( getClass().getResource("/SciTK/resources/preferences-desktop-3.png")); menu_edit_preferences = new JMenuItem("Preferences", menu_edit_preferences_icon); } catch (Exception e) { menu_edit_preferences = new JMenuItem("Preferences"); } menu_edit_preferences.setToolTipText("Edit chart preferences"); menu_edit_preferences.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { chart_panel.doEditChartProperties(); } }); edit.add(menu_edit_preferences); // --------------------------------------------------------- // Third dropdown menu: "Plot" // --------------------------------------------------------- plot = new JMenu("Plot"); plot.setMnemonic(KeyEvent.VK_P); // Options to set log axes JCheckBoxMenuItem menu_plot_ylog = new JCheckBoxMenuItem("Log y axis"); menu_plot_ylog.setToolTipText("Set y axis to logarithmic"); menu_plot_ylog.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setRangeAxisLog(selected); } }); plot.add(menu_plot_ylog); JCheckBoxMenuItem menu_plot_xlog = new JCheckBoxMenuItem("Log x axis"); menu_plot_xlog.setToolTipText("Set x axis to logarithmic"); menu_plot_xlog.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setDomainAxisLog(selected); } }); plot.add(menu_plot_xlog); // grid line display JCheckBoxMenuItem menu_plot_grid = new JCheckBoxMenuItem("Grid lines"); menu_plot_grid.setToolTipText("Show plot grid lines?"); menu_plot_grid.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setGridlineVisible(selected); } }); // set appropirate checkbox state: menu_plot_grid.setState(chart.getXYPlot().isDomainGridlinesVisible()); plot.add(menu_plot_grid); // control for displaying plot legend JCheckBoxMenuItem menu_plot_legend = new JCheckBoxMenuItem("Legend"); menu_plot_legend.setToolTipText("Show plot legend?"); menu_plot_legend.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setLegend(selected); } }); // set appropirate checkbox state: menu_plot_legend.setState((chart.getLegend() instanceof LegendTitle)); plot.add(menu_plot_legend); // --------------------------------------------------------- // General UI // --------------------------------------------------------- // Add menus to the menu bar: menubar.add(file); menubar.add(edit); menubar.add(plot); // Set menubar as this JFrame's menu setJMenuBar(menubar); // set default plot colors: chart.setBackgroundPaint(new Color(255, 255, 255, 0)); chart.getPlot().setBackgroundPaint(new Color(255, 255, 255, 255)); setBackgroundAlpha(0.0f); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); pack(); setTitle(window_title); setLocationRelativeTo(null); setVisible(true); }
From source file:net.sf.taverna.t2.workbench.views.results.processor.RenderedProcessorResultComponent.java
/** * Creates the component.//from w ww . ja v a 2s . c o m */ public RenderedProcessorResultComponent(RendererRegistry rendererRegistry, List<SaveIndividualResultSPI> saveActions) { this.rendererRegistry = rendererRegistry; setLayout(new BorderLayout()); setBorder(new EtchedBorder()); // Results type combo box renderersComboBox = new JComboBox<>(); renderersComboBox.setModel(new DefaultComboBoxModel<String>()); // initially empty renderersComboBox.setRenderer(new ColorCellRenderer()); renderersComboBox.setEditable(false); renderersComboBox.setEnabled(false); // initially disabled // Set the new listener - listen for changes in the currently selected renderer renderersComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == SELECTED && !ERROR_DOCUMENT.equals(e.getItem())) // render the result using the newly selected renderer renderResult(); } }); JPanel resultsTypePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); resultsTypePanel.add(new JLabel("Value type")); resultsTypePanel.add(renderersComboBox); // Refresh (re-render) button refreshButton = new JButton("Refresh", refreshIcon); refreshButton.setEnabled(false); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { renderResult(); refreshButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is clicked * on and did its action */ } }); resultsTypePanel.add(refreshButton); // Check box for wrapping text if result is of type "text/plain" wrapTextCheckBox = new JCheckBox(WRAP_TEXT); wrapTextCheckBox.setVisible(false); wrapTextCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // Should have only one child component holding the rendered result // Check for empty just as well if (renderedResultPanel.getComponents().length == 0) return; if (renderedResultPanel.getComponent(0) instanceof DialogTextArea) { nodeToWrapSelection.put(node.hashCode(), e.getStateChange() == SELECTED); renderResult(); } } }); resultsTypePanel.add(wrapTextCheckBox); // 'Save result' buttons panel saveButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); for (SaveIndividualResultSPI action : saveActions) { action.setResultReference(null); final JButton saveButton = new JButton(action.getAction()); saveButton.setEnabled(false); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is * clicked on and did its action */ } }); saveButtonsPanel.add(saveButton); } // Top panel contains result type combobox and various save buttons JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, LINE_AXIS)); topPanel.add(resultsTypePanel); topPanel.add(saveButtonsPanel); // Rendered results panel - initially empty renderedResultPanel = new JPanel(new BorderLayout()); renderedResultPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); // Add all components add(topPanel, NORTH); add(new JScrollPane(renderedResultPanel), CENTER); }
From source file:medsavant.uhn.cancer.UserCommentApp.java
private JPanel getCommentPanel(UserComment lc) { JTextArea commentText = new JTextArea(); commentText.setText(lc.getCommentText()); commentText.setEditable(false);/*from w ww .j a v a 2 s . c o m*/ commentText.setLineWrap(true); commentText.setPreferredSize(new Dimension(COMMENTTEXT_PREFERRED_WIDTH, COMMENTTEXT_PREFERRED_HEIGHT)); JScrollPane jsp = new JScrollPane(commentText); JPanel outerCommentPanel = new JPanel(); outerCommentPanel.setLayout(new BoxLayout(outerCommentPanel, BoxLayout.X_AXIS)); outerCommentPanel.add(jsp); outerCommentPanel.add(Box.createHorizontalGlue()); return outerCommentPanel; }
From source file:net.sf.dsig.DSApplet.java
private void initSwing() { try {//from w w w . ja va 2 s. c o m UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { logger.warn("UIManager.setLookAndFeel() failed", e); } JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS)); panel.setBackground(Color.decode(backgroundColor)); add(panel); boolean lockPrinted = false; if (formId != null) { Icon lockIcon = new ImageIcon(getClass().getResource("/icons/lock.png")); lockPrinted = true; JButton button = new JButton("Sign", lockIcon); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { available.acquireUninterruptibly(); try { signInternal(formId, null); } catch (Exception ex) { logger.error("Internal sign failed", e); } finally { available.release(); } } }); panel.add(button); } Icon infoIcon = new ImageIcon(getClass().getResource(lockPrinted ? "/icons/info.png" : "/icons/lock.png")); JLabel infoLabel = new JLabel(infoIcon); infoLabel.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { JOptionPane.showMessageDialog(null, printInfoMessage()); } public void mouseEntered(MouseEvent e) { /* NOOP */ } public void mouseExited(MouseEvent e) { /* NOOP */ } public void mousePressed(MouseEvent e) { /* NOOP */ } public void mouseReleased(MouseEvent e) { /* NOOP */ } }); panel.add(infoLabel); }
From source file:de.evaluationtool.gui.EvaluationFrame.java
public EvaluationFrame(File loadLimitFile, File autoEvalDistanceFile, File nameSourceFile, File readmeTemplateFile) throws FileNotFoundException { super(DEFAULT_TITLE); this.nameSource = new NameSource(nameSourceFile); this.loadLimitFile = loadLimitFile; this.autoEvalDistanceFile = autoEvalDistanceFile; this.nameSourceFile = nameSourceFile; this.readmeTemplateFile = readmeTemplateFile; this.setLocation(100, 100); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setMinimumSize(new Dimension(800, 700)); this.add(scrollPane); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS)); // for(ReferenceFormat format: ReferenceFormats.referenceFormats) // {/*from w w w . ja va 2 s. c o m*/ // if(format.hasReadSupport()) // { // JMenuItem item = new JMenuItem("Load "+format.getDescription()); // fileMenu.add(item); // } // if(format.hasWriteSupport()) // { // JMenuItem item = new JMenuItem("Save "+format.getDescription()); // saveMenu.add(item); // } // } for (JMenuItem item : fileMenuItems) { fileMenu.add(item); } // for(JMenuItem item : saveMenuItems) {saveMenu.add(item);} for (JMenuItem item : operationMenuItems) { operationMenu.add(item); } for (JMenuItem item : optionMenuItems) { optionMenu.add(item); } for (JMenuItem item : helpMenuItems) { helpMenu.add(item); } for (JMenu menu : menues) { for (Component component : menu.getMenuComponents()) { if (component instanceof JMenuItem) { ((JMenuItem) component).addActionListener(listener); } } menuBar.add(menu); } this.setJMenuBar(menuBar); this.pack(); reloadNamesources(); autoload(); }
From source file:edu.ucla.stat.SOCR.chart.SuperPowerChart.java
protected void initGraphPanel() { //System.out.println("initGraphPanel called"); graphPanel = new JPanel(); graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); JFreeChart chart = createEmptyChart(null); //create a empty graph first chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y - 100)); /* sliderPanel = new JPanel(); // ww w . j a va2s .co m // ValueSetter(String title, int type int min, int max, int initial,boolean minimumRange10) powerSlider = new ValueSlider("Power", -10, 10, 1,true); reset_slider();// the range will need to be reset powerSlider.setPreferredSize(new Dimension(CHART_SIZE_X-10,100)); powerSlider.addObserver(this); sliderPanel.add(this.powerSlider); sliderPanel.setPreferredSize(new Dimension(CHART_SIZE_X-10,100));*/ graphPanel.add(chartPanel); // graphPanel.add(sliderPanel); //System.out.println("added SliderPanel"); graphPanel.validate(); }
From source file:edu.ucla.stat.SOCR.chart.SuperBoxAndWhiskerChart_Vertical.java
protected void setChart() { // update graph // System.out.println("setChart called"); graphPanel.removeAll();// w w w .ja v a 2 s . co m graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y)); if (legendPanelOn) { JFreeChart chart2 = createLegendChart(createLegend(dataset)); legendPanel = new ChartPanel(chart2, false); //legendPanel.setPreferredSize(new Dimension(CHART_SIZE_X,CHART_SIZE_Y*2/3)); } graphPanel.add(chartPanel); JScrollPane legendPane = new JScrollPane(legendPanel); if (legendPanelOn) { legendPane.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 5)); graphPanel.add(legendPane); } graphPanel.validate(); // get the GRAPH panel to the front if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) != ALL) { tabbedPanelContainer.setSelectedIndex(tabbedPanelContainer.indexOfComponent(graphPanel)); graphPanel.removeAll(); graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); graphPanel.add(chartPanel); if (legendPanelOn) { legendPane = new JScrollPane(legendPanel); legendPane.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 5)); graphPanel.add(legendPane); } graphPanel.validate(); } else { graphPanel2.removeAll(); chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 3)); //legendPanel.setPreferredSize(new Dimension(CHART_SIZE_X*2/3,CHART_SIZE_Y*2/5)); graphPanel2.add(chartPanel); if (legendPanelOn) { legendPane = new JScrollPane(legendPanel); legendPane.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 5)); graphPanel2.add(legendPane); } graphPanel2.validate(); summaryPanel.validate(); } }
From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java
private JComponent makeButtons() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); p.add(convertBtn);//from w ww . ja va 2 s . c om p.add(Box.createRigidArea(new Dimension(0, 10))); p.add(validateBtn); p.add(Box.createRigidArea(new Dimension(0, 10))); p.add(convertAndValidateBtn); p.add(Box.createRigidArea(new Dimension(0, 10))); p.add(convertEdmBtn); return p; }
From source file:com.eviware.soapui.support.components.SimpleForm.java
public void appendHeadingAndHelpButton(String text, String helpUrl) { JLabel label = new JLabel(text); Font font = label.getFont();/*from w w w .jav a 2s .c o m*/ Font fontBold = new Font(font.getName(), Font.BOLD, font.getSize()); label.setFont(fontBold); JPanel innerPanel = new JPanel(); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS)); innerPanel.add(label); innerPanel.add(Box.createHorizontalGlue()); innerPanel.add(UISupport.createFormButton(new ShowOnlineHelpAction(helpUrl))); append(null, null, innerPanel, null, DEFAULT_LABEL_COLUMN, getColumnSpanToTheEnd(DEFAULT_LABEL_COLUMN)); }