List of usage examples for java.awt FlowLayout FlowLayout
public FlowLayout()
From source file:BusinessLogic.java
public void init() { Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(t);//from w w w . j a v a 2s. c o m calc1.addActionListener(new Calc1L()); calc2.addActionListener(new Calc2L()); JPanel p1 = new JPanel(); p1.add(calc1); p1.add(calc2); cp.add(p1); mod.getDocument().addDocumentListener(new ModL()); JPanel p2 = new JPanel(); p2.add(new JLabel("Modifier:")); p2.add(mod); cp.add(p2); }
From source file:RSAccounts.java
private void buildGUI() { Container c = getContentPane(); c.setLayout(new FlowLayout()); accountNumberList = new JList(); loadAccounts();/*from w w w . ja v a 2 s.c o m*/ accountNumberList.setVisibleRowCount(2); JScrollPane accountNumberListScrollPane = new JScrollPane(accountNumberList); gotoText = new JTextField(3); freeQueryText = new JTextField(40); //Do Get Account Button getAccountButton = new JButton("Get Account"); getAccountButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { rs.first(); while (rs.next()) { if (rs.getString("acc_id").equals(accountNumberList.getSelectedValue())) break; } if (!rs.isAfterLast()) { 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); } } }); //Do Next Button nextButton = new JButton(">"); nextButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (!rs.isLast()) { 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 insertException) { displaySQLErrors(insertException); } } }); //Do Next Button previousButton = new JButton("<"); previousButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (!rs.isFirst()) { rs.previous(); 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 insertException) { displaySQLErrors(insertException); } } }); //Do last Button lastButton = new JButton(">|"); lastButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { rs.last(); 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 insertException) { displaySQLErrors(insertException); } } }); //Do first Button firstButton = new JButton("|<"); firstButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { rs.first(); 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 insertException) { displaySQLErrors(insertException); } } }); //Do gotoButton gotoButton = new JButton("Goto"); gotoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { rs.absolute(Integer.parseInt(gotoText.getText())); 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 insertException) { displaySQLErrors(insertException); } } }); //Do freeQueryButton freeQueryButton = new JButton("Execute Query"); freeQueryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (freeQueryText.getText().toUpperCase().indexOf("SELECT") >= 0) { rs = statement.executeQuery(freeQueryText.getText()); 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")); } } else { int i = statement.executeUpdate(freeQueryText.getText()); errorText.append("Rows affected = " + i); 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)); JPanel fourth = new JPanel(); fourth.add(firstButton); fourth.add(previousButton); fourth.add(nextButton); fourth.add(lastButton); fourth.add(gotoText); fourth.add(gotoButton); JPanel fifth = new JPanel(); fifth.add(freeQueryText); c.add(first); c.add(second); c.add(third); c.add(fourth); c.add(fifth); c.add(freeQueryButton); setSize(500, 500); show(); }
From source file:layout.FlowLayoutDemo.java
public void addComponentsToPane(final Container pane) { final JPanel compsToExperiment = new JPanel(); compsToExperiment.setLayout(experimentLayout); experimentLayout.setAlignment(FlowLayout.TRAILING); JPanel controls = new JPanel(); controls.setLayout(new FlowLayout()); LtoRbutton = new JRadioButton(LtoR); LtoRbutton.setActionCommand(LtoR);/*from w w w. j ava 2s. c o m*/ LtoRbutton.setSelected(true); RtoLbutton = new JRadioButton(RtoL); RtoLbutton.setActionCommand(RtoL); //Add buttons to the experiment layout compsToExperiment.add(new JButton("Button 1")); compsToExperiment.add(new JButton("Button 2")); compsToExperiment.add(new JButton("Button 3")); compsToExperiment.add(new JButton("Long-Named Button 4")); compsToExperiment.add(new JButton("5")); //Left to right component orientation is selected by default compsToExperiment.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); //Add controls to set up the component orientation in the experiment layout final ButtonGroup group = new ButtonGroup(); group.add(LtoRbutton); group.add(RtoLbutton); controls.add(LtoRbutton); controls.add(RtoLbutton); controls.add(applyButton); //Process the Apply component orientation button press applyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String command = group.getSelection().getActionCommand(); //Check the selection if (command.equals("Left to right")) { compsToExperiment.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); } else { compsToExperiment.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); } //update the experiment layout compsToExperiment.validate(); compsToExperiment.repaint(); } }); pane.add(compsToExperiment, BorderLayout.CENTER); pane.add(controls, BorderLayout.SOUTH); ; }
From source file:HighlightedButton.java
private static void createAndShowGUI() { JFrame f = new JFrame(); f.getContentPane().setLayout(new FlowLayout()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(100, 100);/*from w ww . j av a2 s . c om*/ f.add(new JButton("Standard")); f.add(new HighlightedButton("Highlighted")); f.setVisible(true); }
From source file:JScrollPanes.java
public void init() { Container cp = getContentPane(); cp.setLayout(new FlowLayout()); // Create Borders for components: Border brd = BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLACK); t1.setBorder(brd);/*from ww w. ja v a 2 s . c o m*/ t2.setBorder(brd); sp3.setBorder(brd); sp4.setBorder(brd); sp5.setBorder(brd); sp6.setBorder(brd); // Initialize listeners and add components: b1.addActionListener(new B1L()); cp.add(b1); cp.add(t1); b2.addActionListener(new B2L()); cp.add(b2); cp.add(t2); b3.addActionListener(new B3L()); cp.add(b3); b4.addActionListener(new B4L()); cp.add(b4); cp.add(sp3); cp.add(sp4); cp.add(sp5); cp.add(sp6); }
From source file:piilSource.Histogram.java
public Histogram(final String s, List<List<String>> list, Character meta) { super(s);/*w w w . j a v a 2s.co m*/ metaLabel = (meta.equals('M')) ? "beta" : "expression"; histogramPanel = createDemoPanel(s, list, metaLabel); histogramPanel.setPreferredSize(new Dimension(500, 270)); setContentPane(histogramPanel); exportButton = new JButton("Export to image"); exportButton.setPreferredSize(new Dimension(150, 30)); closeButton = new JButton("Close"); closeButton.setPreferredSize(new Dimension(150, 30)); buttonsPanel = new JPanel(); buttonsPanel.setLayout(new FlowLayout()); buttonsPanel.setBackground(Color.WHITE); buttonsPanel.add(exportButton); buttonsPanel.add(closeButton); exportButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent bc) { ExportDialog export = new ExportDialog(); export.showExportDialog(chartFrame, "Export view as ...", histogramPanel, "Histogram of the " + metaLabel + " values for all samples - " + s); } }); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { chartFrame.dispose(); } }); chartFrame = new JFrame(); chartFrame.setLayout(new BorderLayout()); chartFrame.setSize(400, 100); Toolkit tk = Toolkit.getDefaultToolkit(); Dimension dim = tk.getScreenSize(); int xPos = (dim.width / 2) - (chartFrame.getWidth() / 2); int yPos = (dim.height / 2) - (chartFrame.getHeight() / 2); chartFrame.setLocation(xPos, yPos); chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); chartFrame.add(histogramPanel, BorderLayout.CENTER); chartFrame.add(buttonsPanel, BorderLayout.SOUTH); chartFrame.setSize(800, 400); chartFrame.setVisible(true); }
From source file:IDlook.java
private void buildGUI() { Container c = getContentPane(); c.setLayout(new FlowLayout()); accountNumberList = new JList(); loadAccounts();/*from ww w. j a v a2 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 { 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(); }
From source file:gtu.xml.xstream.iisi.MQDecodeUI.java
private void initGUI() { try {//from w ww . j a va2 s .c o m JCommonUtil.defaultLookAndFeel(); GridLayout thisLayout = new GridLayout(3, 1); thisLayout.setColumns(1); thisLayout.setHgap(5); thisLayout.setVgap(5); thisLayout.setRows(3); getContentPane().setLayout(thisLayout); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); { beforeArea = new JTextArea(); getContentPane().add(beforeArea); } { afterArea = new JTextArea(); getContentPane().add(afterArea); } { jPanel1 = new JPanel(); FlowLayout jPanel1Layout = new FlowLayout(); getContentPane().add(jPanel1); jPanel1.setPreferredSize(new java.awt.Dimension(546, 38)); jPanel1.setLayout(jPanel1Layout); { executeBtn = new JButton(); jPanel1.add(executeBtn); executeBtn.setText("\u7522\u751f"); executeBtn.setPreferredSize(new java.awt.Dimension(78, 22)); executeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { Validate.notBlank(beforeArea.getText(), "messgaeContent"); String msg2 = beforeArea.getText(); XmlParserImpl xmlParserImpl = new XmlParserImpl(); final String jmsMessageXML = StringCompressUtil.uncompress(msg2); JmsMessageNew jmsMessageNew = (JmsMessageNew) xmlParserImpl .parseToObj(jmsMessageXML); String returnMessage = jmsMessageNew.getMessageXML(); System.out.println(returnMessage); afterArea.setText(returnMessage); System.out.println("done..."); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } { cleanBtn = new JButton(); jPanel1.add(cleanBtn); cleanBtn.setText("\u6e05\u9664"); cleanBtn.setPreferredSize(new java.awt.Dimension(78, 22)); cleanBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { beforeArea.setText(""); afterArea.setText(""); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); } } pack(); this.setSize(554, 402); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:IDlookBlob.java
private void buildGUI() { Container c = getContentPane(); c.setLayout(new FlowLayout()); accountNumberList = new JList(); loadAccounts();//from w w w . ja va2 s . 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")); Blob b = rs.getBlob("pic"); icon = new ImageIcon(b.getBytes(1L, (int) b.length())); 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(); }
From source file:SaveDialog.java
/** Construct the object including its GUI */ public SaveDialog() { super("SaveDialog"); Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(new Label("Press this button to see the Quit dialog: ")); cp.add(quitButton = new Button("Quit")); quitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("In Exit Button's action handler"); if (okToQuit()) { setVisible(false);/*from ww w . java 2 s . c o m*/ dispose(); System.exit(0); } } }); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { setVisible(false); dispose(); System.exit(0); } }); pack(); }