List of usage examples for javax.swing Box createVerticalStrut
public static Component createVerticalStrut(int height)
From source file:Main.java
public JPanel createUI() { intro.setLabelFor(name);// w ww. j av a 2s . c om final JButton button = new JButton("Pick a new name..."); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 20)); intro.setAlignmentX(JComponent.CENTER_ALIGNMENT); name.setAlignmentX(JComponent.CENTER_ALIGNMENT); button.setAlignmentX(JComponent.CENTER_ALIGNMENT); panel.add(intro); panel.add(Box.createVerticalStrut(5)); panel.add(name); panel.add(Box.createRigidArea(new Dimension(150, 10))); panel.add(button); return panel; }
From source file:TextureByReference.java
public JPanel buildGui() { flipB = new JCheckBox("flip image", true); flipB.addItemListener(this); javax.swing.Box flipBox = new javax.swing.Box(BoxLayout.Y_AXIS); flipBox.add(flipB);//from w w w .j a v a 2 s. com Component strut1 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); Component strut2 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); Component strut3 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); Component strut4 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); Component strut5 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); flipBox.add(strut1); flipBox.add(strut2); flipBox.add(strut3); flipBox.add(strut4); flipBox.add(strut5); yUp = new JRadioButton("y up"); yUp.addActionListener(this); yUp.setSelected(true); yDown = new JRadioButton("y down"); yDown.addActionListener(this); ButtonGroup yGroup = new ButtonGroup(); yGroup.add(yUp); yGroup.add(yDown); JLabel yLabel = new JLabel("Image Orientation:"); javax.swing.Box yBox = new javax.swing.Box(BoxLayout.Y_AXIS); yBox.add(yLabel); yBox.add(yUp); yBox.add(yDown); strut1 = yBox.createVerticalStrut(yUp.getPreferredSize().height); strut2 = yBox.createVerticalStrut(yUp.getPreferredSize().height); strut3 = yBox.createVerticalStrut(yUp.getPreferredSize().height); yBox.add(strut1); yBox.add(strut2); yBox.add(strut3); texByRef = new JRadioButton("by reference"); texByRef.addActionListener(this); texByRef.setSelected(true); texByCopy = new JRadioButton("by copy"); texByCopy.addActionListener(this); ButtonGroup texGroup = new ButtonGroup(); texGroup.add(texByRef); texGroup.add(texByCopy); JLabel texLabel = new JLabel("Texture:*"); javax.swing.Box texBox = new javax.swing.Box(BoxLayout.Y_AXIS); texBox.add(texLabel); texBox.add(texByRef); texBox.add(texByCopy); strut1 = texBox.createVerticalStrut(texByRef.getPreferredSize().height); strut2 = texBox.createVerticalStrut(texByRef.getPreferredSize().height); strut3 = texBox.createVerticalStrut(texByRef.getPreferredSize().height); texBox.add(strut1); texBox.add(strut2); texBox.add(strut3); geomByRef = new JRadioButton("by reference"); geomByRef.addActionListener(this); geomByRef.setSelected(true); geomByCopy = new JRadioButton("by copy"); geomByCopy.addActionListener(this); ButtonGroup geomGroup = new ButtonGroup(); geomGroup.add(geomByRef); geomGroup.add(geomByCopy); JLabel geomLabel = new JLabel("Geometry:"); javax.swing.Box geomBox = new javax.swing.Box(BoxLayout.Y_AXIS); geomBox.add(geomLabel); geomBox.add(geomByRef); geomBox.add(geomByCopy); strut1 = geomBox.createVerticalStrut(geomByRef.getPreferredSize().height); strut2 = geomBox.createVerticalStrut(geomByRef.getPreferredSize().height); strut3 = geomBox.createVerticalStrut(geomByRef.getPreferredSize().height); geomBox.add(strut1); geomBox.add(strut2); geomBox.add(strut3); img4ByteABGR = new JRadioButton("TYPE_4BYTE_ABGR"); img4ByteABGR.addActionListener(this); img4ByteABGR.setSelected(true); img3ByteBGR = new JRadioButton("TYPE_3BYTE_BGR"); img3ByteBGR.addActionListener(this); imgIntARGB = new JRadioButton("TYPE_INT_ARGB"); imgIntARGB.addActionListener(this); imgCustomRGBA = new JRadioButton("TYPE_CUSTOM RGBA"); imgCustomRGBA.addActionListener(this); imgCustomRGB = new JRadioButton("TYPE_CUSTOM RGB"); imgCustomRGB.addActionListener(this); ButtonGroup imgGroup = new ButtonGroup(); imgGroup.add(img4ByteABGR); imgGroup.add(img3ByteBGR); imgGroup.add(imgIntARGB); imgGroup.add(imgCustomRGBA); imgGroup.add(imgCustomRGB); JLabel imgLabel = new JLabel("Image Type:*"); javax.swing.Box imgBox = new javax.swing.Box(BoxLayout.Y_AXIS); imgBox.add(imgLabel); imgBox.add(img4ByteABGR); imgBox.add(img3ByteBGR); imgBox.add(imgIntARGB); imgBox.add(imgCustomRGBA); imgBox.add(imgCustomRGB); javax.swing.Box topBox = new javax.swing.Box(BoxLayout.X_AXIS); topBox.add(flipBox); topBox.add(texBox); topBox.add(geomBox); topBox.add(yBox); Component strut = topBox.createRigidArea(new Dimension(10, 10)); topBox.add(strut); topBox.add(imgBox); frameDelay = new JSlider(0, 50, 0); frameDelay.addChangeListener(this); frameDelay.setSnapToTicks(true); frameDelay.setPaintTicks(true); frameDelay.setPaintLabels(true); frameDelay.setMajorTickSpacing(10); frameDelay.setMinorTickSpacing(1); frameDelay.setValue(20); JLabel delayL = new JLabel("frame delay"); javax.swing.Box delayBox = new javax.swing.Box(BoxLayout.X_AXIS); delayBox.add(delayL); delayBox.add(frameDelay); animationB = new JButton(" stop animation "); animationB.addActionListener(this); JLabel texInfo1 = new JLabel("*To use ImageComponent by reference feature, use TYPE_4BYTE_ABGR on Solaris"); JLabel texInfo2 = new JLabel("and TYPE_3BYTE_BGR on Windows"); JPanel buttonP = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); buttonP.setLayout(gridbag); c.anchor = GridBagConstraints.CENTER; c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(topBox, c); buttonP.add(topBox); gridbag.setConstraints(delayBox, c); buttonP.add(delayBox); gridbag.setConstraints(animationB, c); buttonP.add(animationB); gridbag.setConstraints(texInfo1, c); buttonP.add(texInfo1); gridbag.setConstraints(texInfo2, c); buttonP.add(texInfo2); return buttonP; }
From source file:uk.ac.ebi.demo.picr.swing.PICRBLASTDemo.java
public PICRBLASTDemo() { //set general layout setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); add(Box.createVerticalStrut(5)); //create components JPanel row1 = new JPanel(); row1.setLayout(new BoxLayout(row1, BoxLayout.X_AXIS)); row1.add(Box.createHorizontalStrut(5)); row1.setBorder(BorderFactory.createTitledBorder("")); row1.add(new JLabel("Fragment:")); row1.add(Box.createHorizontalStrut(10)); final JTextArea sequenceArea = new JTextArea(5, 40); sequenceArea.setMaximumSize(sequenceArea.getPreferredSize()); row1.add(Box.createHorizontalStrut(10)); row1.add(sequenceArea);/*from w w w . j av a 2 s . c o m*/ row1.add(Box.createHorizontalGlue()); JPanel row2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); row2.setBorder(BorderFactory.createTitledBorder("Target Databases")); final JList databaseList = new JList(); JScrollPane listScroller = new JScrollPane(databaseList); listScroller.setMaximumSize(new Dimension(100, 10)); JButton loadDBButton = new JButton("Load Databases"); row2.add(listScroller); row2.add(loadDBButton); JPanel row3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); JCheckBox onlyActiveCheckBox = new JCheckBox("Only Active"); onlyActiveCheckBox.setSelected(true); row3.add(new JLabel("Options: ")); row3.add(onlyActiveCheckBox); add(row1); add(row2); add(row3); final String[] columns = new String[] { "Database", "Accession", "Version", "Taxon ID" }; final JTable dataTable = new JTable(new Object[0][0], columns); dataTable.setShowGrid(true); add(new JScrollPane(dataTable)); JPanel buttonPanel = new JPanel(); JButton mapAccessionButton = new JButton("Generate Mapping!"); buttonPanel.add(mapAccessionButton); add(buttonPanel); //create listeners! //update boolean flag in communication class onlyActiveCheckBox.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { client.setOnlyActive(((JCheckBox) e.getSource()).isSelected()); } }); //performs mapping call and updates interface with results mapAccessionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (!"".equals(sequenceArea.getText())) { //TODO filters and database are hardcoded here. They should be added to the input panel at a later revision. java.util.List<UPEntry> entries = client.performBlastMapping(sequenceArea.getText(), databaseList.getSelectedValues(), "90", "", "IDENTITY", "UniprotKB", "", false, new BlastParameter()); //compute size of array if (entries != null) { int size = 0; for (UPEntry entry : entries) { for (CrossReference xref : entry.getIdenticalCrossReferences()) { size++; } for (CrossReference xref : entry.getLogicalCrossReferences()) { size++; } } if (size > 0) { final Object[][] data = new Object[size][4]; int i = 0; for (UPEntry entry : entries) { for (CrossReference xref : entry.getIdenticalCrossReferences()) { data[i][0] = xref.getDatabaseName(); data[i][1] = xref.getAccession(); data[i][2] = xref.getAccessionVersion(); data[i][3] = xref.getTaxonId(); i++; } for (CrossReference xref : entry.getLogicalCrossReferences()) { data[i][0] = xref.getDatabaseName(); data[i][1] = xref.getAccession(); data[i][2] = xref.getAccessionVersion(); data[i][3] = xref.getTaxonId(); i++; } } //refresh DefaultTableModel dataModel = new DefaultTableModel(); dataModel.setDataVector(data, columns); dataTable.setModel(dataModel); System.out.println("update done"); } else { JOptionPane.showMessageDialog(null, "No Mappind data found."); } } else { JOptionPane.showMessageDialog(null, "No Mappind data found."); } } else { JOptionPane.showMessageDialog(null, "You must enter a valid FASTA sequence to map."); } } catch (SOAPFaultException soapEx) { JOptionPane.showMessageDialog(null, "A SOAP Error occurred."); soapEx.printStackTrace(); } } }); //loads list of mapping databases from communication class loadDBButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { java.util.List<String> databases = client.loadDatabases(); if (databases != null && databases.size() > 0) { databaseList.setListData(databases.toArray()); System.out.println("database refresh done"); } else { JOptionPane.showMessageDialog(null, "No Databases Loaded!."); } } catch (SOAPFaultException soapEx) { JOptionPane.showMessageDialog(null, "A SOAP Error occurred."); soapEx.printStackTrace(); } } }); }
From source file:org.swiftexplorer.gui.AboutDlg.java
public static void show(Component parent, HasLocalizedStrings stringsBundle) { URI uri = null;// w w w .ja v a 2s . c o m try { uri = new URI("http://www.swiftexplorer.org"); } catch (URISyntaxException e) { logger.error("URL seems to be ill-formed", e); } final String buttontext = "www.swiftexplorer.org"; Box mainBox = Box.createVerticalBox(); mainBox.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); StringBuilder sb = loadResource("/about.html"); JLabel label = new JLabel(sb.toString()); label.getAccessibleContext().setAccessibleDescription(getTitle(stringsBundle)); mainBox.add(label); if (uri != null) { JButton button = new JButton(); button.setText(buttontext); button.setToolTipText(uri.toString()); button.addActionListener(new OpenUrlAction(uri)); FontMetrics metrics = button.getFontMetrics(button.getFont()); if (metrics != null) button.setSize(metrics.stringWidth(buttontext), button.getHeight()); button.getAccessibleContext().setAccessibleDescription(buttontext); mainBox.add(button); } mainBox.add(Box.createVerticalStrut(10)); JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); panel.add(mainBox); JOptionPane.showMessageDialog(parent, panel, getTitle(stringsBundle), JOptionPane.INFORMATION_MESSAGE, getIcon()); }
From source file:Demo.LineGraph.java
public LineGraph(int sampleNb) { this.sampleNb = sampleNb; InitDataSet();/*from w w w. j a v a 2 s . c om*/ InitChart(); // layout setLayout(new BorderLayout()); add(Box.createHorizontalStrut(30), BorderLayout.WEST); add(Box.createHorizontalStrut(30), BorderLayout.EAST); add(Box.createVerticalStrut(30), BorderLayout.NORTH); add(chartPane, BorderLayout.CENTER); }
From source file:com.game.ui.views.UserDialog.java
public UserDialog(String message, JFrame frame) { setLayout(new BorderLayout(5, 5)); setModalityType(ModalityType.APPLICATION_MODAL); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setResizable(false);/*from w w w .j ava2s . c o m*/ ImageIcon icon = null; try { icon = GameUtils.shrinkImage("warning.gif", 30, 30); } catch (IOException e) { System.out.println("Dialog : showDialogForMap(): Exception occured :" + e); e.printStackTrace(); } JPanel panel = new JPanel(); JLabel label = new JLabel(icon); panel.setLayout(new FlowLayout(FlowLayout.LEFT)); label.setText(message); label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); label.setHorizontalAlignment(0); panel.add(label); add(panel, BorderLayout.NORTH); JPanel contentPanel = new JPanel(); contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS)); txt = new JTextField(); txt.setPreferredSize(new Dimension(150, 30)); txt.setAlignmentX(.5f); txt.setMaximumSize(new Dimension(150, 30)); contentPanel.add(txt); contentPanel.add(Box.createVerticalStrut(10)); JButton btn = new JButton("Submit."); btn.setAlignmentX(.5f); btn.setPreferredSize(new Dimension(50, 25)); btn.addActionListener(this); validationMess = new JLabel("All fields are mandatory"); validationMess.setVisible(false); validationMess.setForeground(Color.red); validationMess.setAlignmentX(.5f); contentPanel.add(btn); contentPanel.add(Box.createVerticalStrut(10)); contentPanel.add(validationMess); contentPanel.add(Box.createVerticalGlue()); add(contentPanel, BorderLayout.CENTER); pack(); setSize(new Dimension(300, 200)); setLocationRelativeTo(frame); setVisible(true); }
From source file:CommonLayouts.java
public CommonLayouts() { super("Common Layout Managers"); setSize(500, 380);//w ww. ja v a 2 s. c o m JPanel desktop = new JPanel(); getContentPane().add(desktop); JPanel fr1 = new JPanel(); fr1.setBorder(new TitledBorder("FlowLayout")); fr1.setLayout(new FlowLayout()); fr1.add(new JButton("1")); fr1.add(new JButton("2")); fr1.add(new JButton("3")); fr1.add(new JButton("4")); desktop.add(fr1, 0); JPanel fr2 = new JPanel(); fr2.setBorder(new TitledBorder("GridLayout")); fr2.setLayout(new GridLayout(2, 2)); fr2.add(new JButton("1")); fr2.add(new JButton("2")); fr2.add(new JButton("3")); fr2.add(new JButton("4")); desktop.add(fr2, 0); JPanel fr3 = new JPanel(); fr3.setBorder(new TitledBorder("BorderLayout")); fr3.add(new JButton("1"), BorderLayout.NORTH); fr3.add(new JButton("2"), BorderLayout.EAST); fr3.add(new JButton("3"), BorderLayout.SOUTH); fr3.add(new JButton("4"), BorderLayout.WEST); desktop.add(fr3, 0); JPanel fr4 = new JPanel(); fr4.setBorder(new TitledBorder("BoxLayout - X")); fr4.setLayout(new BoxLayout(fr4, BoxLayout.X_AXIS)); fr4.add(new JButton("1")); fr4.add(Box.createHorizontalStrut(12)); fr4.add(new JButton("2")); fr4.add(Box.createGlue()); fr4.add(new JButton("3")); fr4.add(Box.createHorizontalGlue()); fr4.add(new JButton("4")); desktop.add(fr4, 0); JPanel fr5 = new JPanel(); fr5.setBorder(new TitledBorder("BoxLayout - Y")); fr5.setLayout(new BoxLayout(fr5, BoxLayout.Y_AXIS)); fr5.add(new JButton("1")); fr5.add(Box.createVerticalStrut(10)); fr5.add(new JButton("2")); fr5.add(Box.createGlue()); fr5.add(new JButton("3")); fr5.add(Box.createVerticalGlue()); fr5.add(new JButton("4")); desktop.add(fr5, 0); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:components.ListDialogRunner.java
public static JPanel createUI() { //Create the labels. JLabel intro = new JLabel("The chosen name:"); final JLabel name = new JLabel(names[1]); intro.setLabelFor(name);/*from w ww. j a va2 s .c o m*/ //Use a wacky font if it exists. If not, this falls //back to a font we know exists. name.setFont(getAFont()); //Create the button. final JButton button = new JButton("Pick a new name..."); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String selectedName = ListDialog.showDialog(frame, button, "Baby names ending in O:", "Name Chooser", names, name.getText(), "Cosmo "); name.setText(selectedName); } }); //Create the panel we'll return and set up the layout. JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 20)); intro.setAlignmentX(JComponent.CENTER_ALIGNMENT); name.setAlignmentX(JComponent.CENTER_ALIGNMENT); button.setAlignmentX(JComponent.CENTER_ALIGNMENT); //Add the labels to the content pane. panel.add(intro); panel.add(Box.createVerticalStrut(5)); //extra space panel.add(name); //Add a vertical spacer that also guarantees us a minimum width: panel.add(Box.createRigidArea(new Dimension(150, 10))); //Add the button. panel.add(button); return panel; }
From source file:BoxLayoutTest.java
public Box createBox(boolean horizontal, boolean strutsAndGlue) { Box b;/*from w ww.j a v a2 s . c o m*/ if (horizontal) b = Box.createHorizontalBox(); else b = Box.createVerticalBox(); b.add(new JLabel("Name: ")); b.add(new JTextField()); if (strutsAndGlue) if (horizontal) b.add(Box.createHorizontalStrut(5)); else b.add(Box.createVerticalStrut(5)); b.add(new JLabel("Password: ")); b.add(new JTextField()); if (strutsAndGlue) b.add(Box.createGlue()); b.add(new JButton("Ok")); return b; }
From source file:org.neo4j.desktop.ui.Components.java
static Component createVerticalSpacing() { return Box.createVerticalStrut(BASE_SPACING_SIZE); }