List of usage examples for javax.swing BoxLayout BoxLayout
@ConstructorProperties({ "target", "axis" }) public BoxLayout(Container target, int axis)
From source file:com.googlecode.gmail4j.util.LoginDialog.java
/** * Shows the dialog//from www. jav a 2s .c o m */ private void showDialog() { final BoxLayout layout = new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS); dialog.getContentPane().setLayout(layout); dialog.getContentPane().add(labelUser); dialog.getContentPane().add(user); dialog.getContentPane().add(labelPass); dialog.getContentPane().add(pass); dialog.getContentPane().add(ok); dialog.pack(); dialog.setSize(200, dialog.getSize().height); dialog.setResizable(false); dialog.setAlwaysOnTop(true); center(dialog); dialog.setVisible(true); user.requestFocusInWindow(); }
From source file:NormSample.java
public void init() { // preparing values for the normalization forms ComboBox formValues.put("NFC", Normalizer.Form.NFC); formValues.put("NFD", Normalizer.Form.NFD); formValues.put("NFKC", Normalizer.Form.NFKC); formValues.put("NFKD", Normalizer.Form.NFKD); formComboBox = new JComboBox(); for (Iterator it = formValues.keySet().iterator(); it.hasNext();) { formComboBox.addItem((String) it.next()); }// w ww . j ava2 s. c o m // preparing samples for normalization // text with the acute accent symbol templateValues.put("acute accent", "touch" + "\u00e9"); // text with ligature templateValues.put("ligature", "a" + "\ufb03" + "ance"); // text with the cedilla templateValues.put("cedilla", "fa" + "\u00e7" + "ade"); // text with half-width katakana templateValues.put("half-width katakana", "\uff81\uff6e\uff7a\uff9a\uff70\uff84"); normalizationTemplate = new JComboBox(); for (Iterator it = templateValues.keySet().iterator(); it.hasNext();) { normalizationTemplate.addItem((String) it.next()); } // defining a component to output normalization results paintingComponent = new JComponent() { static final long serialVersionUID = -3725620407788489160L; public Dimension getSize() { return new Dimension(550, 200); } public Dimension getPreferredSize() { return new Dimension(550, 200); } public Dimension getMinimumSize() { return new Dimension(550, 200); } public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setFont(new Font("Serif", Font.PLAIN, 20)); g2.setColor(Color.BLACK); g2.drawString("Original string:", 100, 80); g2.drawString("Normalized string:", 100, 120); g2.setFont(new Font("Serif", Font.BOLD, 24)); // output of the original sample selected from the ComboBox String original_string = templateValues.get(normalizationTemplate.getSelectedItem()); g2.drawString(original_string, 320, 80); // normalization and output of the normalized string String normalized_string; java.text.Normalizer.Form currentForm = formValues.get(formComboBox.getSelectedItem()); normalized_string = Normalizer.normalize(original_string, currentForm); g2.drawString(normalized_string, 320, 120); } }; setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); add(paintingComponent); JPanel controls = new JPanel(); controls.setLayout(new BoxLayout(controls, BoxLayout.X_AXIS)); controls.add(new Label("Normalization Form: ")); controls.add(formComboBox); controls.add(new Label("Normalization Template:")); controls.add(normalizationTemplate); add(controls); formComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { paintingComponent.repaint(); } }); normalizationTemplate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { paintingComponent.repaint(); } }); }
From source file:com.ethercamp.harmony.desktop.HarmonyDesktop.java
private void showErrorWindow(String title, String body) { try {//from w w w. j a va 2 s . c o m UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); // System.setProperty("apple.awt.UIElement", "false"); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JTextArea textArea = new JTextArea(body); JScrollPane scrollPane = new JScrollPane(textArea); textArea.setLineWrap(true); textArea.setFont(Font.getFont(Font.MONOSPACED)); textArea.setEditable(false); textArea.setWrapStyleWord(true); scrollPane.setPreferredSize(new Dimension(500, 500)); JTextPane titleLabel = new JTextPane(); titleLabel.setContentType("text/html"); // let the text pane know this is what you want titleLabel.setText("<html>" + "<b>" + title + "</b>" + "</html>"); // showing off titleLabel.setEditable(false); titleLabel.setBackground(null); titleLabel.setBorder(null); panel.add(titleLabel); panel.add(scrollPane); final JFrame frame = new JFrame(); frame.setAlwaysOnTop(true); moveCenter(frame); frame.setVisible(true); JOptionPane.showMessageDialog(frame, panel, "Oops. Ethereum Harmony stopped with error.", JOptionPane.CLOSED_OPTION); System.exit(1); } catch (Exception e) { log.error("Problem showing error window", e); } }
From source file:QandE.LunarPhasesRB.java
private void addWidgets() { /*//from ww w . j a v a 2 s. c om * Create a label for displaying the moon phase images and * put a border around it. */ phaseIconLabel = new JLabel(); phaseIconLabel.setHorizontalAlignment(JLabel.CENTER); phaseIconLabel.setVerticalAlignment(JLabel.CENTER); phaseIconLabel.setVerticalTextPosition(JLabel.CENTER); phaseIconLabel.setHorizontalTextPosition(JLabel.CENTER); phaseIconLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5))); phaseIconLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0), phaseIconLabel.getBorder())); //Create radio buttons with lunar phase choices. JRadioButton newButton = new JRadioButton("New"); newButton.setActionCommand("0"); newButton.setSelected(true); JRadioButton waxingCrescentButton = new JRadioButton("Waxing Crescent"); waxingCrescentButton.setActionCommand("1"); JRadioButton firstQuarterButton = new JRadioButton("First Quarter"); firstQuarterButton.setActionCommand("2"); JRadioButton waxingGibbousButton = new JRadioButton("Waxing Gibbous"); waxingGibbousButton.setActionCommand("3"); JRadioButton fullButton = new JRadioButton("Full"); fullButton.setActionCommand("4"); JRadioButton waningGibbousButton = new JRadioButton("Waning Gibbous"); waningGibbousButton.setActionCommand("5"); JRadioButton thirdQuarterButton = new JRadioButton("Third Quarter"); thirdQuarterButton.setActionCommand("6"); JRadioButton waningCrescentButton = new JRadioButton("Waning Crescent"); waningCrescentButton.setActionCommand("7"); // Create a button group and add the radio buttons. ButtonGroup group = new ButtonGroup(); group.add(newButton); group.add(waxingCrescentButton); group.add(firstQuarterButton); group.add(waxingGibbousButton); group.add(fullButton); group.add(waningGibbousButton); group.add(thirdQuarterButton); group.add(waningCrescentButton); // Display the first image. phaseIconLabel.setIcon(new ImageIcon("images/image0.jpg")); phaseIconLabel.setText(""); //Make the radio buttons appear in a center-aligned column. selectPanel.setLayout(new BoxLayout(selectPanel, BoxLayout.PAGE_AXIS)); selectPanel.setAlignmentX(Component.CENTER_ALIGNMENT); //Add a border around the select panel. selectPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Select Phase"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Add a border around the display panel. displayPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Display Phase"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Add image and moon phases radio buttons to select panel. displayPanel.add(phaseIconLabel); selectPanel.add(newButton); selectPanel.add(waxingCrescentButton); selectPanel.add(firstQuarterButton); selectPanel.add(waxingGibbousButton); selectPanel.add(fullButton); selectPanel.add(waningGibbousButton); selectPanel.add(thirdQuarterButton); selectPanel.add(waningCrescentButton); //Listen to events from the radio buttons. newButton.addActionListener(this); waxingCrescentButton.addActionListener(this); firstQuarterButton.addActionListener(this); waxingGibbousButton.addActionListener(this); fullButton.addActionListener(this); waningGibbousButton.addActionListener(this); thirdQuarterButton.addActionListener(this); waningCrescentButton.addActionListener(this); }
From source file:net.mitnet.tools.pdf.book.publisher.ui.gui.BookPublisherGUI2.java
/** * Initialise widgets./*w ww . j a va 2 s .c o m*/ */ protected void initComponents() { // frame this.frame = new JFrame(); this.frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.frame.setTitle(FRAME_TITLE); // input dir panel inputDirLabel = new JLabel(); inputDirLabel.setText("Input Folder:"); inputDirField = new JTextField(); inputDirField.setColumns(FILE_TEXTFIELD_WIDTH); inputDirButton = new JButton(); inputDirButton.setText("Browse ..."); inputDirButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { inputDirButtonActionHandler(event); } }); JPanel inputDirPanel = new JPanel(); // inputDirPanel.setLayout( new BoxLayout( inputDirPanel, BoxLayout.X_AXIS ) ); inputDirPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); inputDirPanel.add(inputDirLabel); inputDirPanel.add(inputDirField); inputDirPanel.add(inputDirButton); // output dir panel outputDirLabel = new JLabel(); outputDirLabel.setText("Output Folder:"); outputDirField = new JTextField(); outputDirField.setColumns(FILE_TEXTFIELD_WIDTH); outputDirButton = new JButton(); outputDirButton.setText("Browse ..."); outputDirButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { outputDirButtonActionHandler(event); } }); JPanel outputDirPanel = new JPanel(); // outputDirPanel.setLayout( new BoxLayout( outputDirPanel, BoxLayout.X_AXIS ) ); outputDirPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); outputDirPanel.add(outputDirLabel); outputDirPanel.add(outputDirField); outputDirPanel.add(outputDirButton); // document control panel docControlPanel = new JPanel(); docControlPanel.setLayout(new BoxLayout(docControlPanel, BoxLayout.Y_AXIS)); docControlPanel.add(inputDirPanel); docControlPanel.add(outputDirPanel); // Border docControlPanelBorder = BorderFactory.createTitledBorder("Documents"); Border docControlPanelBorder = BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Documents"), BorderFactory.createEmptyBorder(5, 5, 5, 5)); docControlPanel.setBorder(docControlPanelBorder); // publish button publishButton = new JButton(); publishButton.setText("Publish"); publishButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { publishButtonActionHandler(event); } }); // status message label statusMessageLabel = new JLabel(); // String statusMessageText = "Press " + publishButton.getText() + " to start."; String statusMessageText = ""; statusMessageLabel.setText(statusMessageText); // statusMessageLabel.setVisible(false); // progress bar progressBar = new JProgressBar(); // exit button exitButton = new JButton(); exitButton.setText("Exit"); exitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { exitButtonActionHandler(event); } }); // build main panel JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.add(docControlPanel); // mainPanel.add(new Spacer()); mainPanel.add(publishButton); // mainPanel.add(new Spacer()); mainPanel.add(progressBar); // mainPanel.add(new Spacer()); mainPanel.add(statusMessageLabel); // mainPanel.add(new Spacer()); mainPanel.add(exitButton); // add main panel to frame this.frame.getContentPane().setLayout(new BoxLayout(this.frame.getContentPane(), BoxLayout.Y_AXIS)); this.frame.getContentPane().add(mainPanel); // this.frame.setSize(800,600); this.frame.pack(); }
From source file:org.streamspinner.harmonica.application.CQGraphTerminal.java
private JPanel getJPanel2() { if (jPanel2 != null) return jPanel2; jPanel2 = new JPanel(); jPanel2.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)); jPanel2.setLayout(new BoxLayout(jPanel2, BoxLayout.LINE_AXIS)); jPanel2.add(getJScrollPane1());/*from w w w .j a va 2s.co m*/ jPanel2.setBackground(Color.RED); return jPanel2; }
From source file:edu.ucla.stat.SOCR.chart.SuperXYChart.java
protected void setChart() { // update graph // System.out.println("setChart called"); graphPanel.removeAll();//from w ww .j a va 2s.c om 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/5,CHART_SIZE_Y*2/5)); graphPanel2.add(chartPanel); if (legendPanelOn) { legendPane = new JScrollPane(legendPanel); legendPane.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 5, CHART_SIZE_Y * 2 / 5)); graphPanel2.add(legendPane); } graphPanel2.validate(); summaryPanel.validate(); } }
From source file:es.emergya.ui.gis.popups.RouteDialog.java
private RouteDialog() { super();//from w w w . ja v a2 s . c om setAlwaysOnTop(true); setResizable(false); iconTransparente = LogicConstants.getIcon("48x48_transparente"); iconEnviando = LogicConstants.getIcon("anim_calculando"); try { route = new OsmDataLayer(new DataSet(), "route", File.createTempFile("route", "route")); } catch (IOException e) { log.error(e.getMessage(), e); } setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { clear.doClick(); setVisible(false); } }); setTitle(i18n.getString("window.route.titleBar")); setMinimumSize(new Dimension(400, 200)); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } JPanel base = new JPanel(); base.setBackground(Color.WHITE); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); // Icono del titulo JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); title.setOpaque(false); final JLabel labelTitle = new JLabel(i18n.getString("window.route.title"), LogicConstants.getIcon("tittleventana_icon_calcularruta"), JLabel.LEFT); labelTitle.setFont(LogicConstants.deriveBoldFont(12.0f)); title.add(labelTitle); base.add(title); JPanel content = new JPanel(new SpringLayout()); content.setOpaque(false); // Coordenadas content.add(new JLabel(i18n.getString("window.route.origen"), JLabel.LEFT)); JPanel coords = new JPanel(new GridLayout(1, 2)); coords.setOpaque(false); fx = new JTextField(8); fx.setEditable(false); fy = new JTextField(8); fy.setEditable(false); coords.add(fy); coords.add(fx); content.add(coords); content.add(new JLabel(i18n.getString("window.route.destino"), JLabel.LEFT)); JPanel coords2 = new JPanel(new GridLayout(1, 2)); coords2.setOpaque(false); tx = new JTextField(8); tx.setEditable(false); ty = new JTextField(8); ty.setEditable(false); coords2.add(ty); coords2.add(tx); content.add(coords2); SpringUtilities.makeCompactGrid(content, 2, 2, 6, 6, 6, 6); base.add(content); // Area para mensajes JPanel notificationArea = new JPanel(); notificationArea.setOpaque(false); notification = new JLabel("PLACEHOLDER"); notification.setForeground(Color.WHITE); notificationArea.add(notification); base.add(notificationArea); JPanel buttons = new JPanel(); buttons.setOpaque(false); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); search = new JButton(i18n.getString("window.route.calcular"), LogicConstants.getIcon("ventanacontextual_button_calcularruta")); search.addActionListener(this); buttons.add(search); clear = new JButton(i18n.getString("window.route.limpiar"), LogicConstants.getIcon("button_limpiar")); clear.addActionListener(this); buttons.add(clear); buttons.add(Box.createHorizontalGlue()); progressIcon = new JLabel(iconTransparente); buttons.add(progressIcon); buttons.add(Box.createHorizontalGlue()); JButton cancel = new JButton(i18n.getString("Buttons.cancel"), LogicConstants.getIcon("button_cancel")); cancel.addActionListener(this); buttons.add(cancel); base.add(buttons); getContentPane().add(base); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) x = ((parentSize.width - mySize.width) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > mySize.height) y = ((parentSize.height - mySize.height) / 2) + topLeft.y; else y = topLeft.y; setLocation(x, y); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } }
From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.ADAP3DecompositionV2SetupDialog.java
/** Creates the interface elements */ @Override/*from ww w.jav a 2s. c o m*/ protected void addDialogComponents() { super.addDialogComponents(); comboClustersModel = new DefaultComboBoxModel<>(); PeakList[] peakLists = MZmineCore.getDesktop().getSelectedPeakLists(); // ----------------------------- // Panel with preview UI elements // ----------------------------- // Preview CheckBox chkPreview = new JCheckBox("Show preview"); chkPreview.addActionListener(this); chkPreview.setHorizontalAlignment(SwingConstants.CENTER); chkPreview.setEnabled(peakLists != null && peakLists.length > 0); // Preview panel that will contain ComboBoxes final JPanel panel = new JPanel(new BorderLayout()); panel.add(new JSeparator(), BorderLayout.NORTH); panel.add(chkPreview, BorderLayout.CENTER); panel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH); pnlUIElements = new JPanel(new BorderLayout()); pnlUIElements.add(panel, BorderLayout.NORTH); // ComboBox with Clusters cboClusters = new JComboBox<>(comboClustersModel); cboClusters.setFont(COMBO_FONT); cboClusters.addActionListener(this); pnlComboBoxes = GUIUtils.makeTablePanel(1, 2, new JComponent[] { new JLabel("Clusters"), cboClusters }); // -------------------------------------------------------------------- // ----- Panel with plots -------------------------------------- // -------------------------------------------------------------------- pnlPlots = new JPanel(); pnlPlots.setLayout(new BoxLayout(pnlPlots, BoxLayout.Y_AXIS)); // Plot with retention-time clusters retTimeMZPlot = new SimpleScatterPlot("Retention time", "m/z"); retTimeMZPlot.setMinimumSize(MIN_DIMENSIONS); final JPanel pnlPlotRetTimeClusters = new JPanel(new BorderLayout()); pnlPlotRetTimeClusters.setBackground(Color.white); pnlPlotRetTimeClusters.add(retTimeMZPlot, BorderLayout.CENTER); GUIUtils.addMarginAndBorder(pnlPlotRetTimeClusters, 10); // Plot with chromatograms retTimeIntensityPlot = new EICPlot(); retTimeIntensityPlot.setMinimumSize(MIN_DIMENSIONS); JPanel pnlPlotShapeClusters = new JPanel(new BorderLayout()); pnlPlotShapeClusters.setBackground(Color.white); pnlPlotShapeClusters.add(retTimeIntensityPlot, BorderLayout.CENTER); GUIUtils.addMarginAndBorder(pnlPlotShapeClusters, 10); pnlPlots.add(pnlPlotRetTimeClusters); pnlPlots.add(pnlPlotShapeClusters); super.mainPanel.add(pnlUIElements, 0, super.getNumberOfParameters() + 3, 2, 1, 0, 0, GridBagConstraints.HORIZONTAL); }
From source file:davmail.ui.SettingsFrame.java
protected void addPortSettingComponent(JPanel panel, String label, JComponent component, JComponent checkboxComponent, JComponent checkboxSSLComponent, String toolTipText) { JLabel fieldLabel = new JLabel(label); fieldLabel.setHorizontalAlignment(SwingConstants.RIGHT); fieldLabel.setVerticalAlignment(SwingConstants.CENTER); panel.add(fieldLabel);/*from www. j a v a 2 s . c om*/ component.setMaximumSize(component.getPreferredSize()); JPanel innerPanel = new JPanel(); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS)); innerPanel.add(checkboxComponent); innerPanel.add(component); innerPanel.add(checkboxSSLComponent); panel.add(innerPanel); if (toolTipText != null) { fieldLabel.setToolTipText(toolTipText); component.setToolTipText(toolTipText); } }