List of usage examples for javax.swing BoxLayout BoxLayout
@ConstructorProperties({ "target", "axis" }) public BoxLayout(Container target, int axis)
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);/*from w w w . j ava 2 s . c om*/ 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); 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); }
From source file:net.sf.maltcms.chromaui.normalization.spi.actions.OpenPeakGroupRtBoxPlot.java
@Override public void actionPerformed(ActionEvent ev) { IChromAUIProject project = Utilities.actionsGlobalContext().lookup(IChromAUIProject.class); if (project != null && !context.isEmpty()) { PeakGroupBoxPlotTopComponent pgbpt = new PeakGroupBoxPlotTopComponent(); PeakGroupRtBoxPlot pgbp = new PeakGroupRtBoxPlot(project, context); JPanel bg = new JPanel(); BoxLayout bl = new BoxLayout(bg, BoxLayout.Y_AXIS); bg.setLayout(bl);/* ww w.j av a2s.c om*/ for (JFreeChart chart : pgbp.createChart()) { ChartPanel cp = new ContextAwareChartPanel(chart); bg.add(cp); } JScrollPane jsp = new JScrollPane(bg); pgbpt.add(jsp, BorderLayout.CENTER); IRegistry registry = Lookup.getDefault().lookup(IRegistryFactory.class).getDefault(); for (IPeakGroupDescriptor pgd : context) { registry.registerTopComponentFor(pgd, pgbpt); } pgbpt.open(); pgbpt.requestActive(); } else { Logger.getLogger(getClass().getName()).warning("No IChromAUI project is in lookup!"); } }
From source file:org.onesun.sdi.swing.app.views.DataServicesView.java
public DataServicesView() { this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); createControls(); addControlsToPanel(); }
From source file:edu.gcsc.vrl.jfreechart.JFXPlotContainerType.java
public JFXPlotContainerType() { setValueName("Plot"); // name of the visualization // Set layout this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.setPreferredSize(new Dimension(300, 200)); this.setMinimumSize(new Dimension(200, 120)); // Get the panel from the xychart chartContainer = new TransparentPanel(); // Set layout chartContainer.setLayout(new BorderLayout()); // Add ruler// w w w . j a v a 2s . c om ResizableContainer container = new ResizableContainer(chartContainer); add(container); addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { setValueOptions("width=" + getWidth() + ";" + "height=" + getHeight()); } }); }
From source file:com.igormaznitsa.mindmap.plugins.exporters.PNGImageExporter.java
@Override @Nullable/* w ww. j a va 2 s . c om*/ public JComponent makeOptions() { final JPanel panel = UI_FACTORY.makePanel(); final JCheckBox checkBoxExpandAll = UI_FACTORY.makeCheckBox(); checkBoxExpandAll.setSelected(flagExpandAllNodes); checkBoxExpandAll.setText(Texts.getString("PNGImageExporter.optionUnfoldAll")); checkBoxExpandAll.setActionCommand("unfold"); final JCheckBox checkSaveBackground = UI_FACTORY.makeCheckBox(); checkSaveBackground.setSelected(flagSaveBackground); checkSaveBackground.setText(Texts.getString("PNGImageExporter.optionDrawBackground")); checkSaveBackground.setActionCommand("back"); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(checkBoxExpandAll); panel.add(checkSaveBackground); panel.setBorder(BorderFactory.createEmptyBorder(16, 32, 16, 32)); return panel; }
From source file:io.github.jeremgamer.editor.ManagerFrame.java
public ManagerFrame(String projectName, final JFrame parent) { dialog = this; ArrayList<BufferedImage> icons = new ArrayList<BufferedImage>(); try {//from w w w . ja v a 2 s. c o m icons.add(ImageIO.read(ImageGetter.class.getResource("icon16.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon32.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon64.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon128.png"))); } catch (IOException e1) { e1.printStackTrace(); } this.setIconImages((List<? extends Image>) icons); this.setTitle("Grer les projets"); this.setSize(300, 200); this.setModal(true); this.setLocationRelativeTo(parent); this.setResizable(false); final JScrollPane scroll = new JScrollPane(content); scroll.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); content.setBorder(BorderFactory.createTitledBorder("")); content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS)); for (File project : new File("projects").listFiles()) { if (project.getName().equals(Editor.getProjectName())) { content.add(new ProjectPanel(project.getName(), true, parent, this)); } else { content.add(new ProjectPanel(project.getName(), false, parent, this)); } } try { final JButton add = new JButton("Crer un nouveau projet", new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); newProjectPanel.add(newProjectName); newProjectPanel.add(validate); this.setLayout(new BorderLayout()); scroll.setBorder(null); this.add(scroll, BorderLayout.CENTER); this.add(add, BorderLayout.SOUTH); add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { validate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); parent.dispose(); new Thread(new Runnable() { public void run() { window.getContentPane() .add(new JLabel("", new ImageIcon(ImageGetter.class.getResource("splash.gif")), SwingConstants.CENTER)); window.setBackground(new Color(0, 0, 0, 0)); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); } }).start(); new Thread(new Runnable() { public void run() { new Editor(newProjectName.getText()); window.setVisible(false); } }).start(); } }); CaretListener caretUpdate = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); for (File dir : new File("projects").listFiles()) { if (dir.isDirectory() && text.getText().equals(dir.getName())) { validate.setEnabled(false); validate.setText("Existe dj"); break; } else { validate.setEnabled(true); validate.setText("Crer!"); } } } }; JButton cancel = null; try { cancel = new JButton( new ImageIcon(ImageIO.read(ImageGetter.class.getResource("cancel.png")))); } catch (IOException e1) { e1.printStackTrace(); } newProjectName.addCaretListener(caretUpdate); remove(add); addPanel.setLayout(new BorderLayout()); addPanel.add(newProjectPanel, BorderLayout.CENTER); addPanel.add(cancel, BorderLayout.EAST); add(addPanel, BorderLayout.SOUTH); revalidate(); repaint(); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { newProjectName.setText(""); remove(addPanel); add(add, BorderLayout.SOUTH); revalidate(); repaint(); } }); newProjectName.requestFocusInWindow(); newProjectName.requestFocus(); } }); this.setVisible(true); } catch (IOException e) { e.printStackTrace(); } }
From source file:net.sf.firemox.ui.wizard.Wizard.java
/** * Create a new instance of this class.//from w ww . j a va2 s.c o m * * @param ability * ability to associate to this ability. If this ability has an * associated picture, it will be used instead of given picture. * Ability's name is also used to fill the title. This ability will * be used to restart this wizard in case of Background button is * used. * @param title * the title of this wizard. * @param description * the description appended to the title of this wizard. This content * will be displayed as Html. * @param iconName * the icon's name to display on the top right place. * @param width * the preferred width. * @param height * the preferred height. */ public Wizard(Ability ability, String title, String description, String iconName, int width, int height) { super(MagicUIComponents.magicForm, StringUtils.capitalize(title), true); getRootPane().setPreferredSize(new Dimension(width, 300)); getRootPane().setMinimumSize(new Dimension(width, height)); setSize(new Dimension(width, height)); // center gameParamPanel = new JPanel(null); gameParamPanel.setLayout(new BoxLayout(gameParamPanel, BoxLayout.Y_AXIS)); if (ability == null) getContentPane().add(new WizardTitle(new WizardImageIcon((Image) null, iconName), description), BorderLayout.NORTH); else getContentPane().add(new WizardTitle(new WizardImageIcon(ability.getCard(), iconName), description), BorderLayout.NORTH); getContentPane().add(gameParamPanel, BorderLayout.CENTER); getContentPane().add(new JPanel(), BorderLayout.EAST); // bottom final JPanel abstractButtonPanel = new JPanel(new BorderLayout()); this.buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); this.ability = ability; abstractButtonPanel.setBorder(null); abstractButtonPanel.add(new JSeparator(), BorderLayout.NORTH); abstractButtonPanel.add(buttonPanel, BorderLayout.CENTER); abstractButtonPanel.add(wizardInfo, BorderLayout.SOUTH); getContentPane().add(abstractButtonPanel, BorderLayout.SOUTH); setLocationRelativeTo(null); }
From source file:com.antelink.sourcesquare.gui.view.ExitSourceSquareView.java
/** * Create the frame.//from ww w . j ava 2s .c o m */ public ExitSourceSquareView() { setIconImage(Toolkit.getDefaultToolkit().getImage(SourceSquareView.class.getResource("/antelink.png"))); setTitle("SourceSquare"); setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 500, 170); this.contentPane = new JPanel(); this.contentPane.setBackground(Color.WHITE); this.contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(this.contentPane); this.mainPanel = new JPanel(); this.mainPanel.setBackground(Color.WHITE); GroupLayout gl_contentPane = new GroupLayout(this.contentPane); gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) .addComponent(this.mainPanel, GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE)); gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) .addComponent(this.mainPanel, GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)); this.mainPanel.setLayout(new BoxLayout(this.mainPanel, BoxLayout.Y_AXIS)); JPanel panel_1 = new JPanel(); panel_1.setBackground(Color.WHITE); this.mainPanel.add(panel_1); panel_1.setLayout(new BorderLayout(0, 0)); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout(FlowLayout.CENTER, 50, 20)); panel.setBackground(Color.WHITE); panel_1.add(panel, BorderLayout.SOUTH); Image openButtonImage = Toolkit.getDefaultToolkit() .getImage(SourceSquareView.class.getResource("/OpenButton.png")); this.openButtonLabel = new JLabel(new ImageIcon(openButtonImage)); this.openButtonLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); panel.add(this.openButtonLabel); JLabel exitLabel = new JLabel("<html><b>Closing this window will quit the application</b></html>"); exitLabel.setFont(new Font("Helvetica", Font.PLAIN, 13)); JLabel explainLabel = new JLabel("<html>(You won't be able to see or publish your results anymore)</html>"); explainLabel.setFont(new Font("Helvetica", Font.PLAIN, 13)); JPanel textPanel = new JPanel(); textPanel.setBackground(Color.WHITE); textPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 0)); textPanel.add(exitLabel, BorderLayout.CENTER); textPanel.add(explainLabel, BorderLayout.CENTER); panel_1.add(textPanel, BorderLayout.CENTER); CopyrightPanel copyrightPanel = new CopyrightPanel(); copyrightPanel.setBackground(Color.WHITE); this.mainPanel.add(copyrightPanel); this.contentPane.setLayout(gl_contentPane); setLocationRelativeTo(null); }
From source file:greenapi.ui.charts.ChartPanelSupport.java
public ChartPanelSupport(String title, String axisLabel, T resource, int updateIntervalInSeconds) { this.title = title; this.axisLabel = axisLabel; this.resource = resource; this.updateDelayInSeconds = updateIntervalInSeconds; this.chartPanel = new org.jfree.chart.ChartPanel(chart = this.createChart()); this.chartPanel.setDomainZoomable(true); this.chartPanel.setRangeZoomable(true); setLayout(new BoxLayout(this, 2)); this.add(this.chartPanel); updateChartExecutorService = new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors()); }
From source file:jchrest.gui.VisualSearchPane.java
private JPanel trainPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(constructTrainingOptions()); panel.add(runTrainingButtons());// w ww. j a v a 2s .c o m if (freeChartLoaded()) { panel.add(createPanel()); } return panel; }