List of usage examples for javax.swing BoxLayout Y_AXIS
int Y_AXIS
To view the source code for javax.swing BoxLayout Y_AXIS.
Click Source Link
From source file:com.opendoorlogistics.components.reports.ReporterPanel.java
public ReporterPanel(final ComponentConfigurationEditorAPI api, final ReporterConfig config) { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // setAlignmentX(LEFT_ALIGNMENT); // add config panel ReporterConfigPanel configPanel = new ReporterConfigPanel(config); configPanel.setBorder(createBorder("Export and processing options")); add(configPanel);/*from w w w . java 2s .c om*/ // add gap add(Box.createRigidArea(new Dimension(1, 10))); // add tools panel JPanel toolContainer = new JPanel(); toolContainer.setLayout(new BorderLayout()); toolContainer.setBorder(createBorder("Tools")); add(toolContainer); JPanel tools = new JPanel(); toolContainer.add(tools, BorderLayout.NORTH); toolContainer.setMaximumSize(new Dimension(Integer.MAX_VALUE, api.isInstruction() ? 120 : 80)); // tools.setLayout(new BoxLayout(tools, BoxLayout.X_AXIS)); tools.setLayout(new GridLayout(api == null || api.isInstruction() ? 2 : 1, 3)); JButton compileButton = new JButton("Compile .jrxml file"); compileButton.setToolTipText("Compile a JasperReports .jrxml file"); compileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { File file = ReporterTools.chooseJRXMLFile(api.getComponentPreferences(), LAST_JRXML_TO_COMPILE, ReporterPanel.this); if (file == null) { return; } final ExecutionReport report = api.getApi().uiFactory().createExecutionReport(); try { JasperDesign design = JRXmlLoader.load(file); if (design == null) { throw new RuntimeException("File to load jrxml: " + file.getAbsolutePath()); } String filename = FilenameUtils.removeExtension(file.getAbsolutePath()) + ".jasper"; JasperCompileManager.compileReportToFile(design, filename); } catch (Throwable e2) { report.setFailed(e2); report.setFailed("Failed to compile file " + file.getAbsolutePath()); } finally { if (report.isFailed()) { Window window = SwingUtilities.getWindowAncestor(ReporterPanel.this); api.getApi().uiFactory() .createExecutionReportDialog( JFrame.class.isInstance(window) ? (JFrame) window : null, "Compiling jrxml file", report, true) .setVisible(true); } else { JOptionPane.showMessageDialog(ReporterPanel.this, "Compiled jxrml successfully: " + file.getAbsolutePath()); } } } }); tools.add(compileButton); for (final OrientationEnum orientation : new OrientationEnum[] { OrientationEnum.LANDSCAPE, OrientationEnum.PORTRAIT }) { // create export button JButton button = new JButton("Export " + orientation.getName().toLowerCase() + " template"); button.setToolTipText( "Export template (editable .jrxml and compiled .jasper) based on the input tables (" + orientation.getName().toLowerCase() + ")"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ReporterTools.exportReportTemplate(api, config, orientation, ReporterPanel.this); } }); tools.add(button); // create view button if (api.isInstruction()) { final String title = "View basic " + orientation.getName().toLowerCase() + " report"; button = new JButton(title); button.setToolTipText("View basic report based on the input tables (" + orientation.getName().toLowerCase() + ")"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (api != null) { api.executeInPlace(title, orientation == OrientationEnum.LANDSCAPE ? ReporterComponent.VIEW_BASIC_LANDSCAPE : ReporterComponent.VIEW_BASIC_PORTRAIT); } } }); tools.add(button); } } }
From source file:MultiLineLabel.java
/** ** Constructor - make a multiline label **///from w w w.java 2 s . c o m public MultiLineLabel(String text, float alignment) { this.alignment = alignment; setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); if (text != null) setText(text); }
From source file:com.game.ui.views.CharachterEditorPanel.java
public void doGui() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JLabel noteLbl = new JLabel("Pls select a value to choose an enemy or you can create a new " + "Enemy entity below. Once selected an Enemy character, its' details will be available below"); noteLbl.setAlignmentX(0);/*from ww w. j a v a2s . co m*/ // noteLbl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(noteLbl); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (GameCharacter character : GameBean.enemyDetails) { System.out.println(character.getName()); model.addElement(character.getName()); } comboBox = new JComboBox(model); comboBox.setSelectedIndex(-1); comboBox.setMaximumSize(new Dimension(100, 30)); comboBox.setAlignmentX(0); comboBox.setActionCommand("dropDown"); comboBox.addActionListener(this); add(Box.createVerticalStrut(10)); add(comboBox); add(Box.createVerticalStrut(10)); JPanel panel1 = new JPanel(); panel1.setAlignmentX(0); panel1.setBorder(LineBorder.createGrayLineBorder()); panel1.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(5, 5, 5, 5); c.weightx = 1; c.weighty = 1; c.gridwidth = 2; JLabel enemyDtlLbl = new JLabel("Enemy Character Details : "); enemyDtlLbl.setFont(new Font("Times New Roman", Font.BOLD, 15)); panel1.add(enemyDtlLbl, c); c.gridwidth = 1; c.gridy = 1; JLabel nameLbl = new JLabel("Name : "); panel1.add(nameLbl, c); c.gridx = 1; JTextField name = new JTextField(""); name.setColumns(20); panel1.add(name, c); c.gridx = 0; c.gridy = 2; JLabel imageLbl = new JLabel("Image Path : "); panel1.add(imageLbl, c); c.gridx = 1; JTextField image = new JTextField(""); image.setColumns(20); panel1.add(image, c); c.gridx = 0; c.gridy = 3; JLabel healthLbl = new JLabel("Health Pts : "); panel1.add(healthLbl, c); c.gridx = 1; JTextField health = new JTextField(""); health.setColumns(20); panel1.add(health, c); c.gridx = 0; c.gridy = 4; JLabel attackPtsLbl = new JLabel("Attack Points : "); panel1.add(attackPtsLbl, c); c.gridx = 1; JTextField attackPts = new JTextField(""); attackPts.setColumns(20); panel1.add(attackPts, c); c.gridx = 0; c.gridy = 5; JLabel armoursPtsLbl = new JLabel("Armour Points : "); panel1.add(armoursPtsLbl, c); c.gridx = 1; JTextField armourPts = new JTextField(""); armourPts.setColumns(20); panel1.add(armourPts, c); c.gridx = 0; c.gridy = 6; JLabel attackRngeLbl = new JLabel("Attack Range : "); panel1.add(attackRngeLbl, c); c.gridx = 1; JTextField attackRnge = new JTextField(""); attackRnge.setColumns(20); panel1.add(attackRnge, c); c.gridx = 0; c.gridy = 7; JLabel movementLbl = new JLabel("Movement : "); panel1.add(movementLbl, c); c.gridx = 1; JTextField movement = new JTextField(""); movement.setColumns(20); panel1.add(movement, c); c.gridx = 0; c.gridy = 8; c.gridwidth = 2; JButton submit = new JButton("Save"); submit.addActionListener(this); submit.setActionCommand("button"); panel1.add(submit, c); add(panel1); c.gridx = 0; c.gridy = 9; JLabel validationMess = new JLabel("Pls enter all the fields or pls choose a character from the drop down"); validationMess.setForeground(Color.red); validationMess.setVisible(false); add(validationMess, c); add(Box.createVerticalGlue()); }
From source file:jmemorize.gui.swing.panels.SessionChartPanel.java
private void initComponents(LearnSession finishedSession) { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(new EmptyBorder(5, 5, 5, 5)); LearnHistory history = Main.getInstance().getLesson().getLearnHistory(); SessionSummary lastSummary = history.getLastSummary(); add(createChartPanel(Localization.get(LC.CHART_THIS_SESSION), lastSummary)); add(createChartPanel(Localization.get(LC.CHART_AVERAGE_SESSION), history.getAverage())); setPreferredSize(new Dimension(500, 460)); }
From source file:Presentation.MainWindow.java
/** Construction de la fentre d'affichage principale */ public MainWindow() { super();//from ww w . j ava 2 s. co m setTitle("Interface d'administration du frigo"); setSize(800, 1000); Panel mainPanel = new Panel(); BoxLayout layout = new BoxLayout(mainPanel, BoxLayout.Y_AXIS); add(mainPanel); this.mPanel = mainPanel; addSlider(); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { dispose(); } }); show(); }
From source file:BoxLayoutPane.java
public BoxLayoutPane() { // Use a BorderLayout layout manager to arrange various Box components this.setLayout(new BorderLayout()); // Give the entire panel a margin by adding an empty border // We could also do this by overriding getInsets() this.setBorder(new EmptyBorder(10, 10, 10, 10)); // Add a plain row of buttons along the top of the pane Box row = Box.createHorizontalBox(); for (int i = 0; i < 4; i++) { JButton b = new JButton("B" + i); b.setFont(new Font("serif", Font.BOLD, 12 + i * 2)); row.add(b);// ww w. j av a 2 s . co m } this.add(row, BorderLayout.NORTH); // Add a plain column of buttons along the right edge // Use BoxLayout with a different kind of Swing container // Give the column a border: can't do this with the Box class JPanel col = new JPanel(); col.setLayout(new BoxLayout(col, BoxLayout.Y_AXIS)); col.setBorder(new TitledBorder(new EtchedBorder(), "Column")); for (int i = 0; i < 4; i++) { JButton b = new JButton("Button " + i); b.setFont(new Font("sanserif", Font.BOLD, 10 + i * 2)); col.add(b); } this.add(col, BorderLayout.EAST); // Add column to right of panel // Add a button box along the bottom of the panel. // Use "Glue" to space the buttons evenly Box buttonbox = Box.createHorizontalBox(); buttonbox.add(Box.createHorizontalGlue()); // stretchy space buttonbox.add(new JButton("Okay")); buttonbox.add(Box.createHorizontalGlue()); // stretchy space buttonbox.add(new JButton("Cancel")); buttonbox.add(Box.createHorizontalGlue()); // stretchy space buttonbox.add(new JButton("Help")); buttonbox.add(Box.createHorizontalGlue()); // stretchy space this.add(buttonbox, BorderLayout.SOUTH); // Create a component to display in the center of the panel JTextArea textarea = new JTextArea(); textarea.setText("This component has 12-pixel margins on left and top" + " and has 72-pixel margins on right and bottom."); textarea.setLineWrap(true); textarea.setWrapStyleWord(true); // Use Box objects to give the JTextArea an unusual spacing // First, create a column with 3 kids. The first and last kids // are rigid spaces. The middle kid is the text area Box fixedcol = Box.createVerticalBox(); fixedcol.add(Box.createVerticalStrut(12)); // 12 rigid pixels fixedcol.add(textarea); // Component fills in the rest fixedcol.add(Box.createVerticalStrut(72)); // 72 rigid pixels // Now create a row. Give it rigid spaces on the left and right, // and put the column from above in the middle. Box fixedrow = Box.createHorizontalBox(); fixedrow.add(Box.createHorizontalStrut(12)); fixedrow.add(fixedcol); fixedrow.add(Box.createHorizontalStrut(72)); // Now add the JTextArea in the column in the row to the panel this.add(fixedrow, BorderLayout.CENTER); }
From source file:fuel.gui.stats.StationStatsPanel.java
public StationStatsPanel(Database database) throws SQLException { this.database = database; JPanel container = new JPanel(new BorderLayout()); //container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS)); graphContainer = new JPanel(); graphContainer.setLayout(new BoxLayout(graphContainer, BoxLayout.Y_AXIS)); container.add(graphContainer, BorderLayout.CENTER); setLayout(new BorderLayout()); refreshGraphs();/*from w w w.j a va 2 s. c om*/ add(container); setVisible(true); }
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);// ww w.java 2 s . 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:com.ibm.watson.WatsonVRTraining.util.images.PhotoCaptureFrame.java
PhotoCaptureFrame() { jp = new JPanel(); jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); JScrollPane scrollPane = new JScrollPane(jp); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); scrollPane.setPreferredSize(new Dimension(dim.width / 2 - 40, dim.height - 117)); JButton btn = new JButton("Upload Image"); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(System.getenv("user.home")); fc.setFileFilter(new JPEGImageFileFilter()); int res = fc.showOpenDialog(null); // We have an image! try { if (res == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); //SharedResources.sharedCache.getCapturedImageList().add(file); File tmpf_name = File.createTempFile("tmp", "." + FilenameUtils.getExtension(file.getName())); System.out.println("cp " + file.getPath() + " " + AppConstants.vr_process_img_dir_path + File.separator + tmpf_name.getName()); new CommandsUtils().executeCommand("bash", "-c", "cp " + file.getPath() + " " + AppConstants.vr_process_img_dir_path + File.separator + tmpf_name.getName()); }/*from w w w .j a v a 2 s . c o m*/ } catch (Exception iOException) { } } }); ImageRemainingProcessingLabel = new JLabel("REMAINIG IMAGES:0"); ImageRemainingProcessingLabel.setHorizontalAlignment(SwingConstants.LEFT); ImageRemainingProcessingLabel.setFont(new Font("Arial", Font.BOLD, 13)); ImagebeingProcessedLabel = new JLabel(" PROCESSING IMAGES:0"); ImagebeingProcessedLabel.setHorizontalAlignment(SwingConstants.LEFT); ImagebeingProcessedLabel.setFont(new Font("Arial", Font.BOLD, 13)); appIDLabel = new JLabel("APP-ID:" + AppConstants.unique_app_id); appIDLabel.setHorizontalAlignment(SwingConstants.LEFT); appIDLabel.setFont(new Font("Arial", Font.BOLD, 13)); headerPanel = new JPanel(new FlowLayout()); headerPanel.add(ImageRemainingProcessingLabel); headerPanel.add(ImagebeingProcessedLabel); headerPanel.add(btn); headerPanel.add(appIDLabel); headerPanel.setSize(new Dimension(getWidth(), 10)); JPanel contentPane = new JPanel(); contentPane.add(headerPanel); contentPane.add(scrollPane); f = new JFrame("IBM Watson Visual Prediction Window"); f.setContentPane(contentPane); f.setSize(dim.width / 2 - 30, dim.height - 40); f.setLocation(dim.width / 2, 0); f.setResizable(false); f.setPreferredSize(new Dimension(dim.width / 2 - 30, dim.height - 60)); f.setVisible(true); }
From source file:com.game.ui.views.WeaponEditorPanel.java
public void doGui() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JLabel noteLbl = new JLabel( "<html><div style='width : 500px;'>Pls select a value to choose an Weapon or you can create a new " + "Weapon entity below. Once selected a weapon, its' details will be available below</div></html>"); noteLbl.setAlignmentX(0);//from w ww . j ava 2 s .c o m add(noteLbl); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (Item item : GameBean.weaponDetails) { if (item instanceof Weapon) { model.addElement(((Weapon) item).getName()); } } comboBox = new JComboBox(model); comboBox.setSelectedIndex(-1); comboBox.setMaximumSize(new Dimension(100, 30)); comboBox.setAlignmentX(0); comboBox.setActionCommand("dropDown"); comboBox.addActionListener(this); add(Box.createVerticalStrut(10)); add(comboBox); add(Box.createVerticalStrut(10)); JPanel panel1 = new JPanel(); panel1.setAlignmentX(0); panel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel1.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(5, 5, 5, 5); c.weightx = 1; c.weighty = 1; c.gridwidth = 2; JLabel weaponDtsLbl = new JLabel("Weapon Details : "); weaponDtsLbl.setFont(new Font("Times New Roman", Font.BOLD, 15)); panel1.add(weaponDtsLbl, c); c.gridwidth = 1; c.gridy = 1; JLabel nameLbl = new JLabel("Name : "); panel1.add(nameLbl, c); c.gridx = 1; JTextField name = new JTextField(""); name.setColumns(20); panel1.add(name, c); c.gridx = 0; c.gridy = 2; JLabel weaponTypeLbl = new JLabel("Weapon Type : "); panel1.add(weaponTypeLbl, c); c.gridx = 1; JComboBox weaponType = new JComboBox(Configuration.weaponTypes); weaponType.setSelectedIndex(0); weaponType.setPreferredSize(name.getPreferredSize()); System.out.println(name.getPreferredSize()); panel1.add(weaponType, c); c.gridx = 0; c.gridy = 3; JLabel attackRangeLbl = new JLabel("Attack Range : "); panel1.add(attackRangeLbl, c); c.gridx = 1; JTextField attackRange = new JTextField(""); attackRange.setColumns(20); panel1.add(attackRange, c); c.gridx = 0; c.gridy = 4; JLabel attackPtsLbl = new JLabel("Attack Points : "); panel1.add(attackPtsLbl, c); c.gridx = 1; JTextField attackPts = new JTextField(""); attackPts.setColumns(20); panel1.add(attackPts, c); c.gridx = 0; c.gridy = 5; c.gridwidth = 2; JButton submit = new JButton("Save"); submit.addActionListener(this); submit.setActionCommand("button"); panel1.add(submit, c); c.gridx = 0; c.gridy = 6; c.gridwidth = 2; c.weighty = 0; c.weightx = 1; validationMess = new JLabel("Pls enter all the fields or pls choose a weapon from the drop down"); validationMess.setForeground(Color.red); validationMess.setVisible(false); panel1.add(validationMess, c); // c.fill = GridBagConstraints.BOTH; // c.gridy = 7; // c.weightx = 1; // c.weighty = 1; // panel1.add(new JLabel(""), c); panel1.setBorder(LineBorder.createGrayLineBorder()); add(panel1); add(Box.createVerticalGlue()); }