List of usage examples for java.awt GridBagLayout GridBagLayout
public GridBagLayout()
From source file:com.litt.core.security.license.gui.CustomerPanel.java
public CustomerPanel() { GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0 }; gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE }; gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; setLayout(gridBagLayout);//from www .j a va 2 s . com JLabel lblProduct = new JLabel("\u4EA7\u54C1\uFF1A"); GridBagConstraints gbc_lblProduct = new GridBagConstraints(); gbc_lblProduct.insets = new Insets(0, 0, 5, 5); gbc_lblProduct.anchor = GridBagConstraints.EAST; gbc_lblProduct.gridx = 0; gbc_lblProduct.gridy = 0; add(lblProduct, gbc_lblProduct); comboBoxProduct = new JComboBox(); GridBagConstraints gbc_comboBoxProduct = new GridBagConstraints(); gbc_comboBoxProduct.insets = new Insets(0, 0, 5, 5); gbc_comboBoxProduct.fill = GridBagConstraints.HORIZONTAL; gbc_comboBoxProduct.gridx = 1; gbc_comboBoxProduct.gridy = 0; add(comboBoxProduct, gbc_comboBoxProduct); JButton btnRefresh = new JButton(""); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { initProduct(); } }); btnRefresh.setIcon(new ImageIcon(CustomerPanel.class.getResource("/images/icon_refresh.png"))); GridBagConstraints gbc_btnRefresh = new GridBagConstraints(); gbc_btnRefresh.insets = new Insets(0, 0, 5, 0); gbc_btnRefresh.gridx = 2; gbc_btnRefresh.gridy = 0; add(btnRefresh, gbc_btnRefresh); JLabel lblProductVersion = new JLabel("\u4EA7\u54C1\u7248\u672C\uFF1A"); GridBagConstraints gbc_lblProductVersion = new GridBagConstraints(); gbc_lblProductVersion.anchor = GridBagConstraints.EAST; gbc_lblProductVersion.insets = new Insets(0, 0, 5, 5); gbc_lblProductVersion.gridx = 0; gbc_lblProductVersion.gridy = 1; add(lblProductVersion, gbc_lblProductVersion); textFieldProductVersion = new VersionTextField(); textFieldProductVersion.setColumns(10); GridBagConstraints gbc_textFieldProductVersion = new GridBagConstraints(); gbc_textFieldProductVersion.anchor = GridBagConstraints.WEST; gbc_textFieldProductVersion.insets = new Insets(0, 0, 5, 5); gbc_textFieldProductVersion.gridx = 1; gbc_textFieldProductVersion.gridy = 1; add(textFieldProductVersion, gbc_textFieldProductVersion); JLabel lblCompanyName = new JLabel("\u516C\u53F8\u540D\u79F0\uFF1A"); GridBagConstraints gbc_lblCompanyName = new GridBagConstraints(); gbc_lblCompanyName.anchor = GridBagConstraints.EAST; gbc_lblCompanyName.insets = new Insets(0, 0, 5, 5); gbc_lblCompanyName.gridx = 0; gbc_lblCompanyName.gridy = 2; add(lblCompanyName, gbc_lblCompanyName); textFieldCompanyName = new JTextField(); GridBagConstraints gbc_textFieldCompanyName = new GridBagConstraints(); gbc_textFieldCompanyName.insets = new Insets(0, 0, 5, 5); gbc_textFieldCompanyName.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldCompanyName.gridx = 1; gbc_textFieldCompanyName.gridy = 2; add(textFieldCompanyName, gbc_textFieldCompanyName); textFieldCompanyName.setColumns(10); JLabel lblCustomerCode = new JLabel("\u5BA2\u6237\u7F16\u53F7\uFF1A"); GridBagConstraints gbc_lblCustomerCode = new GridBagConstraints(); gbc_lblCustomerCode.anchor = GridBagConstraints.EAST; gbc_lblCustomerCode.insets = new Insets(0, 0, 5, 5); gbc_lblCustomerCode.gridx = 0; gbc_lblCustomerCode.gridy = 3; add(lblCustomerCode, gbc_lblCustomerCode); textFieldCustomerCode = new JTextField(); GridBagConstraints gbc_textFieldCustomerCode = new GridBagConstraints(); gbc_textFieldCustomerCode.insets = new Insets(0, 0, 5, 5); gbc_textFieldCustomerCode.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldCustomerCode.gridx = 1; gbc_textFieldCustomerCode.gridy = 3; add(textFieldCustomerCode, gbc_textFieldCustomerCode); textFieldCustomerCode.setColumns(10); JLabel lblCustomerName = new JLabel("\u5BA2\u6237\u540D\u79F0\uFF1A"); GridBagConstraints gbc_lblCustomerName = new GridBagConstraints(); gbc_lblCustomerName.anchor = GridBagConstraints.EAST; gbc_lblCustomerName.insets = new Insets(0, 0, 5, 5); gbc_lblCustomerName.gridx = 0; gbc_lblCustomerName.gridy = 4; add(lblCustomerName, gbc_lblCustomerName); textFieldCustomerName = new JTextField(); GridBagConstraints gbc_textFieldCustomerName = new GridBagConstraints(); gbc_textFieldCustomerName.insets = new Insets(0, 0, 5, 5); gbc_textFieldCustomerName.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldCustomerName.gridx = 1; gbc_textFieldCustomerName.gridy = 4; add(textFieldCustomerName, gbc_textFieldCustomerName); textFieldCustomerName.setColumns(10); JLabel lblLicenseType = new JLabel("\u8BC1\u4E66\u7C7B\u578B\uFF1A"); GridBagConstraints gbc_lblLicenseType = new GridBagConstraints(); gbc_lblLicenseType.anchor = GridBagConstraints.EAST; gbc_lblLicenseType.insets = new Insets(0, 0, 5, 5); gbc_lblLicenseType.gridx = 0; gbc_lblLicenseType.gridy = 5; add(lblLicenseType, gbc_lblLicenseType); comboBoxLicenseType = new JComboBox(); GridBagConstraints gbc_comboBoxLicenseType = new GridBagConstraints(); gbc_comboBoxLicenseType.insets = new Insets(0, 0, 5, 5); gbc_comboBoxLicenseType.fill = GridBagConstraints.HORIZONTAL; gbc_comboBoxLicenseType.gridx = 1; gbc_comboBoxLicenseType.gridy = 5; add(comboBoxLicenseType, gbc_comboBoxLicenseType); JLabel lblExpiredDate = new JLabel("\u8FC7\u671F\u65F6\u95F4\uFF1A"); GridBagConstraints gbc_lblExpiredDate = new GridBagConstraints(); gbc_lblExpiredDate.insets = new Insets(0, 0, 5, 5); gbc_lblExpiredDate.gridx = 0; gbc_lblExpiredDate.gridy = 6; add(lblExpiredDate, gbc_lblExpiredDate); datePickerExpiredDate = new DatePicker(new Date(), "yyyy-MM-dd", null, null); GridBagConstraints gbc_datePicker = new GridBagConstraints(); gbc_datePicker.anchor = GridBagConstraints.WEST; gbc_datePicker.insets = new Insets(0, 0, 5, 5); gbc_datePicker.gridx = 1; gbc_datePicker.gridy = 6; add(datePickerExpiredDate, gbc_datePicker); JButton btnSave = new JButton("\u4FDD\u5B58"); btnSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { //???????? if (comboBoxProduct.getSelectedIndex() <= 0) { JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "??"); return; } String[] array = StringUtils.split(comboBoxProduct.getSelectedItem().toString(), '-'); String productCode = array[0]; String productName = array[1]; String customerCode = textFieldCustomerCode.getText(); //?? File configFile = ResourceUtils.getFile(Gui.HOME_PATH + File.separator + "config.xml"); Document document = XmlUtils.readXml(configFile); Element customerNode = (Element) document.selectSingleNode( "//product[@code='" + productCode + "']/customer[@code='" + customerCode + "']"); if (customerNode != null) { JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "???"); return; } String licenseId = new RandomGUID().toString(); String licenseType = Utility.splitStringAll(comboBoxLicenseType.getSelectedItem().toString(), " - ")[0]; String companyName = textFieldCompanyName.getText(); String customerName = textFieldCustomerName.getText(); String version = textFieldProductVersion.getText(); Date expiredDate = Utility.parseDate(datePickerExpiredDate.getText()); License license = new License(); license.setLicenseId(licenseId); license.setLicenseType(licenseType); license.setProductName(productName); license.setCompanyName(companyName); license.setCustomerName(customerName); license.setVersion(Version.parseVersion(version)); license.setCreateDate(new Date()); license.setExpiredDate(expiredDate); LicenseService service = new LicenseService(); String productPath = Gui.HOME_PATH + File.separator + productCode; File licenseDir = new File(productPath, customerCode); if (!licenseDir.exists()) { licenseDir.mkdir(); //? FileUtils.copyFileToDirectory(new File(productPath, "license.key"), licenseDir); } File priKeyFile = new File(Gui.HOME_PATH + File.separator + productCode, "private.key"); File licenseFile = new File(licenseDir, "license.xml"); service.save(Gui.HOME_PATH, productCode, customerCode, license, priKeyFile, licenseFile); //??zip? File customerPath = licenseFile.getParentFile(); //???license????? File licensePath = new File(customerPath.getParent(), "license"); if (!licensePath.exists() && !licensePath.isDirectory()) { licensePath.mkdir(); } else { FileUtils.cleanDirectory(licensePath); } //? FileUtils.copyDirectory(customerPath, licensePath); String currentTime = FormatDateTime.formatDateTimeNum(new Date()); ZipUtils.zip(licensePath, new File(licensePath.getParentFile(), customerCode + "-" + currentTime + ".zip")); //license FileUtils.deleteDirectory(licensePath); JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "??"); } catch (Exception e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), e1.getMessage()); } } }); GridBagConstraints gbc_btnSave = new GridBagConstraints(); gbc_btnSave.insets = new Insets(0, 0, 5, 5); gbc_btnSave.gridx = 1; gbc_btnSave.gridy = 7; add(btnSave, gbc_btnSave); //?? initData(); }
From source file:de.codesourcery.eve.skills.ui.components.impl.PriceInfoComponent.java
@Override protected JPanel createPanelHook() { final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); final String kind; switch (priceType) { case BUY:// w w w . j ava2 s.c o m kind = "buy"; break; case SELL: default: throw new RuntimeException( "Invalid data in switch/case: PriceInfo.Type.ALL cannot be queried from user"); } minPrice.addActionListener(listener); maxPrice.addActionListener(listener); avgPrice.addActionListener(listener); final TextArea desc = new TextArea(); desc.setText(message); desc.setEditable(false); panel.add(desc, constraints(0, 0).width(2).resizeBoth().end()); panel.add(new JLabel("Minimum " + kind + " price"), constraints(0, 1).useRelativeWidth().end()); panel.add(minPrice, constraints(1, 1).useRemainingWidth().end()); panel.add(new JLabel("Average " + kind + " price"), constraints(0, 2).useRelativeWidth().end()); panel.add(avgPrice, constraints(1, 2).useRemainingWidth().end()); panel.add(new JLabel("Maximum " + kind + " price"), constraints(0, 3).useRelativeWidth().end()); panel.add(maxPrice, constraints(1, 3).useRemainingWidth().end()); return panel; }
From source file:StoppUhr.java
private void initGUI() { try {/*from w ww . j av a 2 s.c o m*/ AnchorLayout thisLayout = new AnchorLayout(); getContentPane().setLayout(thisLayout); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setPreferredSize(new java.awt.Dimension(609, 394)); { jPanel3 = new JPanel(); GridBagLayout jPanel3Layout = new GridBagLayout(); jPanel3.setLayout(jPanel3Layout); getContentPane().add(jPanel3, new AnchorConstraint(668, 811, 978, 19, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jPanel3.setPreferredSize(new java.awt.Dimension(384, 94)); { jScrollPane1 = new JScrollPane(); jPanel3.add(jScrollPane1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jScrollPane1.setPreferredSize(new java.awt.Dimension(300, 90)); { jTextArea = new JTextArea(); jScrollPane1.setViewportView(jTextArea); jTextArea.setText(""); } } { jTextFieldStNr = new JTextField(); jPanel3.add(jTextFieldStNr, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jTextFieldStNr.setText(""); jTextFieldStNr.setPreferredSize(new java.awt.Dimension(150, 90)); jTextFieldStNr.setHorizontalAlignment(JTextField.CENTER); jTextFieldStNr.setFont(new Font(Font.DIALOG, Font.BOLD, 40)); } jPanel3Layout.rowWeights = new double[] { 0.1 }; jPanel3Layout.rowHeights = new int[] { 7 }; jPanel3Layout.columnWeights = new double[] { 0.1, 0.1 }; jPanel3Layout.columnWidths = new int[] { 7, 7 }; } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[] { 0.1, 0.1 }; jPanel2Layout.rowHeights = new int[] { 7, 7 }; jPanel2Layout.columnWeights = new double[] { 0.1 }; jPanel2Layout.columnWidths = new int[] { 7 }; jPanel2.setLayout(jPanel2Layout); getContentPane().add(jPanel2, new AnchorConstraint(47, 821, 721, 27, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jPanel2.setPreferredSize(new java.awt.Dimension(363, 178)); { uhrzeitAusgabe = new JLabel(); jPanel2.add(uhrzeitAusgabe, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); uhrzeitAusgabe.setText("00:00:00"); uhrzeitAusgabe.setFont(new Font(Font.DIALOG, Font.BOLD, uhrFontSize)); } { stoppuhrAusgabe = new JLabel(); jPanel2.add(stoppuhrAusgabe, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); stoppuhrAusgabe.setText("00:00:00"); stoppuhrAusgabe.setFont(new Font(Font.DIALOG, Font.BOLD, uhrFontSize)); } } { jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); getContentPane().add(jPanel1, new AnchorConstraint(48, 987, 954, 820, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); jPanel1Layout.rowWeights = new double[] { 0.1, 0.1, 0.1, 1.0, 0.1 }; jPanel1Layout.rowHeights = new int[] { 1, 1, 1, 1, 1 }; jPanel1Layout.columnWeights = new double[] { 0.1 }; jPanel1Layout.columnWidths = new int[] { 7 }; jPanel1.setLayout(jPanel1Layout); jPanel1.setPreferredSize(new java.awt.Dimension(100, 330)); { startButton = new JButton(); jPanel1.add(startButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); startButton.setPreferredSize(new java.awt.Dimension(90, 30)); startButton.setText("Start"); } { resetButton = new JButton(); jPanel1.add(resetButton, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); resetButton.setText("Reset"); resetButton.setPreferredSize(new java.awt.Dimension(90, 30)); } { jPanel4 = new JPanel(); GridBagLayout jPanel4Layout = new GridBagLayout(); jPanel1.add(jPanel4, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jPanel4.setPreferredSize(new java.awt.Dimension(51, 81)); jPanel4Layout.rowWeights = new double[] { 0.1, 0.1, 0.1 }; jPanel4Layout.rowHeights = new int[] { 7, 7, 7 }; jPanel4Layout.columnWeights = new double[] { 0.1 }; jPanel4Layout.columnWidths = new int[] { 7 }; jPanel4.setLayout(jPanel4Layout); { plusButton = new JButton(); jPanel4.add(plusButton, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); plusButton.setText("+"); plusButton.setPreferredSize(new java.awt.Dimension(50, 30)); } { minusButton = new JButton(); jPanel4.add(minusButton, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); minusButton.setText("-"); minusButton.setPreferredSize(new java.awt.Dimension(50, 30)); } { jLabelFontSize = new JLabel(); jPanel4.add(jLabelFontSize, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabelFontSize.setFont(new Font(Font.DIALOG, Font.PLAIN, 10)); jLabelFontSize.setText("Font Size"); } } } this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { thisWindowClosing(evt); } }); startButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { startButtonListener(evt); } }); resetButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { resetButtonListener(evt); } }); jTextFieldStNr.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { try { stNrFieldListener(evt); } catch (IOException e) { e.printStackTrace(); } } }); plusButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { plusButtonListener(evt); } }); minusButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { minusButtonListener(evt); } }); pack(); this.setSize(609, 394); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:gdt.jgui.entity.contact.JContactEditor.java
public JContactEditor() { GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 100, 0, 0 }; gridBagLayout.rowHeights = new int[] { 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0 }; setLayout(gridBagLayout);/*from w w w .j a va 2 s .c o m*/ JLabel lblTitle = new JLabel("Label"); GridBagConstraints gbc_lblTitle = new GridBagConstraints(); gbc_lblTitle.insets = new Insets(5, 5, 5, 5); gbc_lblTitle.gridx = 0; gbc_lblTitle.gridy = 0; gbc_lblTitle.anchor = GridBagConstraints.NORTHWEST; add(lblTitle, gbc_lblTitle); title = new JTextField(); GridBagConstraints gbc_title = new GridBagConstraints(); gbc_title.insets = new Insets(5, 0, 5, 5); gbc_title.fill = GridBagConstraints.HORIZONTAL; gbc_title.gridx = 1; gbc_title.gridy = 0; add(title, gbc_title); title.setColumns(10); JLabel lblPhone = new JLabel("Phone"); GridBagConstraints gbc_lblphone = new GridBagConstraints(); gbc_lblphone.insets = new Insets(5, 5, 5, 5); gbc_lblphone.gridx = 0; gbc_lblphone.gridy = 1; gbc_lblphone.anchor = GridBagConstraints.NORTHWEST; add(lblPhone, gbc_lblphone); phone = new JTextField(); GridBagConstraints gbc_phone = new GridBagConstraints(); gbc_phone.insets = new Insets(5, 0, 5, 5); gbc_phone.fill = GridBagConstraints.HORIZONTAL; gbc_phone.gridx = 1; gbc_phone.gridy = 1; add(phone, gbc_phone); phone.setColumns(10); JLabel lblEmail = new JLabel("Email"); GridBagConstraints gbc_lblEmail = new GridBagConstraints(); gbc_lblEmail.insets = new Insets(5, 5, 5, 5); gbc_lblEmail.gridx = 0; gbc_lblEmail.gridy = 2; gbc_lblEmail.anchor = GridBagConstraints.NORTHWEST; add(lblEmail, gbc_lblEmail); email = new JTextField(); GridBagConstraints gbc_email = new GridBagConstraints(); gbc_phone.insets = new Insets(5, 0, 5, 5); gbc_email.fill = GridBagConstraints.HORIZONTAL; gbc_email.gridx = 1; gbc_email.gridy = 2; add(email, gbc_email); email.setColumns(10); JPanel panel = new JPanel(); GridBagConstraints gbc_panel = new GridBagConstraints(); gbc_panel.weighty = 1.0; gbc_panel.insets = new Insets(5, 0, 5, 5); gbc_panel.fill = GridBagConstraints.BOTH; gbc_panel.gridx = 0; gbc_panel.gridy = 3; add(panel, gbc_panel); panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); }
From source file:fxts.stations.ui.UIFrontEnd.java
/** * Creating new fxts.stations.ui.SideLayout object or java.awt.GridBagLayout by default. * * @return LayoutManager//ww w.j av a 2 s. c o m */ public LayoutManager getSideLayout() { try { return new SideLayout(); } catch (Exception e) { mLogger.error("Load layout error: " + e + " load default : java.awt.GridBagLayout"); return new GridBagLayout(); } }
From source file:SocketApplet.java
/** Initialize the GUI nicely. */ public void init() { Label aLabel;/*from w ww.java2 s. c om*/ setLayout(new GridBagLayout()); int LOGO_COL = 1; int LABEL_COL = 2; int TEXT_COL = 3; int BUTTON_COL = 1; GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx = 100.0; gbc.weighty = 100.0; gbc.gridx = LABEL_COL; gbc.gridy = 0; gbc.anchor = GridBagConstraints.EAST; add(aLabel = new Label("Name:", Label.CENTER), gbc); gbc.anchor = GridBagConstraints.CENTER; gbc.gridx = TEXT_COL; gbc.gridy = 0; add(nameTF = new TextField(10), gbc); gbc.gridx = LABEL_COL; gbc.gridy = 1; gbc.anchor = GridBagConstraints.EAST; add(aLabel = new Label("Password:", Label.CENTER), gbc); gbc.anchor = GridBagConstraints.CENTER; gbc.gridx = TEXT_COL; gbc.gridy = 1; add(passTF = new TextField(10), gbc); passTF.setEchoChar('*'); gbc.gridx = LABEL_COL; gbc.gridy = 2; gbc.anchor = GridBagConstraints.EAST; add(aLabel = new Label("Domain:", Label.CENTER), gbc); gbc.anchor = GridBagConstraints.CENTER; gbc.gridx = TEXT_COL; gbc.gridy = 2; add(domainTF = new TextField(10), gbc); sendButton = new Button("Send data"); gbc.gridx = BUTTON_COL; gbc.gridy = 3; gbc.gridwidth = 3; add(sendButton, gbc); whence = getCodeBase(); // Now the action begins... sendButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String name = nameTF.getText(); if (name.length() == 0) { showStatus("Name required"); return; } String domain = domainTF.getText(); if (domain.length() == 0) { showStatus("Domain required"); return; } showStatus("Connecting to host " + whence.getHost() + " as " + nameTF.getText()); try { Socket s = new Socket(getCodeBase().getHost(), 3333); PrintWriter pf = new PrintWriter(s.getOutputStream(), true); // send login name pf.println(nameTF.getText()); // passwd pf.println(passTF.getText()); // and domain pf.println(domainTF.getText()); BufferedReader is = new BufferedReader(new InputStreamReader(s.getInputStream())); String response = is.readLine(); showStatus(response); } catch (IOException e) { showStatus("ERROR: " + e.getMessage()); } } }); }
From source file:net.chaosserver.timelord.swingui.SummaryPanel.java
/** * Constructs the panel./*www . ja va2 s .co m*/ */ protected void buildSummaryPanel() { GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridBagConstraints = new GridBagConstraints(); setLayout(gridBagLayout); if (isToday()) { JLabel remainderName = new JLabel("Remainder"); gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST; gridBagConstraints.weightx = LayoutConstants.HEAVY_WEIGHT; gridBagConstraints.insets = new Insets(0, LayoutConstants.SMALL_INSET, 0, LayoutConstants.BIG_INSET); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.gridwidth = 1; gridBagLayout.addLayoutComponent(remainderName, gridBagConstraints); add(remainderName); timeLeftLabel = new JLabel(); gridBagConstraints.anchor = GridBagConstraints.SOUTHEAST; gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.weightx = 0; gridBagConstraints.insets = new Insets(0, LayoutConstants.BIG_INSET, 0, LayoutConstants.SMALL_INSET); gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.addLayoutComponent(timeLeftLabel, gridBagConstraints); add(timeLeftLabel); } JLabel taskName = new JLabel("Total"); gridBagConstraints.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = LayoutConstants.HEAVY_WEIGHT; gridBagConstraints.insets = new Insets(0, LayoutConstants.SMALL_INSET, 0, LayoutConstants.BIG_INSET); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.gridwidth = 1; gridBagLayout.addLayoutComponent(taskName, gridBagConstraints); add(taskName); totalTimeLabel = new JLabel(); gridBagConstraints.anchor = GridBagConstraints.NORTHEAST; gridBagConstraints.fill = GridBagConstraints.NONE; gridBagConstraints.weightx = 0; gridBagConstraints.insets = new Insets(0, LayoutConstants.BIG_INSET, 0, LayoutConstants.SMALL_INSET); gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.addLayoutComponent(totalTimeLabel, gridBagConstraints); add(totalTimeLabel); updateTotalTimeLabel(); updateTimeLeftLabel(); }
From source file:wef.articulab.view.ui.CombinedBNXYPlot.java
/** * Creates a new demo instance.//from w w w. j a v a 2s . co m */ public CombinedBNXYPlot(String name1, String name2, String title1, String title2, String[] series1, String[] series2, boolean shouldPlot) { super("Social Reasoner"); Container content = getContentPane(); content.setLayout(new GridBagLayout()); JPanel chartCSPanel = null; JPanel chartPhasePanel = null; if (shouldPlot) { chartContainer1 = new ChartContainer(name1, title1, series1); chartCSPanel = createChartPanel(chartContainer1); if (name2 != null) { chartContainer2 = new ChartContainer(name2, title2, series2); chartPhasePanel = createChartPanel(chartContainer2); } else { chartCSPanel.setPreferredSize(new Dimension(970, 750)); } } inputPanel = createInputPanel(); outputPanel = createOutputPanel(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; add(outputPanel, gbc); add(Box.createRigidArea(new Dimension(0, 40))); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; add(inputPanel, gbc); if (shouldPlot) { if (chartPhasePanel != null) { gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; add(chartCSPanel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; add(chartPhasePanel, gbc); } else { gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.gridheight = 2; add(chartCSPanel, gbc); } } pack(); setVisible(true); setResizable(false); }
From source file:com.jaxzin.iraf.forecast.swing.JForecaster.java
@SuppressWarnings({ "FieldRepeatedlyAccessedInMethod" }) private void initialize() { // final GridBagLayout gridbag = new GridBagLayout(); setLayout(new GridBagLayout());//new BoxLayout(this, BoxLayout.PAGE_AXIS)); controlPanel = new JForecasterControl(domain); final JFreeChart chart = createJFreeChart(); final JPanel chartPanel = new ChartPanel(chart, true); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weighty = 1.0;//from w ww . j a v a 2s . c om c.gridx = 0; c.gridy = 0; // gridbag.setConstraints(chartPanel, c); add(chartPanel, c); // todo: change to changelistener of JControlPanel domain.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent e) { chart.getXYPlot().setDataset(createDataset()); //noinspection CallToStringEquals if ("adjustForInflation".equals(e.getPropertyName())) { final String label; if (domain.isAdjustForInflation()) { label = "Account Value (Adjusted to Today's Value)"; } else { label = "Account Value"; } logAxis.setLabel(label); linearAxis.setLabel(label); } } }); controlPanel.addPropertyChangeListener("logScale", new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent e) { if (controlPanel.isLogScale()) { chart.getXYPlot().setRangeAxis(logAxis); } else { chart.getXYPlot().setRangeAxis(linearAxis); } } }); c.weighty = 0.0; c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.SOUTH; // gridbag.setConstraints(controlPanel, c1); add(controlPanel, c); }
From source file:com.lottery.gui.MainLotteryForm.java
public void init() { initComponents();/*from www. jav a 2 s. c om*/ setTitle("Lottery"); // ballNumbersPanel.setLayout(new BoxLayout(ballNumbersPanel, BoxLayout.Y_AXIS)); ballNumbersPanel.setLayout(new GridBagLayout()); ballNumbersPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); // c.fill = GridBagConstraints.HORIZONTAL; tfBuyerName.setFocusable(true); tfBuyerName.requestFocusInWindow(); WinnerTableModel model = new WinnerTableModel(); model.setData(winTicketTables); tblWinners.setModel(model); resetGame(); // pnStart.setLayout(new GridBagLayout()); // pnStart.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); // DateFormat format = new SimpleDateFormat("yyyy--MMMM--dd"); // GridBagConstraints pnStartConstraint = new GridBagConstraints(); // pnStartConstraint.fill = GridBagConstraints.HORIZONTAL; // // lbDrawDate = new JLabel("Date"); // pnStartConstraint.gridx = 0; // pnStartConstraint.gridy = 0; // pnStart.add(lbDrawDate, pnStartConstraint); // // tfDrawDate = new JFormattedTextField(format); // pnStartConstraint.gridx = 1; // pnStartConstraint.gridy = 0; // pnStart.add(tfDrawDate, pnStartConstraint); }