List of usage examples for java.awt FlowLayout FlowLayout
public FlowLayout()
From source file:abfab3d.param.editor.URIEditor.java
public URIEditor(Parameter param) { super(param); m_textField = new TextField(EDITOR_SIZE); Object val = m_param.getValue(); String sval = ""; if (val != null) { sval = val.toString(); }/*from ww w.ja v a 2s. c om*/ m_textField.setText(sval); m_textField.addActionListener(this); m_open = new JButton("Open"); m_open.setToolTipText("Open File"); panel = new JPanel(new FlowLayout()); panel.add(m_open); panel.add(m_textField); String user_dir = System.getProperty("user.dir"); Preferences prefs = Preferences.userNodeForPackage(URIEditor.class); String last_dir = prefs.get(LASTDIR_PROPERTY, null); String dir; if (last_dir != null) dir = last_dir; else dir = user_dir; fc = new JFileChooser(dir); m_open.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int returnVal = fc.showDialog(parent, "Open File"); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); String dir = file.getPath(); int idx = dir.lastIndexOf(File.separator); if (idx > 0) { dir = dir.substring(0, idx); Preferences prefs = Preferences.userNodeForPackage(URIEditor.class); prefs.put(LASTDIR_PROPERTY, dir); } m_param.setValue(file.getAbsolutePath()); informParamChangedListeners(); } } }); }
From source file:gtu._work.ui.JermyP100UI.java
private void initGUI() { try {/*from ww w . java 2 s. c om*/ FlowLayout thisLayout = new FlowLayout(); getContentPane().setLayout(thisLayout); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); { jLabel1 = new JLabel(); getContentPane().add(jLabel1); jLabel1.setText("FileP100.xls"); jLabel1.setPreferredSize(new java.awt.Dimension(68, 15)); } { fileP100Text = new JTextField(); JCommonUtil.jTextFieldSetFilePathMouseEvent(fileP100Text, false); getContentPane().add(fileP100Text); fileP100Text.setPreferredSize(new java.awt.Dimension(340, 22)); } { label2 = new JLabel(); getContentPane().add(label2); getContentPane().add(label2); label2.setText("RCDFP100.xls"); label2.setPreferredSize(new java.awt.Dimension(84, 15)); } { rcdfp100Text = new JTextField(); JCommonUtil.jTextFieldSetFilePathMouseEvent(rcdfp100Text, false); getContentPane().add(rcdfp100Text); rcdfp100Text.setPreferredSize(new java.awt.Dimension(340, 22)); } { executeBtn = new JButton(); getContentPane().add(executeBtn); executeBtn.setText("\u7522\u751f\u532f\u51fa\u6a94"); executeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (StringUtils.isBlank(rcdfp100Text.getText())) { JCommonUtil._jOptionPane_showMessageDialog_error("RCDFP100.xls"); return; } File rcdfp100File = new File(StringUtils.defaultString(rcdfp100Text.getText())); if (!rcdfp100File.exists()) { JCommonUtil._jOptionPane_showMessageDialog_error("RCDFP100.xls"); return; } if (StringUtils.isBlank(fileP100Text.getText())) { JCommonUtil._jOptionPane_showMessageDialog_error("FileP100.xls"); return; } File fileP100File = new File(StringUtils.defaultString(fileP100Text.getText())); if (!rcdfp100File.exists()) { JCommonUtil._jOptionPane_showMessageDialog_error("FileP100.xls"); return; } try { TestForJermy test = new TestForJermy(); test.execute(fileP100File, rcdfp100File, PropertiesUtil.getJarCurrentPath(JermyP100UI.class)); File outputFile = test.getOutputCvs(); JCommonUtil._jOptionPane_showMessageDialog_info( ":\n" + outputFile.getAbsolutePath()); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } pack(); this.setSize(457, 146); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:List.java
public void init() { Container cp = getContentPane(); t.setEditable(false);/*from w w w . jav a 2 s . c o m*/ cp.setLayout(new FlowLayout()); // Create Borders for components: Border brd = BorderFactory.createMatteBorder(1, 1, 2, 2, Color.BLACK); lst.setBorder(brd); t.setBorder(brd); // Add the first four items to the List for (int i = 0; i < 4; i++) lItems.addElement(flavors[count++]); // Add items to the Content Pane for Display cp.add(t); cp.add(lst); cp.add(b); // Register event listeners lst.addListSelectionListener(ll); b.addActionListener(bl); }
From source file:GlassPaneDemo.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. *//*from w w w .jav a 2 s . c o m*/ private static void createAndShowGUI() { // Create and set up the window. JFrame frame = new JFrame("GlassPaneDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Start creating and adding components. JCheckBox changeButton = new JCheckBox("Glass pane \"visible\""); changeButton.setSelected(false); // Set up the content pane, where the "main GUI" lives. Container contentPane = frame.getContentPane(); contentPane.setLayout(new FlowLayout()); contentPane.add(changeButton); contentPane.add(new JButton("Button 1")); contentPane.add(new JButton("Button 2")); // Set up the menu bar, which appears above the content pane. JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Menu"); menu.add(new JMenuItem("Do nothing")); menuBar.add(menu); frame.setJMenuBar(menuBar); // Set up the glass pane, which appears over both menu bar // and content pane and is an item listener on the change // button. myGlassPane = new MyGlassPane(changeButton, menuBar, frame.getContentPane()); changeButton.addItemListener(myGlassPane); frame.setGlassPane(myGlassPane); // Show the window. frame.pack(); frame.setVisible(true); }
From source file:Accounts.java
private void buildGUI() { Container c = getContentPane(); c.setLayout(new FlowLayout()); accountNumberList = new JList(); loadAccounts();//from www . j a v a 2 s. c o m 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 { Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery( "SELECT * FROM acc_acc WHERE acc_id = " + accountNumberList.getSelectedValue()); if (rs.next()) { accountIDText.setText(rs.getString("acc_id")); usernameText.setText(rs.getString("username")); passwordText.setText(rs.getString("password")); tsText.setText(rs.getString("ts")); activeTSText.setText(rs.getString("act_ts")); } } catch (SQLException selectException) { displaySQLErrors(selectException); } } }); //Do Insert Account Button insertAccountButton = new JButton("Insert Account"); insertAccountButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Statement statement = connection.createStatement(); int i = statement.executeUpdate("INSERT INTO acc_acc VALUES(" + accountIDText.getText() + ", " + "'" + usernameText.getText() + "', " + "'" + passwordText.getText() + "', " + "0" + ", " + "now())"); errorText.append("Inserted " + i + " rows successfully"); accountNumberList.removeAll(); loadAccounts(); } catch (SQLException insertException) { displaySQLErrors(insertException); } } }); //Do Delete Account Button deleteAccountButton = new JButton("Delete Account"); deleteAccountButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Statement statement = connection.createStatement(); int i = statement.executeUpdate( "DELETE FROM acc_acc WHERE acc_id = " + accountNumberList.getSelectedValue()); errorText.append("Deleted " + i + " rows successfully"); accountNumberList.removeAll(); loadAccounts(); } catch (SQLException insertException) { displaySQLErrors(insertException); } } }); //Do Update Account Button updateAccountButton = new JButton("Update Account"); updateAccountButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Statement statement = connection.createStatement(); int i = statement.executeUpdate("UPDATE acc_acc " + "SET username='" + usernameText.getText() + "', " + "password='" + passwordText.getText() + "', " + "act_ts = now() " + "WHERE acc_id = " + accountNumberList.getSelectedValue()); errorText.append("Updated " + i + " rows successfully"); accountNumberList.removeAll(); loadAccounts(); } catch (SQLException insertException) { displaySQLErrors(insertException); } } }); JPanel first = new JPanel(new GridLayout(5, 1)); first.add(accountNumberListScrollPane); first.add(getAccountButton); first.add(insertAccountButton); first.add(deleteAccountButton); first.add(updateAccountButton); accountIDText = new JTextField(15); usernameText = new JTextField(15); passwordText = new JTextField(15); tsText = new JTextField(15); activeTSText = new JTextField(15); errorText = new JTextArea(5, 15); errorText.setEditable(false); JPanel second = new JPanel(); second.setLayout(new GridLayout(6, 1)); second.add(accountIDText); second.add(usernameText); second.add(passwordText); second.add(tsText); second.add(activeTSText); JPanel third = new JPanel(); third.add(new JScrollPane(errorText)); c.add(first); c.add(second); c.add(third); setSize(500, 500); show(); }
From source file:DialogSeparator.java
public FlightReservation() { super("Dialog "); Container c = getContentPane(); c.setLayout(new FlowLayout()); c.add(new DialogSeparator("Options")); ButtonGroup group = new ButtonGroup(); JRadioButton r1 = new JRadioButton("First class"); group.add(r1);// ww w. j a v a2s . com c.add(r1); JRadioButton r2 = new JRadioButton("Business"); group.add(r2); c.add(r2); JRadioButton r3 = new JRadioButton("Coach"); group.add(r3); c.add(r3); c.add(new DialogSeparator()); JButton b3 = new JButton("Exit"); c.add(b3); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setSize(300, 200); setVisible(true); }
From source file:com.streamhub.StreamHubLicenseGenerator.java
private JPanel createActionsRow() { JPanel actionsRow = new JPanel(new FlowLayout()); File baseFolder = new File(DEFAULT_CUSTOMERS_DIRECTORY); JButton generate = new JButton("Generate"); generate.addActionListener(new ActionListener() { @Override/*from w ww. ja v a 2 s . c o m*/ public void actionPerformed(ActionEvent e) { for (JPanel row : macAddressPanels) { try { String macAddress = ((JTextField) row.getComponent(1)).getText(); if (macAddress.length() > 0) { String startDate = ((JTextField) row.getComponent(3)).getText(); String expiryDate = ((JTextField) row.getComponent(5)).getText(); String edition = ((JComboBox) row.getComponent(6)).getSelectedItem().toString(); macAddress = macAddress.replaceAll("-", ":").trim(); String name = ((JTextField) row.getComponent(8)).getText().trim(); String numUsers = ((JTextField) row.getComponent(10)).getText(); String licenseString = startDate + "-" + expiryDate + "-" + numUsers + "-" + macAddress + "-" + edition + ":" + name; String hashInput = licenseString + USELESS_KEY; MessageDigest m = MessageDigest.getInstance("SHA-512"); m.update(hashInput.getBytes(), 0, hashInput.length()); String hash = "==" + new BigInteger(1, m.digest()).toString(16) + "=="; StringBuilder licenseText = new StringBuilder(); licenseText.append("--").append(licenseString).append("--"); licenseText.append(CRLF); licenseText.append(hash); licenseText.append(CRLF); System.out.println(name + ":"); System.out.println(); System.out.println(licenseText); File licenseDir = new File(folderChooser.getSelectedFile(), name); if (!licenseDir.isDirectory() && !licenseDir.exists()) { licenseDir.mkdir(); } File licenseFile = new File(licenseDir, "license.txt"); System.out.println("writing to " + licenseFile.getAbsolutePath()); FileUtils.writeStringToFile(licenseFile, licenseText.toString()); } } catch (Exception exception) { System.out.println("Could not generate license"); exception.printStackTrace(); } } } }); final JButton chooseFolder = new JButton("Choose Folder"); final JTextField folderDisplay = new JTextField(baseFolder.getAbsolutePath()); folderChooser = new JFileChooser(baseFolder); folderChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); folderChooser.setSelectedFile(baseFolder); chooseFolder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == chooseFolder) { int returnVal = folderChooser.showOpenDialog(StreamHubLicenseGenerator.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File folder = folderChooser.getSelectedFile(); folderDisplay.setText(folder.getAbsolutePath()); } } } }); actionsRow.add(folderDisplay); actionsRow.add(chooseFolder); actionsRow.add(generate); return actionsRow; }
From source file:edu.turtlekit2.tools.chart.ChartWindow.java
/** * Constructor. Creates a new window where charts can be added. */ public ChartWindow() { setLayout(new FlowLayout()); }
From source file:JOptionDemo.java
JOptionDemo(String s) { super(s);/*ww w . j a v a 2 s. c om*/ Container cp = getContentPane(); cp.setLayout(new FlowLayout()); JButton b = new JButton("Give me a message"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(JOptionDemo.this, "This is your message: etaoin shrdlu", "Coded Message", JOptionPane.INFORMATION_MESSAGE); } }); cp.add(b); b = new JButton("Goodbye!"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); cp.add(b); // size the main window pack(); }
From source file:JListDemo.java
JListDemo(String s) { super(s);/*from ww w.j a va 2 s . co m*/ Container cp = getContentPane(); cp.setLayout(new FlowLayout()); ArrayList data = new ArrayList(); data.add("Hi"); data.add("Hello"); data.add("Goodbye"); data.add("Adieu"); data.add("Adios"); list = new JList(data.toArray()); list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (evt.getValueIsAdjusting()) return; System.out.println("Selected from " + evt.getFirstIndex() + " to " + evt.getLastIndex()); } }); cp.add(list, BorderLayout.CENTER); }