List of usage examples for javax.swing JPanel setLayout
public void setLayout(LayoutManager mgr)
From source file:MenuItemChooser.java
private void initGUI() { JPanel itemDetailsPanel = new JPanel(); itemDetailsPanel.setLayout(new GridLayout(4, 2)); itemDetailsPanel.setBackground(Color.WHITE); JLabel lbl = new JLabel("Item: "); itemDetailsPanel.add(lbl);//from w w w . j a v a 2 s . com itemName = new JLabel(""); itemDetailsPanel.add(itemName); lbl = new JLabel("Type: "); itemDetailsPanel.add(lbl); itemType = new JLabel(""); itemDetailsPanel.add(itemType); lbl = new JLabel("Price: $ "); itemDetailsPanel.add(lbl); price = new JLabel(""); itemDetailsPanel.add(price); lbl = new JLabel("Quantity: "); itemDetailsPanel.add(lbl); qty = new JTextField("0", 1); qty.addActionListener(this); qty.addFocusListener(this); itemDetailsPanel.add(qty); JPanel imgDescPanel = new JPanel(new BorderLayout()); imgDescPanel.setBackground(Color.WHITE); image = new JLabel(""); image.setHorizontalAlignment(SwingConstants.CENTER); image.setVerticalAlignment(SwingConstants.CENTER); imgDescPanel.add(image, BorderLayout.NORTH); desc = new JLabel("desc"); imgDescPanel.add(desc, BorderLayout.SOUTH); JPanel buttonPanel = new JPanel(); buttonPanel.setBackground(Color.WHITE); next = new JButton("Next"); next.addActionListener(this); buttonPanel.add(next); prev = new JButton("Previous"); prev.addActionListener(this); buttonPanel.add(prev); order = new JButton("Order"); order.addActionListener(this); buttonPanel.add(order); cancel = new JButton("Cancel / New"); cancel.addActionListener(this); buttonPanel.add(cancel); close = new JButton("Close"); close.addActionListener(this); close.setEnabled(false); buttonPanel.add(close); totalLbl = new JLabel(""); totalLbl.setFont(new Font("Serif", Font.BOLD, 14)); totalLbl.setForeground((Color.GREEN).darker()); buttonPanel.add(totalLbl); BorderLayout bl = new BorderLayout(); bl.setHgap(30); bl.setVgap(20); setLayout(bl); setBackground(Color.WHITE); add(itemDetailsPanel, BorderLayout.WEST); add(imgDescPanel, BorderLayout.EAST); add(buttonPanel, BorderLayout.SOUTH); TitledBorder title = BorderFactory.createTitledBorder("Choose Menu Items And Place Order"); setBorder(title); loadMenuItem(); }
From source file:com.apatar.ui.JSubmitHelpDialog.java
private void createDialog() { setLayout(new BorderLayout(5, 5)); setSize(400, 400);/*from w w w . jav a 2s . c o m*/ JPanel textPanel = new JPanel(new BorderLayout(5, 5)); textPanel.setBorder(new EmptyBorder(10, 5, 5, 5)); text.setLineWrap(true); text.setWrapStyleWord(true); text.setFont(UiUtils.NORMAL_SIZE_12_FONT); textPanel.add(new JLabel("If you found a bug, please submit it here:"), BorderLayout.NORTH); textPanel.add(new JScrollPane(text), BorderLayout.CENTER); JPanel contactPanel = new JPanel(); contactPanel.setLayout(new BoxLayout(contactPanel, BoxLayout.Y_AXIS)); JPanel firstNamePanel = new JPanel(); firstNamePanel.setLayout(new BoxLayout(firstNamePanel, BoxLayout.X_AXIS)); firstNamePanel.add(new JLabel("Your First Name:")); firstNamePanel.add(Box.createHorizontalStrut(5)); firstNamePanel.add(firstNameField); JPanel lastNamePanel = new JPanel(); lastNamePanel.setLayout(new BoxLayout(lastNamePanel, BoxLayout.X_AXIS)); lastNamePanel.add(new JLabel("Your Last Name:")); lastNamePanel.add(Box.createHorizontalStrut(5)); lastNamePanel.add(lastNameField); JPanel emailPanel = new JPanel(); emailPanel.setLayout(new BoxLayout(emailPanel, BoxLayout.X_AXIS)); emailPanel.add(new JLabel("Your E-mail:")); emailPanel.add(Box.createHorizontalStrut(28)); emailPanel.add(emailField); contactPanel.add(firstNamePanel); contactPanel.add(Box.createVerticalStrut(5)); contactPanel.add(lastNamePanel); contactPanel.add(Box.createVerticalStrut(5)); contactPanel.add(emailPanel); textPanel.add(contactPanel, BorderLayout.SOUTH); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.add(Box.createHorizontalGlue()); buttonPanel.add(sendButton); buttonPanel.add(Box.createHorizontalStrut(5)); buttonPanel.add(cancel); buttonPanel.add(Box.createHorizontalStrut(5)); buttonPanel.setBorder(new EmptyBorder(0, 0, 5, 0)); getContentPane().add(textPanel, BorderLayout.CENTER); getContentPane().add(buttonPanel, BorderLayout.SOUTH); }
From source file:org.spf4j.ui.TSDBViewJInternalFrame.java
@edu.umd.cs.findbugs.annotations.SuppressWarnings("UP_UNUSED_PARAMETER") private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed TreePath[] selectionPaths = measurementTree.getSelectionPaths(); JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); chartPannel.setViewportView(content); try {//from w w w . j av a 2 s . c o m List<String> selectedTables = getSelectedTables(selectionPaths); for (String tableName : selectedTables) { addChartToPanel(tableName, content); } } catch (IOException ex) { throw new RuntimeException(ex); } chartPannel.repaint(); }
From source file:be.ac.ua.comp.scarletnebula.gui.windows.LinkUnlinkWindow.java
private JPanel getBottomPanel() { final JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS)); bottomPanel.add(Box.createHorizontalGlue()); final JButton cancelButton = ButtonFactory.createCancelButton(); cancelButton.addActionListener(new ActionListener() { @Override//from ww w. j a v a 2 s . c om public void actionPerformed(final ActionEvent e) { LinkUnlinkWindow.this.dispose(); } }); bottomPanel.add(cancelButton); bottomPanel.add(Box.createHorizontalStrut(10)); final JButton okButton = ButtonFactory.createOkButton(); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { actuallyLinkUnlink(); LinkUnlinkWindow.this.dispose(); } }); bottomPanel.add(okButton); bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 20, 20)); return bottomPanel; }
From source file:fuel.gui.stats.MotorStatsPanel.java
public MotorStatsPanel(Database database) throws SQLException { this.database = database; controller = new Controller(); JPanel container = new JPanel(new BorderLayout()); //container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS)); JPanel motorSelectionPanel = new JPanel(); motorSelectionPanel.setLayout(new BoxLayout(motorSelectionPanel, BoxLayout.X_AXIS)); motorSpecsPanel = new JPanel(new GridLayout(2, 3)); motorSpecsPanel.setBorder(BorderFactory.createTitledBorder("Specs")); graphContainer = new JPanel(); graphContainer.setLayout(new BoxLayout(graphContainer, BoxLayout.Y_AXIS)); JComboBox motorSelector = new JComboBox(database.getMotorcycles().toArray()); motorSelector.setActionCommand("SELECTMOTOR"); motorSelector.addActionListener(controller); motorSelectionPanel.add(motorSelector); //motorSelector.setSelectedIndex(0); motorSelectionPanel.add(motorSpecsPanel); refreshMotorSpecs((Motorcycle) motorSelector.getSelectedItem()); container.add(motorSelectionPanel, BorderLayout.NORTH); JScrollPane scroll = new JScrollPane(graphContainer); scroll.getHorizontalScrollBar().setUnitIncrement(10); scroll.getVerticalScrollBar().setUnitIncrement(10); container.add(scroll, BorderLayout.CENTER); refreshGraphs((Motorcycle) motorSelector.getSelectedItem()); setLayout(new BorderLayout()); add(container);/*ww w . j a va 2 s .co m*/ setVisible(true); }
From source file:MainClass.java
public void actionPerformed(ActionEvent e) { JTextPane editor = (JTextPane) getEditor(e); int p0 = editor.getSelectionStart(); StyledDocument doc = getStyledDocument(editor); Element paragraph = doc.getCharacterElement(p0); AttributeSet as = paragraph.getAttributes(); family = StyleConstants.getFontFamily(as); fontSize = StyleConstants.getFontSize(as); formatText = new JDialog(new JFrame(), "Font and Size", true); formatText.getContentPane().setLayout(new BorderLayout()); JPanel choosers = new JPanel(); choosers.setLayout(new GridLayout(2, 1)); JPanel fontFamilyPanel = new JPanel(); fontFamilyPanel.add(new JLabel("Font")); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fontNames = ge.getAvailableFontFamilyNames(); fontFamilyChooser = new JComboBox(); for (int i = 0; i < fontNames.length; i++) { fontFamilyChooser.addItem(fontNames[i]); }//from ww w . ja va 2 s . c o m fontFamilyChooser.setSelectedItem(family); fontFamilyPanel.add(fontFamilyChooser); choosers.add(fontFamilyPanel); JPanel fontSizePanel = new JPanel(); fontSizePanel.add(new JLabel("Size")); fontSizeChooser = new JComboBox(); fontSizeChooser.setEditable(true); fontSizeChooser.addItem(new Float(4)); fontSizeChooser.addItem(new Float(8)); fontSizeChooser.addItem(new Float(12)); fontSizeChooser.addItem(new Float(16)); fontSizeChooser.addItem(new Float(20)); fontSizeChooser.addItem(new Float(24)); fontSizeChooser.setSelectedItem(new Float(fontSize)); fontSizePanel.add(fontSizeChooser); choosers.add(fontSizePanel); JButton ok = new JButton("OK"); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { accept = true; formatText.dispose(); family = (String) fontFamilyChooser.getSelectedItem(); fontSize = Float.parseFloat(fontSizeChooser.getSelectedItem().toString()); } }); JButton cancel = new JButton("Cancel"); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { formatText.dispose(); } }); JPanel buttons = new JPanel(); buttons.add(ok); buttons.add(cancel); formatText.getContentPane().add(choosers, BorderLayout.CENTER); formatText.getContentPane().add(buttons, BorderLayout.SOUTH); formatText.pack(); formatText.setVisible(true); MutableAttributeSet attr = null; if (editor != null && accept) { attr = new SimpleAttributeSet(); StyleConstants.setFontFamily(attr, family); StyleConstants.setFontSize(attr, (int) fontSize); setCharacterAttributes(editor, attr, false); } }
From source file:de.codesourcery.jasm16.ide.ui.views.ProjectConfigurationView.java
@Override protected JPanel getPanel() { final JPanel result = new JPanel(); result.setLayout(new GridBagLayout()); // project name int y = 0;//from w w w . ja v a 2 s . c o m GridBagConstraints cnstrs = constraints(0, y, false, false, GridBagConstraints.NONE); result.add(new JLabel("Project name"), cnstrs); cnstrs = constraints(1, y++, true, false, GridBagConstraints.NONE); result.add(projectName, cnstrs); // build options panel final JPanel buildOptionsPanel = new JPanel(); buildOptionsPanel.setLayout(new GridBagLayout()); buildOptionsPanel.setBorder(BorderFactory.createTitledBorder("Build options")); cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); buildOptionsPanel.add(new JLabel("Compilation root"), cnstrs); cnstrs = constraints(1, 0, false, false, GridBagConstraints.NONE); compilationRootName.setEditable(false); compilationRootName.setColumns(25); buildOptionsPanel.add(compilationRootName, cnstrs); cnstrs = constraints(2, 0, true, false, GridBagConstraints.NONE); buildOptionsPanel.add(compilationRootButton, cnstrs); compilationRootButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser chooser; File baseDir = null; if (project != null) { baseDir = project.getConfiguration().getBaseDirectory(); } if (StringUtils.isNotBlank(compilationRootName.getText())) { File tmp = new File(compilationRootName.getText()).getParentFile(); if (tmp.exists() && tmp.isDirectory()) { baseDir = tmp; } } if (baseDir != null) { chooser = new JFileChooser(baseDir); } else { chooser = new JFileChooser(); } final int result = chooser.showOpenDialog(null); if (result == JFileChooser.APPROVE_OPTION && chooser.getSelectedFile().isFile()) { compilationRootName.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); // generate self-relocating code ? cnstrs = constraints(0, 1, false, false, GridBagConstraints.NONE); buildOptionsPanel.add(new JLabel("Generate self-relocating code?"), cnstrs); cnstrs = constraints(1, 1, true, true, GridBagConstraints.NONE); cnstrs.gridwidth = 2; buildOptionsPanel.add(generateSelfRelocatingCode, cnstrs); // inline short literals ? cnstrs = constraints(0, 2, false, false, GridBagConstraints.NONE); buildOptionsPanel.add(new JLabel("Inline short literals?"), cnstrs); cnstrs = constraints(1, 2, true, true, GridBagConstraints.NONE); cnstrs.gridwidth = 2; buildOptionsPanel.add(inlineShortLiterals, cnstrs); // add build options panel to parent cnstrs = constraints(0, y++, true, false, GridBagConstraints.BOTH); cnstrs.gridwidth = 2; result.add(buildOptionsPanel, cnstrs); // buttons final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); buttonPanel.add(saveButton, cnstrs); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (hasValidInput()) { onSave(); } } }); cnstrs = constraints(1, 0, true, true, GridBagConstraints.NONE); buttonPanel.add(cancelButton, cnstrs); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onCancel(); } }); // button panel cnstrs = constraints(0, y++, true, true, GridBagConstraints.NONE); cnstrs.gridwidth = 2; result.add(buttonPanel, cnstrs); return result; }
From source file:de.rub.syssec.saaf.gui.frame.CfgSelectorFrame.java
/** * A frame to generate and open Control Flow Graphs. CFGs are created using mxGraph * and are saved as PNGs./* w w w .ja v a 2s. c om*/ * * @param smaliClass the smali class to select methods from */ public CfgSelectorFrame(ClassInterface smaliClass) { super(smaliClass.getFullClassName(true), true, true, true, true); this.smaliClass = smaliClass; listModel = new MethodTableModel(smaliClass); list.setModel(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { int viewRow = list.getSelectedRow(); if (viewRow <= 0) { showButton.setEnabled(false); } else { showButton.setEnabled(true); } } }); JScrollPane listScrollPane = new JScrollPane(list); ActionListener al = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(SHOW_OPERATION)) { generateAndShowCfg(true); } else if (e.getActionCommand().equals(GENERATE_OPERATION)) { generateAndShowCfg(false); } } }; generateButton = new JButton(GENERATE_OPERATION); generateButton.setActionCommand(GENERATE_OPERATION); generateButton.addActionListener(al); showButton = new JButton(SHOW_OPERATION); showButton.setEnabled(false); showButton.addActionListener(al); saveCfgCheckBox = new JCheckBox("Save a copy"); saveCfgCheckBox.setToolTipText("Save a copy in the configured CFG folder upon generation."); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.add(generateButton); buttonPane.add(saveCfgCheckBox); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel filler = new JPanel(); filler.setPreferredSize(new Dimension(10, 10)); buttonPane.add(filler); buttonPane.add(showButton); add(listScrollPane, BorderLayout.CENTER); add(buttonPane, BorderLayout.PAGE_END); this.setPreferredSize(new Dimension(500, 250)); this.pack(); this.setVisible(true); }
From source file:FileChooserTest.java
public FileChooserTest() { JPanel p = new JPanel(); open.addActionListener(new OpenL()); p.add(open);//w ww . j a va 2s. c om save.addActionListener(new SaveL()); p.add(save); Container cp = getContentPane(); cp.add(p, BorderLayout.SOUTH); dir.setEditable(false); filename.setEditable(false); p = new JPanel(); p.setLayout(new GridLayout(2, 1)); p.add(filename); p.add(dir); cp.add(p, BorderLayout.NORTH); }
From source file:IDlook.java
private void buildGUI() { Container c = getContentPane(); c.setLayout(new FlowLayout()); accountNumberList = new JList(); loadAccounts();// w w w . ja v a 2s . c om accountNumberList.setVisibleRowCount(2); JScrollPane accountNumberListScrollPane = new JScrollPane(accountNumberList); //Do Get Account Button getAccountButton = new JButton("Get Account"); getAccountButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { rs.beforeFirst(); while (rs.next()) { if (rs.getString("acc_id").equals(accountNumberList.getSelectedValue())) break; } if (!rs.isAfterLast()) { accountIDText.setText(rs.getString("acc_id")); thumbIDText.setText(rs.getString("thumb_id")); icon = new ImageIcon(rs.getBytes("pic")); createThumbnail(); photographLabel.setIcon(iconThumbnail); } } catch (SQLException selectException) { displaySQLErrors(selectException); } } }); //Do Update Account Button updateAccountButton = new JButton("Update Account"); updateAccountButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { byte[] bytes = new byte[50000]; FileInputStream fs = new FileInputStream(nailFileText.getText()); BufferedInputStream bis = new BufferedInputStream(fs); bis.read(bytes); rs.updateBytes("thumbnail.pic", bytes); rs.updateRow(); bis.close(); accountNumberList.removeAll(); loadAccounts(); } catch (SQLException insertException) { displaySQLErrors(insertException); } catch (Exception generalE) { generalE.printStackTrace(); } } }); //Do insert Account Button insertAccountButton = new JButton("Insert Account"); insertAccountButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { byte[] bytes = new byte[50000]; FileInputStream fs = new FileInputStream(nailFileText.getText()); BufferedInputStream bis = new BufferedInputStream(fs); bis.read(bytes); rs.moveToInsertRow(); rs.updateInt("thumb_id", Integer.parseInt(thumbIDText.getText())); rs.updateInt("acc_id", Integer.parseInt(accountIDText.getText())); rs.updateBytes("pic", bytes); rs.updateObject("sysobject", null); rs.updateTimestamp("ts", new Timestamp(0)); rs.updateTimestamp("act_ts", new Timestamp(new java.util.Date().getTime())); rs.insertRow(); bis.close(); accountNumberList.removeAll(); loadAccounts(); } catch (SQLException insertException) { displaySQLErrors(insertException); } catch (Exception generalE) { generalE.printStackTrace(); } } }); photographLabel = new JLabel(); photographLabel.setHorizontalAlignment(JLabel.CENTER); photographLabel.setVerticalAlignment(JLabel.CENTER); photographLabel.setVerticalTextPosition(JLabel.CENTER); photographLabel.setHorizontalTextPosition(JLabel.CENTER); JPanel first = new JPanel(new GridLayout(4, 1)); first.add(accountNumberListScrollPane); first.add(getAccountButton); first.add(updateAccountButton); first.add(insertAccountButton); accountIDText = new JTextField(15); thumbIDText = new JTextField(15); errorText = new JTextArea(5, 15); errorText.setEditable(false); JPanel second = new JPanel(); second.setLayout(new GridLayout(2, 1)); second.add(thumbIDText); second.add(accountIDText); JPanel third = new JPanel(); third.add(new JScrollPane(errorText)); nailFileText = new JTextField(25); c.add(first); c.add(second); c.add(third); c.add(nailFileText); c.add(photographLabel); setSize(500, 500); show(); }