List of usage examples for java.awt FlowLayout CENTER
int CENTER
To view the source code for java.awt FlowLayout CENTER.
Click Source Link
From source file:us.paulevans.basicxslt.SaveAsConfigurationFrame.java
/** * Constructor//from w w w. jav a 2s.c o m * @param aParent * @param aCurrentConfiguration */ public SaveAsConfigurationFrame(BasicXSLTFrame aParent, String aCurrentConfiguration) { JPanel southPanel, mainPanel; parent = aParent; userPrefs = Utils.getUserPrefs(); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { dispose(); } }); mainPanel = new JPanel(new BorderLayout()); mainPanel.add(buildMainPanel(), BorderLayout.CENTER); southPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); southPanel.add(okayBtn = new JButton(stringFactory.getString(LabelStringFactory.OK_BUTTON))); southPanel.add(cancelBtn = new JButton(stringFactory.getString(LabelStringFactory.CANCEL_BUTTON))); okayBtn.addActionListener(this); cancelBtn.addActionListener(this); getContentPane().setLayout(new BorderLayout()); getContentPane().add(buildNorthPanel(), BorderLayout.NORTH); getContentPane().add(southPanel, BorderLayout.SOUTH); getContentPane().add(new JScrollPane(mainPanel), BorderLayout.CENTER); setTitle(stringFactory.getString(LabelStringFactory.SAVEASCONFIG_FRAME_SAVE_CONFIGURATION_AS)); setSize(FRAME_WIDTH, FRAME_HEIGHT); GUIUtils.center(this, aParent); setVisible(true); configurationName.requestFocus(); }
From source file:qrcode.JavaQR.java
@Override public void run() { setLayout(new BorderLayout()); JPanel topPanel = new JPanel(); JPanel centerPanel = new JPanel(); JPanel bottomPanel = new JPanel(); topPanel.setLayout(new GridLayout(0, 1)); topPanel.setBorder(BorderFactory.createTitledBorder("Input Data")); JPanel rowTopPanel = new JPanel(); rowTopPanel.setLayout(new GridLayout(0, 2)); JLabel accKey = new JLabel("Access Key"); JTextField accField = new JTextField(5); accField.setEditable(false);//from ww w . j av a 2 s. c o m accField.setText(Data.accessKey); JLabel regNo = new JLabel("Registration Number"); JTextField regField = new JTextField(5); regField.setEditable(false); regField.setText(Data.registrationNumber); JLabel licNo = new JLabel("License Number"); JFormattedTextField licField = new JFormattedTextField(); licField.setEditable(false); licField.setText(Data.licenseNumber); rowTopPanel.add(accKey); rowTopPanel.add(accField); rowTopPanel.add(regNo); rowTopPanel.add(regField); rowTopPanel.add(licNo); rowTopPanel.add(licField); topPanel.add(rowTopPanel); centerPanel.setLayout(new GridLayout(0, 1)); centerPanel.setBorder(BorderFactory.createTitledBorder("QR Code")); JPanel rowCenPanel = new JPanel(); rowCenPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton genBtn = new JButton("Download QR Code"); JButton homeBtn = new JButton("Back to Start"); String accessKey = accField.getText().toString(); String regKey = regField.getText().toString(); String licKey = licField.getText().toString(); JSONObject jsonObject = new JSONObject(); try { jsonObject.put("accessKey", accessKey); jsonObject.put("registrationNumber", regKey); jsonObject.put("licenseNumber", licKey); } catch (JSONException e1) { e1.printStackTrace(); } QRLogic qrGen = new QRLogic(); BufferedImage image = qrGen.generateQR(jsonObject); centerPanel.add(new JLabel(new ImageIcon(image))); bottomPanel.setLayout(new GridLayout(2, 1)); rowCenPanel.add(homeBtn); rowCenPanel.add(genBtn); bottomPanel.add(rowCenPanel); add(topPanel, BorderLayout.NORTH); add(bottomPanel, BorderLayout.SOUTH); add(centerPanel, BorderLayout.CENTER); Data.mainFrame.setSize(1000, 500); genBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Date date = new Date(); String newDate = new SimpleDateFormat("yyyy-MM-dd h-m-a").format(date); JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); File myFile = new File(Data.registrationNumber + ".png"); fileChooser.setSelectedFile(myFile); fileChooser.showSaveDialog(null); String dlDir = fileChooser.getSelectedFile().getPath(); System.out.println(dlDir); String fileName = fileChooser.getSelectedFile().getName(); String filePath = ""; if (fileName != null) { filePath = dlDir + ".png"; } else { filePath = dlDir + "/" + Data.registrationNumber + ".png"; } String fileType = "png"; myFile = new File(filePath); if (dlDir != null) { try { ImageIO.write(image, fileType, myFile); JOptionPane.showMessageDialog(Data.mainFrame, "QR Code Saved in " + dlDir); } catch (IOException e1) { e1.printStackTrace(); } } } }); homeBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Data.mainFrame.showPanel("inventory"); } }); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } catch (InstantiationException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (UnsupportedLookAndFeelException e1) { e1.printStackTrace(); } }
From source file:com.emental.mindraider.ui.dialogs.FtsJDialog.java
public FtsJDialog() { super(Messages.getString("FtsJDialog.title")); JPanel dialogPanel = new JPanel(); dialogPanel.setBorder(new EmptyBorder(5, 10, 0, 10)); dialogPanel.setLayout(new BorderLayout()); JPanel contentAndButtons = new JPanel(new GridLayout(2, 1)); JPanel contentPanel = new JPanel(new BorderLayout()); // 1a.// www . ja v a2 s . com // TODO add help like in eclipse contentPanel.add(new JLabel(Messages.getString("FtsJDialog.searchString")), BorderLayout.NORTH); // 1b. String[] knownSearches = new String[] { "", "RDF", "mind", "concept", "China" }; ftsCombo = new JComboBox(knownSearches); ftsCombo.setPreferredSize(new Dimension(200, 18)); ftsCombo.setEditable(true); ftsCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if ("comboBoxEdited".equals(e.getActionCommand())) { search(); } } }); contentPanel.add(ftsCombo, BorderLayout.SOUTH); contentAndButtons.add(contentPanel); // 2. JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 5)); JButton searchButton = new JButton(Messages.getString("FtsJDialog.searchButton")); searchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { search(); } }); p.add(searchButton); JButton cancelButton = new JButton(Messages.getString("FtsJDialog.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); p.add(cancelButton); contentAndButtons.add(p); dialogPanel.add(contentAndButtons, BorderLayout.CENTER); getContentPane().add(dialogPanel, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); }
From source file:ua.utility.fkindexgenerator.UIUtils.java
/** * * @param labels// ww w.j av a 2 s. c o m * @param components * @return */ public static JPanel buildEntryPanel(String[] labels, JComponent[] components) { JPanel retval = new JPanel(new FlowLayout(FlowLayout.CENTER)); JPanel entryPanel = new JPanel(new BorderLayout(2, 1)); entryPanel.add(buildLabelGridPanel(labels), BorderLayout.WEST); entryPanel.add(buildComponentGridPanel(components), BorderLayout.CENTER); retval.add(entryPanel); return retval; }
From source file:com.emental.mindraider.ui.dialogs.NewRdfModelJDialog.java
/** * Constructor./*from ww w.j a va2 s . c o m*/ */ public NewRdfModelJDialog() { super(Messages.getString("NewRdfModelJDialog.title")); JPanel framePanel = new JPanel(); framePanel.setLayout(new GridLayout(3, 1)); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(new JLabel(Messages.getString("NewRdfModelJDialog.subject"))); subjectNs = new JTextField(30); subjectNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS); p.add(subjectNs); p.add(new JLabel("#")); subjectLocalName = new JTextField(15); p.add(subjectLocalName); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox literalCheckBox = new JCheckBox("literal", false); p.add(literalCheckBox); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton addButton = new JButton(Messages.getString("NewRdfModelJDialog.create")); p.add(addButton); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createModel(literalCheckBox); } }); JButton cancelButton = new JButton(Messages.getString("NewRdfModelJDialog.cancel")); p.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { NewRdfModelJDialog.this.dispose(); } }); framePanel.add(p); subjectLocalName.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { createModel(literalCheckBox); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); getContentPane().add(framePanel, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent e) { subjectLocalName.requestFocusInWindow(); } }); }
From source file:net.sf.taverna.raven.plugins.ui.CheckForUpdatesDialog.java
private void initComponents() { // Base font for all components on the form Font baseFont = new JLabel("base font").getFont().deriveFont(11f); // Message saying that updates are available JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.setBorder(/*from w w w. j a v a2 s . co m*/ new CompoundBorder(new EmptyBorder(10, 10, 10, 10), new EtchedBorder(EtchedBorder.LOWERED))); JLabel message = new JLabel( "<html><body>Updates are available for some Taverna components. To review and <br>install them go to 'Updates and plugins' in the 'Advanced' menu.</body><html>"); message.setFont(baseFont.deriveFont(12f)); message.setBorder(new EmptyBorder(5, 5, 5, 5)); message.setIcon(UpdatesAvailableIcon.updateIcon); messagePanel.add(message, BorderLayout.CENTER); // Buttons JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton okButton = new JButton("OK"); // we'll check for updates again in 2 weeks okButton.setFont(baseFont); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okPressed(); } }); buttonsPanel.add(okButton); getContentPane().setLayout(new BorderLayout()); getContentPane().add(messagePanel, BorderLayout.CENTER); getContentPane().add(buttonsPanel, BorderLayout.SOUTH); pack(); setResizable(false); // Center the dialog on the screen (we do not have the parent) Dimension dimension = getToolkit().getScreenSize(); Rectangle abounds = getBounds(); setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2); setSize(getPreferredSize()); }
From source file:org.kse.gui.dialogs.DCheckUpdate.java
private void initComponents() { jlCheckUpdate = new JLabel(res.getString("DCheckUpdate.jlCheckUpdate.text")); ImageIcon icon = new ImageIcon(getClass().getResource(res.getString("DCheckUpdate.jlCheckUpdate.image"))); jlCheckUpdate.setIcon(icon);/*from ww w . j a v a2 s . co m*/ jlCheckUpdate.setHorizontalTextPosition(SwingConstants.LEADING); jlCheckUpdate.setIconTextGap(15); jpCheckUpdate = new JPanel(new FlowLayout(FlowLayout.CENTER)); jpCheckUpdate.add(jlCheckUpdate); jpCheckUpdate.setBorder(new EmptyBorder(5, 5, 5, 5)); jpbCheckUpdate = new JProgressBar(); jpbCheckUpdate.setIndeterminate(true); jpbCheckUpdate.setString("DCheckUpdate.jlCheckUpdate.text"); jpProgress = new JPanel(new FlowLayout(FlowLayout.CENTER)); jpProgress.add(jpbCheckUpdate); jpProgress.setBorder(new EmptyBorder(5, 5, 5, 5)); jbCancel = new JButton(res.getString("DCheckUpdate.jbCancel.text")); jbCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY); jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jpCancel = PlatformUtil.createDialogButtonPanel(jbCancel, false); getContentPane().add(jpCheckUpdate, BorderLayout.NORTH); getContentPane().add(jpProgress, BorderLayout.CENTER); getContentPane().add(jpCancel, BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { if ((checker != null) && (checker.isAlive())) { checker.interrupt(); } closeDialog(); } }); setTitle(res.getString("DCheckUpdate.Title")); setResizable(false); pack(); }
From source file:gui.TraitViewerDialog.java
private JPanel createButtons() { bClose = new JButton("Close"); bClose.addActionListener(this); JPanel p1 = new JPanel(new GridLayout(1, 1, 5, 5)); p1.add(bClose);//from ww w .j a v a 2 s. co m JPanel p2 = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); p2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); p2.add(p1); return p2; }
From source file:com.emental.mindraider.ui.dialogs.SearchConceptAnnotation.java
/** * Constructor./*from ww w .j a va 2s . c om*/ */ public SearchConceptAnnotation(AbstractTextAnnotationRenderer renderer) { super("Search Annotation"); this.renderer = renderer; JPanel dialogPanel = new JPanel(); dialogPanel.setBorder(new EmptyBorder(5, 10, 0, 10)); dialogPanel.setLayout(new BorderLayout()); JPanel contentAndButtons = new JPanel(new GridLayout(2, 1)); JPanel contentPanel = new JPanel(new BorderLayout()); // 1a. // TODO add help like in eclipse contentPanel.add(new JLabel(Messages.getString("FtsJDialog.searchString")), BorderLayout.NORTH); // 1b. searchCombo = new JComboBox(history.toArray()); searchCombo.setSelectedItem(""); searchCombo.setPreferredSize(new Dimension(200, 18)); searchCombo.setEditable(true); searchCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if ("comboBoxEdited".equals(e.getActionCommand())) { search(); } } }); contentPanel.add(searchCombo, BorderLayout.SOUTH); contentAndButtons.add(contentPanel); // 2. JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 5)); JButton searchButton = new JButton(Messages.getString("FtsJDialog.searchButton")); searchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { search(); } }); p.add(searchButton); JButton cancelButton = new JButton(Messages.getString("FtsJDialog.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); p.add(cancelButton); contentAndButtons.add(p); dialogPanel.add(contentAndButtons, BorderLayout.CENTER); getContentPane().add(dialogPanel, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); }
From source file:net.sf.keystore_explorer.gui.dialogs.DCheckUpdate.java
private void initComponents() { jlCheckUpdate = new JLabel(res.getString("DCheckUpdate.jlCheckUpdate.text")); ImageIcon icon = new ImageIcon(getClass().getResource(res.getString("DCheckUpdate.jlCheckUpdate.image"))); jlCheckUpdate.setIcon(icon);/*from w w w . j a va2s . c o m*/ jlCheckUpdate.setHorizontalTextPosition(SwingConstants.LEADING); jlCheckUpdate.setIconTextGap(15); jpCheckUpdate = new JPanel(new FlowLayout(FlowLayout.CENTER)); jpCheckUpdate.add(jlCheckUpdate); jpCheckUpdate.setBorder(new EmptyBorder(5, 5, 5, 5)); jpbCheckUpdate = new JProgressBar(); jpbCheckUpdate.setIndeterminate(true); jpbCheckUpdate.setString("DCheckUpdate.jlCheckUpdate.text"); jpProgress = new JPanel(new FlowLayout(FlowLayout.CENTER)); jpProgress.add(jpbCheckUpdate); jpProgress.setBorder(new EmptyBorder(5, 5, 5, 5)); jbCancel = new JButton(res.getString("DCheckUpdate.jbCancel.text")); jbCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY); jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jpCancel = PlatformUtil.createDialogButtonPanel(jbCancel, false); getContentPane().add(jpCheckUpdate, BorderLayout.NORTH); getContentPane().add(jpProgress, BorderLayout.CENTER); getContentPane().add(jpCancel, BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { if ((checker != null) && (checker.isAlive())) { checker.interrupt(); } closeDialog(); } }); setTitle(res.getString("DCheckUpdate.Title")); setResizable(false); pack(); }