List of usage examples for java.awt Insets Insets
public Insets(int top, int left, int bottom, int right)
From source file:components.ProgressBarDemo.java
public ProgressBarDemo() { super(new BorderLayout()); //Create the demo's UI. startButton = new JButton("Start"); startButton.setActionCommand("start"); startButton.addActionListener(this); progressBar = new JProgressBar(0, 100); progressBar.setValue(0);/*from w w w . j a v a 2 s. c o m*/ progressBar.setStringPainted(true); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false); JPanel panel = new JPanel(); panel.add(startButton); panel.add(progressBar); add(panel, BorderLayout.PAGE_START); add(new JScrollPane(taskOutput), BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:com.sshtools.common.ui.OptionsPanel.java
/** * * * @param parent//from w w w . j ava 2 s . co m * @param tabs tabs * * @return */ public static boolean showOptionsDialog(Component parent, OptionsTab[] tabs) { final OptionsPanel opts = new OptionsPanel(tabs); opts.reset(); JDialog d = null; Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, parent); if (w instanceof JDialog) { d = new JDialog((JDialog) w, "Options", true); } else if (w instanceof JFrame) { d = new JDialog((JFrame) w, "Options", true); } else { d = new JDialog((JFrame) null, "Options", true); } final JDialog dialog = d; // Create the bottom button panel final JButton cancel = new JButton("Cancel"); cancel.setMnemonic('c'); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { opts.cancelled = true; dialog.setVisible(false); } }); final JButton ok = new JButton("Ok"); ok.setMnemonic('o'); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (opts.validateTabs()) { dialog.setVisible(false); } } }); dialog.getRootPane().setDefaultButton(ok); JPanel buttonPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(6, 6, 0, 0); gbc.weighty = 1.0; UIUtil.jGridBagAdd(buttonPanel, ok, gbc, GridBagConstraints.RELATIVE); UIUtil.jGridBagAdd(buttonPanel, cancel, gbc, GridBagConstraints.REMAINDER); JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); southPanel.add(buttonPanel); // JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); mainPanel.add(opts, BorderLayout.CENTER); mainPanel.add(southPanel, BorderLayout.SOUTH); // Show the dialog dialog.getContentPane().setLayout(new GridLayout(1, 1)); dialog.getContentPane().add(mainPanel); dialog.pack(); dialog.setResizable(true); UIUtil.positionComponent(SwingConstants.CENTER, dialog); dialog.setVisible(true); if (!opts.cancelled) { opts.applyTabs(); } return !opts.cancelled; }
From source file:com.litt.core.security.license.gui.ConfigPanel.java
/** * Create the panel./*from ww w . j a v a2 s.c om*/ */ public ConfigPanel(final Gui gui) { GridBagLayout gbl_configPanel = new GridBagLayout(); gbl_configPanel.columnWidths = new int[] { 0, 0, 0, 0 }; gbl_configPanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; gbl_configPanel.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE }; gbl_configPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; this.setLayout(gbl_configPanel); JLabel label_18 = new JLabel("?"); GridBagConstraints gbc_label_18 = new GridBagConstraints(); gbc_label_18.insets = new Insets(0, 0, 5, 5); gbc_label_18.anchor = GridBagConstraints.EAST; gbc_label_18.gridx = 0; gbc_label_18.gridy = 0; this.add(label_18, gbc_label_18); comboBox_config = new JComboBox(); comboBox_config.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { try { LicenseConfig licenseConfig = (LicenseConfig) e.getItem(); File licenseFile = new File(licenseConfig.getLicenseFilePath()); currentLicenseConfig = licenseConfig; loadLicense(licenseFile); gui.setCurrentLicenseConfig(currentLicenseConfig); } catch (Exception e1) { JOptionPane.showMessageDialog(self, e1.getMessage()); } } } }); GridBagConstraints gbc_comboBox_config = new GridBagConstraints(); gbc_comboBox_config.insets = new Insets(0, 0, 5, 5); gbc_comboBox_config.fill = GridBagConstraints.HORIZONTAL; gbc_comboBox_config.gridx = 1; gbc_comboBox_config.gridy = 0; this.add(comboBox_config, gbc_comboBox_config); JButton button_3 = new JButton("?"); button_3.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { try { comboBox_config.removeAllItems(); File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml"); Document document = XmlUtils.readXml(configFile); Element rootE = document.getRootElement(); List productList = rootE.elements(); for (int i = 0; i < productList.size(); i++) { Element productE = (Element) productList.get(i); String productCode = productE.attributeValue("code"); List customerList = productE.elements(); for (int j = 0; j < customerList.size(); j++) { Element customerE = (Element) customerList.get(j); String customerCode = customerE.attributeValue("code"); LicenseConfig licenseConfig = new LicenseConfig(); licenseConfig.setProductCode(productCode); licenseConfig.setCustomerCode(customerCode); licenseConfig.setLicenseId(customerE.elementText("licenseId")); licenseConfig.setEncryptedLicense(customerE.elementText("encryptedLicense")); licenseConfig.setRootFilePath(Gui.HOME_PATH); licenseConfig.setLicenseFilePath(Gui.HOME_PATH + File.separator + productCode + File.separator + customerCode + File.separator + "license.xml"); licenseConfig.setPriKeyFilePath( Gui.HOME_PATH + File.separator + productCode + File.separator + "private.key"); licenseConfig.setPubKeyFilePath( Gui.HOME_PATH + File.separator + productCode + File.separator + "license.key"); comboBox_config.addItem(licenseConfig); if (i == 0 && j == 0) { File licenseFile = new File(licenseConfig.getLicenseFilePath()); currentLicenseConfig = licenseConfig; loadLicense(licenseFile); gui.setCurrentLicenseConfig(currentLicenseConfig); btnDelete.setEnabled(true); } } } } catch (Exception e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(self, e1.getMessage()); } } }); btnDelete = new JButton(); btnDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (currentLicenseConfig != null) { try { String productCode = currentLicenseConfig.getProductCode(); String customerCode = currentLicenseConfig.getCustomerCode(); //congfig.xml File configFile = new File(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) { customerNode.detach(); XmlUtils.writeXml(configFile, document); } // File licensePathFile = new File(currentLicenseConfig.getLicenseFilePath()); if (licensePathFile.exists()) { FileUtils.deleteDirectory(licensePathFile.getParentFile()); } //comboboxitem comboBox_config.removeItemAt(comboBox_config.getSelectedIndex()); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (comboBox_config.getItemCount() <= 0) { btnDelete.setEnabled(false); } } } }); btnDelete.setEnabled(false); btnDelete.setIcon(new ImageIcon(ConfigPanel.class.getResource("/images/icon_delete.png"))); GridBagConstraints gbc_btnDelete = new GridBagConstraints(); gbc_btnDelete.insets = new Insets(0, 0, 5, 0); gbc_btnDelete.gridx = 2; gbc_btnDelete.gridy = 0; add(btnDelete, gbc_btnDelete); GridBagConstraints gbc_button_3 = new GridBagConstraints(); gbc_button_3.insets = new Insets(0, 0, 5, 5); gbc_button_3.gridx = 1; gbc_button_3.gridy = 1; this.add(button_3, gbc_button_3); JLabel lblid = new JLabel("?ID"); GridBagConstraints gbc_lblid = new GridBagConstraints(); gbc_lblid.anchor = GridBagConstraints.EAST; gbc_lblid.insets = new Insets(0, 0, 5, 5); gbc_lblid.gridx = 0; gbc_lblid.gridy = 2; this.add(lblid, gbc_lblid); textField_licenseId = new JTextField(); GridBagConstraints gbc_textField_licenseId = new GridBagConstraints(); gbc_textField_licenseId.insets = new Insets(0, 0, 5, 5); gbc_textField_licenseId.fill = GridBagConstraints.HORIZONTAL; gbc_textField_licenseId.gridx = 1; gbc_textField_licenseId.gridy = 2; this.add(textField_licenseId, gbc_textField_licenseId); textField_licenseId.setColumns(10); JLabel label = new JLabel("?"); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.anchor = GridBagConstraints.EAST; gbc_label.insets = new Insets(0, 0, 5, 5); gbc_label.gridx = 0; gbc_label.gridy = 3; add(label, gbc_label); comboBox_licenseType = new JComboBox(MapComboBoxModel.getLicenseTypeOptions().toArray()); GridBagConstraints gbc_comboBox_licenseType = new GridBagConstraints(); gbc_comboBox_licenseType.insets = new Insets(0, 0, 5, 5); gbc_comboBox_licenseType.fill = GridBagConstraints.HORIZONTAL; gbc_comboBox_licenseType.gridx = 1; gbc_comboBox_licenseType.gridy = 3; add(comboBox_licenseType, gbc_comboBox_licenseType); JLabel label_23 = new JLabel("???"); GridBagConstraints gbc_label_23 = new GridBagConstraints(); gbc_label_23.anchor = GridBagConstraints.EAST; gbc_label_23.insets = new Insets(0, 0, 5, 5); gbc_label_23.gridx = 0; gbc_label_23.gridy = 4; this.add(label_23, gbc_label_23); textField_productName = new JTextField(); GridBagConstraints gbc_textField_productName = new GridBagConstraints(); gbc_textField_productName.insets = new Insets(0, 0, 5, 5); gbc_textField_productName.fill = GridBagConstraints.HORIZONTAL; gbc_textField_productName.gridx = 1; gbc_textField_productName.gridy = 4; this.add(textField_productName, gbc_textField_productName); textField_productName.setColumns(10); JLabel label_24 = new JLabel("???"); GridBagConstraints gbc_label_24 = new GridBagConstraints(); gbc_label_24.anchor = GridBagConstraints.EAST; gbc_label_24.insets = new Insets(0, 0, 5, 5); gbc_label_24.gridx = 0; gbc_label_24.gridy = 5; this.add(label_24, gbc_label_24); textField_companyName = new JTextField(); GridBagConstraints gbc_textField_companyName = new GridBagConstraints(); gbc_textField_companyName.insets = new Insets(0, 0, 5, 5); gbc_textField_companyName.fill = GridBagConstraints.HORIZONTAL; gbc_textField_companyName.gridx = 1; gbc_textField_companyName.gridy = 5; this.add(textField_companyName, gbc_textField_companyName); textField_companyName.setColumns(10); JLabel label_25 = new JLabel("??"); GridBagConstraints gbc_label_25 = new GridBagConstraints(); gbc_label_25.anchor = GridBagConstraints.EAST; gbc_label_25.insets = new Insets(0, 0, 5, 5); gbc_label_25.gridx = 0; gbc_label_25.gridy = 6; this.add(label_25, gbc_label_25); textField_customerName = new JTextField(); GridBagConstraints gbc_textField_customerName = new GridBagConstraints(); gbc_textField_customerName.insets = new Insets(0, 0, 5, 5); gbc_textField_customerName.fill = GridBagConstraints.HORIZONTAL; gbc_textField_customerName.gridx = 1; gbc_textField_customerName.gridy = 6; this.add(textField_customerName, gbc_textField_customerName); textField_customerName.setColumns(10); JLabel label_26 = new JLabel(""); GridBagConstraints gbc_label_26 = new GridBagConstraints(); gbc_label_26.anchor = GridBagConstraints.EAST; gbc_label_26.insets = new Insets(0, 0, 5, 5); gbc_label_26.gridx = 0; gbc_label_26.gridy = 7; this.add(label_26, gbc_label_26); textField_version = new JTextField(); GridBagConstraints gbc_textField_version = new GridBagConstraints(); gbc_textField_version.insets = new Insets(0, 0, 5, 5); gbc_textField_version.fill = GridBagConstraints.HORIZONTAL; gbc_textField_version.gridx = 1; gbc_textField_version.gridy = 7; this.add(textField_version, gbc_textField_version); textField_version.setColumns(10); JLabel label_27 = new JLabel(""); GridBagConstraints gbc_label_27 = new GridBagConstraints(); gbc_label_27.insets = new Insets(0, 0, 5, 5); gbc_label_27.gridx = 0; gbc_label_27.gridy = 8; this.add(label_27, gbc_label_27); datePicker_expiredDate = new DatePicker(new Date(), "yyyy-MM-dd", null, null); //datePicker_expiredDate.setTimePanleVisible(false); GridBagConstraints gbc_datePicker_expiredDate = new GridBagConstraints(); gbc_datePicker_expiredDate.anchor = GridBagConstraints.WEST; gbc_datePicker_expiredDate.insets = new Insets(0, 0, 5, 5); gbc_datePicker_expiredDate.gridx = 1; gbc_datePicker_expiredDate.gridy = 8; this.add(datePicker_expiredDate, gbc_datePicker_expiredDate); JButton button_5 = new JButton(""); button_5.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (currentLicenseConfig != null) { try { File priKeyFile = new File(currentLicenseConfig.getPriKeyFilePath()); File licenseFile = new File(currentLicenseConfig.getLicenseFilePath()); //?? License license = new License(); license.setLicenseId(textField_licenseId.getText()); license.setLicenseType( ((MapComboBoxModel) comboBox_licenseType.getSelectedItem()).getValue().toString()); license.setProductName(textField_productName.getText()); license.setCompanyName(textField_companyName.getText()); license.setCustomerName(textField_customerName.getText()); license.setVersion(Version.parseVersion(textField_version.getText())); license.setCreateDate(new Date()); license.setExpiredDate(Utility.parseDate(datePicker_expiredDate.getText())); //???? DigitalSignatureTool utils = new DigitalSignatureTool("DSA"); utils.readPriKey(priKeyFile.getAbsolutePath()); //?? String signedData = utils.sign(license.toString()); //?????? license.setSignature(signedData); LicenseManager.writeLicense(license, licenseFile); //config.xml String licenseContent = XmlUtils.readXml(licenseFile).asXML(); //DES ISecurity security = new DESTool(currentLicenseConfig.getLicenseId(), Algorithm.BLOWFISH); licenseContent = security.encrypt(licenseContent); txt_encryptContent.setText(licenseContent); currentLicenseConfig.setEncryptedLicense(licenseContent); System.out.println(licenseContent); File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml"); XMLConfiguration config = new XMLConfiguration(configFile); config.setAutoSave(true); config.setProperty("product.customer.encryptedLicense", licenseContent); //??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(), currentLicenseConfig.getCustomerCode() + "-" + currentTime + ".zip")); //license FileUtils.deleteDirectory(licensePath); JOptionPane.showMessageDialog(self, "??"); } catch (Exception e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(self, e1.getMessage()); } } else { JOptionPane.showMessageDialog(self, "???"); } } }); GridBagConstraints gbc_button_5 = new GridBagConstraints(); gbc_button_5.insets = new Insets(0, 0, 5, 5); gbc_button_5.gridx = 1; gbc_button_5.gridy = 9; this.add(button_5, gbc_button_5); JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.insets = new Insets(0, 0, 0, 5); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 1; gbc_scrollPane.gridy = 10; this.add(scrollPane, gbc_scrollPane); txt_encryptContent = new JTextArea(); txt_encryptContent.setLineWrap(true); scrollPane.setViewportView(txt_encryptContent); // txt_encryptContent = new JTextArea(20, 20); // GridBagConstraints gbc_6 = new GridBagConstraints(); // gbc_6.gridx = 1; // gbc_6.gridy = 10; // this.add(txt_encryptContent, gbc_6); }
From source file:com.sec.ose.osi.ui.dialog.progress.JDlgProgress.java
/** * This method initializes jPanelContent * //from w ww .ja v a 2s . c o m * @return javax.swing.JPanel */ private JPanel getJPanelContent() { if (jPanelContent == null) { GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.fill = GridBagConstraints.BOTH; gridBagConstraints1.gridy = 0; gridBagConstraints1.weightx = 1.0; gridBagConstraints1.weighty = 1.0; gridBagConstraints1.insets = new Insets(35, 25, 0, 25); gridBagConstraints1.gridx = 0; GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints2.weightx = 1.0; gridBagConstraints2.weighty = 1.0; gridBagConstraints2.gridx = 0; gridBagConstraints2.insets = new Insets(35, 25, 0, 25); gridBagConstraints2.gridy = 1; GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.gridx = 0; gridBagConstraints3.insets = new Insets(20, 0, 20, 0); gridBagConstraints3.gridy = 2; jPanelContent = new JPanel(); jPanelContent.setLayout(new GridBagLayout()); jPanelContent.setPreferredSize(new Dimension(350, 150)); jPanelContent.add(getJTextAreaMessage(), gridBagConstraints1); jPanelContent.add(getJButtonCancel(), gridBagConstraints3); } return jPanelContent; }
From source file:gate.creole.kea.CorpusImporter.java
protected void initGUIComponents() { setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridy = 0;//from ww w . j a va2 s . c o m constraints.gridx = GridBagConstraints.RELATIVE; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.BOTH; JPanel inputPanel = new JPanel(new GridBagLayout()); inputPanel.setBorder(BorderFactory.createTitledBorder("Input")); GridBagConstraints constraints2 = new GridBagConstraints(); constraints2.gridy = 0; constraints2.gridx = GridBagConstraints.RELATIVE; constraints2.weighty = 0; constraints2.weightx = 0; constraints2.fill = GridBagConstraints.BOTH; constraints2.insets = new Insets(2, 2, 2, 2); JLabel label = new JLabel("Source directory:"); inputPanel.add(label, constraints2); sourceDirTField = new JTextField(30); inputPanel.add(sourceDirTField, constraints2); JButton openButton = new JButton(new SelectDirectoryAction()); inputPanel.add(openButton, constraints2); constraints2.gridy = 1; label = new JLabel("Extension for text files:"); inputPanel.add(label, constraints2); constraints2.gridwidth = 2; textExtensionTField = new JTextField(".txt"); inputPanel.add(textExtensionTField, constraints2); constraints2.gridwidth = 1; constraints2.gridy = 2; label = new JLabel("Extension for keyphrase files:"); inputPanel.add(label, constraints2); constraints2.gridwidth = 2; keyExtensionTField = new JTextField(".key"); inputPanel.add(keyExtensionTField, constraints2); constraints2.gridwidth = 1; constraints2.gridy = 3; label = new JLabel("Encoding for input files:"); inputPanel.add(label, constraints2); constraints2.gridwidth = 2; encodingTField = new JTextField(""); inputPanel.add(encodingTField, constraints2); constraints2.gridwidth = 1; add(inputPanel, constraints); constraints.weightx = 1; add(Box.createHorizontalGlue(), constraints); constraints.weightx = 0; JPanel outputPanel = new JPanel(); outputPanel.setLayout(new GridBagLayout()); outputPanel.setBorder(BorderFactory.createTitledBorder("Output")); constraints2.gridy = 0; label = new JLabel("Corpus name:"); outputPanel.add(label, constraints2); constraints2.weightx = 1; corpusNameTField = new JTextField("KEA Corpus"); constraints2.weightx = 0; outputPanel.add(corpusNameTField, constraints2); constraints2.gridy = 1; label = new JLabel("Output annotation set:"); outputPanel.add(label, constraints2); constraints2.weightx = 1; annotationSetTField = new JTextField("Key"); constraints2.weightx = 0; outputPanel.add(annotationSetTField, constraints2); constraints2.gridy = 2; label = new JLabel("Keyphrase annotation type:"); outputPanel.add(label, constraints2); constraints2.weightx = 1; annotationTypeTField = new JTextField("Keyphrase"); constraints2.weightx = 0; outputPanel.add(annotationTypeTField, constraints2); constraints.gridy = 1; add(outputPanel, constraints); constraints.gridy = 2; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.CENTER; add(new JButton(new ImportCorpusAction()), constraints); constraints.gridy = 3; constraints.weighty = 1; add(Box.createVerticalGlue(), constraints); }
From source file:PizzaGridBagLayout.java
private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align) { GridBagConstraints gc = new GridBagConstraints(); gc.gridx = x;//from w w w. ja v a 2s.c o m gc.gridy = y; gc.gridwidth = width; gc.gridheight = height; gc.weightx = 100.0; gc.weighty = 100.0; gc.insets = new Insets(5, 5, 5, 5); gc.anchor = align; gc.fill = GridBagConstraints.NONE; p.add(c, gc); }
From source file:Demo.ScatterGraph.java
public ScatterGraph(int sampleNb, List<String> paraType_list) { this.sampleNb = sampleNb; this.paraType_list = paraType_list; // widgets: charts(JFreeChart), parameter selectors (JList) DefaultListModel xModel = new DefaultListModel(); xSelector = new JList(xModel); JScrollPane xSelPane = new JScrollPane(); xSelPane.setViewportView(xSelector); DefaultListModel yModel = new DefaultListModel(); ySelector = new JList(yModel); JScrollPane ySelPane = new JScrollPane(); ySelPane.setViewportView(ySelector); charts = new JFreeChart[paraType_list.size()][paraType_list.size()]; for (int i = 0; i < paraType_list.size(); i++) { String para = paraType_list.get(i); xModel.addElement(para);//from w w w.j av a2 s. co m yModel.addElement(para); for (int j = 0; j < paraType_list.size(); j++) { charts[i][j] = null; } } charts[0][0] = CreateChart(0, 0); chartPane = new ChartPanel(charts[0][0]); xSelector.setSelectedIndex(0); ySelector.setSelectedIndex(0); xSelector.addMouseListener(this); ySelector.addMouseListener(this); // layout GridBagLayout layout = new GridBagLayout(); setLayout(layout); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(5, 20, 5, 5); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 20; gbc.weighty = 12; gbc.gridheight = 4; add(chartPane, gbc); gbc.insets = new Insets(5, 5, 5, 20); gbc.gridx = 1; gbc.weightx = 1; gbc.gridheight = 1; gbc.gridy = 0; gbc.weighty = 1; add(new JLabel("X :"), gbc); gbc.gridy = 2; add(new JLabel("Y :"), gbc); gbc.gridy = 1; gbc.weighty = 5; add(xSelPane, gbc); gbc.gridy = 3; add(ySelPane, gbc); }
From source file:ProgressMonitorDemo.java
public ProgressMonitorDemo() { super(new BorderLayout()); // Create the demo's UI. startButton = new JButton("Start"); startButton.setActionCommand("start"); startButton.addActionListener(this); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false);//ww w. j av a2 s .c o m add(startButton, BorderLayout.PAGE_START); add(new JScrollPane(taskOutput), BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:e3fraud.gui.MainWindow.java
public MainWindow() { super(new BorderLayout(5, 5)); extended = false;//from w ww .j ava 2 s . com //Create the log first, because the action listeners //need to refer to it. log = new JTextArea(10, 50); log.setMargin(new Insets(5, 5, 5, 5)); log.setEditable(false); logScrollPane = new JScrollPane(log); DefaultCaret caret = (DefaultCaret) log.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); // create the progress bar progressBar = new JProgressBar(0, 100); progressBar.setValue(progressBar.getMinimum()); progressBar.setVisible(false); progressBar.setStringPainted(true); //Create the settings pane generationSettingLabel = new JLabel("Generate:"); SpinnerModel collusionsSpinnerModel = new SpinnerNumberModel(1, 0, 3, 1); collusionSettingsPanel = new JPanel(new FlowLayout()) { @Override public Dimension getMaximumSize() { return getPreferredSize(); } }; // collusionSettingsPanel.setLayout(new BoxLayout(collusionSettingsPanel, BoxLayout.X_AXIS)); collusionsButton = new JSpinner(collusionsSpinnerModel); collusionsLabel = new JLabel("collusion(s)"); collusionSettingsPanel.add(collusionsButton); collusionSettingsPanel.add(collusionsLabel); rankingSettingLabel = new JLabel("Rank by:"); lossButton = new JRadioButton("loss"); lossButton.setToolTipText("Sort sub-ideal models based on loss for Target of Assessment (high -> low)"); gainButton = new JRadioButton("gain"); gainButton.setToolTipText( "Sort sub-ideal models based on gain of any actor except Target of Assessment (high -> low)"); lossGainButton = new JRadioButton("loss + gain"); lossGainButton.setToolTipText( "Sort sub-ideal models based on loss for Target of Assessment and, if equal, on gain of any actor except Target of Assessment"); //gainLossButton = new JRadioButton("gain + loss"); lossGainButton.setSelected(true); rankingGroup = new ButtonGroup(); rankingGroup.add(lossButton); rankingGroup.add(gainButton); rankingGroup.add(lossGainButton); //rankingGroup.add(gainLossButton); groupingSettingLabel = new JLabel("Group by:"); groupingButton = new JCheckBox("collusion"); groupingButton.setToolTipText( "Groups sub-ideal models based on the pair of actors colluding before ranking them"); groupingButton.setSelected(false); refreshButton = new JButton("Refresh"); refreshButton.addActionListener(this); settingsPanel = new JPanel(); settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS)); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); settingsPanel.add(generationSettingLabel); collusionSettingsPanel.setAlignmentX(LEFT_ALIGNMENT); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); settingsPanel.add(collusionSettingsPanel); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); rankingSettingLabel.setAlignmentY(TOP_ALIGNMENT); settingsPanel.add(rankingSettingLabel); settingsPanel.add(lossButton); settingsPanel.add(gainButton); settingsPanel.add(lossGainButton); //settingsPanel.add(gainLossButton); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); settingsPanel.add(groupingSettingLabel); settingsPanel.add(groupingButton); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); settingsPanel.add(refreshButton); settingsPanel.add(Box.createRigidArea(new Dimension(0, 20))); progressBar.setPreferredSize( new Dimension(settingsPanel.getSize().width, progressBar.getPreferredSize().height)); settingsPanel.add(progressBar); //Create the result tree root = new DefaultMutableTreeNode("No models to display"); treeModel = new DefaultTreeModel(root); tree = new JTree(treeModel); //tree.setUI(new CustomTreeUI()); tree.setCellRenderer(new CustomTreeCellRenderer(tree)); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setLargeModel(true); resultScrollPane = new JScrollPane(tree); tree.addTreeSelectionListener(treeSelectionListener); //tree.setShowsRootHandles(true); //Create a file chooser for saving sfc = new JFileChooser(); FileFilter jpegFilter = new FileNameExtensionFilter("JPEG image", new String[] { "jpg", "jpeg" }); sfc.addChoosableFileFilter(jpegFilter); sfc.setFileFilter(jpegFilter); //Create a file chooser for loading fc = new JFileChooser(); FileFilter rdfFilter = new FileNameExtensionFilter("RDF file", "RDF"); fc.addChoosableFileFilter(rdfFilter); fc.setFileFilter(rdfFilter); //Create the open button. openButton = new JButton("Load model", createImageIcon("images/Open24.png")); openButton.addActionListener(this); openButton.setToolTipText("Load a e3value model"); //Create the ideal graph button. idealGraphButton = new JButton("Show ideal graph", createImageIcon("images/Plot.png")); idealGraphButton.setToolTipText("Display ideal profitability graph"); idealGraphButton.addActionListener(this); Dimension thinButtonDimension = new Dimension(15, 420); //Create the expand subideal graph button. expandButton = new JButton(">"); expandButton.setPreferredSize(thinButtonDimension); expandButton.setMargin(new Insets(0, 0, 0, 0)); expandButton.setToolTipText("Expand to show non-ideal profitability graph for selected model"); expandButton.addActionListener(this); //Create the collapse sub-ideal graph button. collapseButton = new JButton("<"); collapseButton.setPreferredSize(thinButtonDimension); collapseButton.setMargin(new Insets(0, 0, 0, 0)); collapseButton.setToolTipText("Collapse non-ideal profitability graph for selected model"); collapseButton.addActionListener(this); //Create the generation button. generateButton = new JButton("Generate sub-ideal models", createImageIcon("images/generate.png")); generateButton.addActionListener(this); generateButton.setToolTipText("Generate sub-ideal models for the e3value model currently loaded"); //Create the chart panel chartPane = new JPanel(); chartPane.setLayout(new FlowLayout(FlowLayout.LEFT)); chartPane.add(expandButton); //For layout purposes, put the buttons in a separate panel JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.add(openButton); buttonPanel.add(Box.createRigidArea(new Dimension(20, 0))); buttonPanel.add(generateButton); buttonPanel.add(Box.createRigidArea(new Dimension(10, 0))); buttonPanel.add(idealGraphButton); //Add the buttons, the ranking options, the result list and the log to this panel. add(buttonPanel, BorderLayout.PAGE_START); add(settingsPanel, BorderLayout.LINE_START); add(resultScrollPane, BorderLayout.CENTER); add(logScrollPane, BorderLayout.PAGE_END); add(chartPane, BorderLayout.LINE_END); //and make a nice border around it setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10)); }
From source file:MultipartViewer.java
protected void setupDisplay(Multipart mp) { // we display the first body part in a main frame on the left, and then // on the right we display the rest of the parts as attachments GridBagConstraints gc = new GridBagConstraints(); gc.gridheight = GridBagConstraints.REMAINDER; gc.fill = GridBagConstraints.BOTH; gc.weightx = 1.0;// w w w .ja va 2 s .com gc.weighty = 1.0; // get the first part try { BodyPart bp = mp.getBodyPart(0); Component comp = getComponent(bp); add(comp, gc); } catch (MessagingException me) { add(new Label(me.toString()), gc); } // see if there are more than one parts try { int count = mp.getCount(); // setup how to display them gc.gridwidth = GridBagConstraints.REMAINDER; gc.gridheight = 1; gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.NORTH; gc.weightx = 0.0; gc.weighty = 0.0; gc.insets = new Insets(4, 4, 4, 4); // for each one we create a button with the content type for (int i = 1; i < count; i++) { // we skip the first one BodyPart curr = mp.getBodyPart(i); String label = null; if (label == null) label = curr.getFileName(); if (label == null) label = curr.getDescription(); if (label == null) label = curr.getContentType(); Button but = new Button(label); but.addActionListener(new AttachmentViewer(curr)); add(but, gc); } } catch (MessagingException me2) { me2.printStackTrace(); } }