List of usage examples for java.awt Insets Insets
public Insets(int top, int left, int bottom, int right)
From source file:net.chaosserver.timelord.swingui.SummaryPanel.java
/** * Constructs the panel./*from w ww . ja va 2 s.c om*/ */ 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:com.digitalgeneralists.assurance.ui.components.FileAttributesPanel.java
private void initializeComponent() { if (!this.initialized) { if (this.file == null) { this.dialogTitle = "No File Provided"; this.file = null; } else {// w ww. ja v a2s . c om StringBuilder title = new StringBuilder(128); this.dialogTitle = title.append("Attributes for ").append(file.getFile().getName()).toString(); title.setLength(0); title = null; } GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); GridBagConstraints filePanelConstraints = new GridBagConstraints(); filePanelConstraints.anchor = GridBagConstraints.NORTH; filePanelConstraints.fill = GridBagConstraints.HORIZONTAL; filePanelConstraints.gridx = 0; filePanelConstraints.gridy = 0; filePanelConstraints.weightx = 1.0; filePanelConstraints.weighty = 0.1; filePanelConstraints.gridheight = 1; filePanelConstraints.gridwidth = 1; filePanelConstraints.insets = new Insets(5, 5, 5, 5); final JPanel filePanel = new JPanel(); filePanel.setLayout(new GridBagLayout()); GridBagConstraints filePathValueConstraints = new GridBagConstraints(); filePathValueConstraints.anchor = GridBagConstraints.WEST; filePathValueConstraints.gridx = 0; filePathValueConstraints.gridy = 0; filePathValueConstraints.weightx = 1.0; filePathValueConstraints.weighty = 1.0; filePathValueConstraints.gridheight = 1; filePathValueConstraints.gridwidth = 1; filePathValueConstraints.insets = new Insets(5, 5, 5, 5); String filePath = "File is null."; if (file != null) { File diskFile = file.getFile(); if (diskFile == null) { filePath = "The disk file is not set."; } else { filePath = diskFile.getPath(); } diskFile = null; } JLabel filePathValue = new JLabel(filePath); filePath = null; filePanel.add(filePathValue, filePathValueConstraints); this.add(filePanel, filePanelConstraints); Border attributesBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); attributesBorder = BorderFactory.createTitledBorder(attributesBorder, "File Attributes", TitledBorder.CENTER, TitledBorder.TOP); GridBagConstraints attributesPanelConstraints = new GridBagConstraints(); attributesPanelConstraints.anchor = GridBagConstraints.SOUTH; attributesPanelConstraints.fill = GridBagConstraints.BOTH; attributesPanelConstraints.gridx = 0; attributesPanelConstraints.gridy = 1; attributesPanelConstraints.weightx = 1.0; attributesPanelConstraints.weighty = 0.9; attributesPanelConstraints.gridheight = 1; attributesPanelConstraints.gridwidth = 1; attributesPanelConstraints.insets = new Insets(0, 5, 5, 5); JPanel attributesPanel = this.createFileAttributesPanel(file); attributesPanel.setBorder(attributesBorder); this.add(attributesPanel, attributesPanelConstraints); this.initialized = true; } }
From source file:com.adito.upgrade.GUIUpgrader.java
public GUIUpgrader() { super(new BorderLayout()); JPanel info = new JPanel(new BorderLayout(2, 2)); // info.setBackground(Color.white); // info.setForeground(Color.black); // info.setOpaque(true); info.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); JLabel l = new JLabel("<html><p>This utility upgrades configuration from " + "one version 0.1.16 installation to another " + "0.2.5+ installation. You may choose which resources you " + "wish to be copied. If resources with the same name already " + "exist they will be left as is."); l.setIcon(new ImageIcon(GUIUpgrader.class.getResource("upgrader-48x48.png"))); info.add(l, BorderLayout.CENTER); info.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH); mainPanel = new JPanel(new BorderLayout()); add(info, BorderLayout.NORTH); add(mainPanel, BorderLayout.CENTER); // Installations panel JPanel installations = new JPanel(new GridBagLayout()); installations.setBorder(BorderFactory.createTitledBorder("Installations")); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(2, 2, 2, 2); gbc.weightx = 2.0;//w w w .ja v a 2 s. c o m UIUtil.jGridBagAdd(installations, new JLabel("Source"), gbc, GridBagConstraints.REMAINDER); gbc.weightx = 1.0; source = new JTextField(); source.getDocument().addDocumentListener(this); UIUtil.jGridBagAdd(installations, source, gbc, GridBagConstraints.RELATIVE); browseSource = new JButton("Browse"); browseSource.setMnemonic('b'); browseSource.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(source.getText()); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Select source installation directory (0.16.1)"); if (chooser.showOpenDialog(GUIUpgrader.this) == JFileChooser.APPROVE_OPTION) { source.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); gbc.weightx = 0.0; UIUtil.jGridBagAdd(installations, browseSource, gbc, GridBagConstraints.REMAINDER); gbc.weightx = 2.0; UIUtil.jGridBagAdd(installations, new JLabel("Target"), gbc, GridBagConstraints.REMAINDER); gbc.weightx = 1.0; target = new JTextField(System.getProperty("user.dir")); target.getDocument().addDocumentListener(this); UIUtil.jGridBagAdd(installations, target, gbc, GridBagConstraints.RELATIVE); browseTarget = new JButton("Browse"); browseTarget.setMnemonic('r'); browseTarget.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(target.getText()); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Select target installation directory (0.2.5+)"); if (chooser.showOpenDialog(GUIUpgrader.this) == JFileChooser.APPROVE_OPTION) { target.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); gbc.weightx = 0.0; UIUtil.jGridBagAdd(installations, browseTarget, gbc, GridBagConstraints.REMAINDER); mainPanel.add(installations, BorderLayout.NORTH); // Upgrade selection upgradeSelectionPanel = new JPanel(); upgradeSelectionPanel.setBorder(BorderFactory.createTitledBorder("Upgrades")); upgradeSelectionPanel.setLayout(new BoxLayout(upgradeSelectionPanel, BoxLayout.Y_AXIS)); mainPanel.add(upgradeSelectionPanel, BorderLayout.CENTER); }
From source file:com.sshtools.common.ui.HostsTab.java
/** * Creates a new HostsTab object./*from ww w . j a va2 s . c o m*/ * * @param hostKeyVerifier */ public HostsTab(AbstractKnownHostsKeyVerification hostKeyVerifier) { super(); this.hostKeyVerifier = hostKeyVerifier; hosts = new JList(model = new HostsListModel()); hosts.setVisibleRowCount(10); hosts.setCellRenderer(new HostRenderer()); hosts.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { setAvailableActions(); } }); remove = new JButton("Remove", new ResourceIcon(REMOVE_ICON)); remove.addActionListener(this); //deny = new JButton("Deny", new ResourceIcon(DENY_ICON)); //deny.addActionListener(this); JPanel b = new JPanel(new GridBagLayout()); b.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 0, 4, 0); gbc.anchor = GridBagConstraints.NORTH; gbc.weightx = 1.0; UIUtil.jGridBagAdd(b, remove, gbc, GridBagConstraints.REMAINDER); gbc.weighty = 1.0; //UIUtil.jGridBagAdd(b, deny, gbc, GridBagConstraints.REMAINDER); JPanel s = new JPanel(new BorderLayout()); s.add(new JScrollPane(hosts), BorderLayout.CENTER); s.add(b, BorderLayout.EAST); IconWrapperPanel w = new IconWrapperPanel(new ResourceIcon(GLOBAL_ICON), s); // This tab setLayout(new BorderLayout()); add(w, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); reset(); }
From source file:com.microsoft.alm.plugin.idea.common.ui.common.forms.TfsLoginForm.java
private void ensureInitialized() { if (!initialized) { // Ensure that the commands are set up correctly signInLink.setActionCommand(CMD_SIGN_IN); // Ensure that fonts are scaled appropriately headerLabel.setFont(JBUI.Fonts.label(20.0f)); signInLink.setFont(JBUI.Fonts.label(16.0f)); exampleLabel.setFont(JBUI.Fonts.label(9.0f)); // Make sure the busy spinner size is scaled properly Dimension size = new Dimension(JBUI.scale(20), JBUI.scale(20)); busySpinner.setPreferredSize(size); busySpinner.setMinimumSize(size); // Add some margin under the description label descriptionLabel.setMargin(new Insets(0, 0, JBUI.scale(15), 0)); initialized = true;/*from w ww . j a v a2 s . co m*/ } }
From source file:org.bench4Q.console.ui.section.LW_ConfigLoadShowSection.java
/** * @param resources//from w w w. j a va2 s. c o m * @param processControl * @param dispatcherFactory * @param configModel * @param configLoadSection * @throws ConsoleException */ public LW_ConfigLoadShowSection(Resources resources, ProcessControl processControl, SwingDispatcherFactory dispatcherFactory, ConfigModel configModel, LW_ConfigLoadSection configLoadSection) throws ConsoleException { m_resources = resources; m_processControl = processControl; m_swingDispatcherFactory = dispatcherFactory; m_configModel = configModel; m_args = m_configModel.getArgs(); this.setLayout(new GridBagLayout()); this.setPreferredSize(new Dimension(683, 475)); this.setMinimumSize(new Dimension(683, 475)); picPanel = new PicPanel(m_args); // JPanel picPanel = new JPanel(); this.add(picPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); m_configModel.addListener(new ConfigModel.AbstractListener() { public void isArgsChanged() { resetConfig(); } }); configLoadSection.addListener(new LW_ConfigLoadSection.AbstractListener() { public void isArgsChanged() { resetConfig(); } }); }
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);/*ww w . j a v a 2s . 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:interpolation.InteractiveRegression.java
public void Card() { CardLayout cl = new CardLayout(); panelCont.setLayout(cl);/*from w ww.j a v a2 s .c o m*/ panelCont.add(panelFirst, "1"); panelCont.add(panelSecond, "2"); panelFirst.setName("Regression Polynomial Fits"); /* Instantiation */ final GridBagLayout layout = new GridBagLayout(); final GridBagConstraints c = new GridBagConstraints(); final Scrollbar degreeSB = new Scrollbar(Scrollbar.HORIZONTAL, this.degreeInt, 1, MIN_SLIDER, MAX_SLIDER + 1); final Label degreeLabel = new Label("Degree of polynomial = " + this.degree, Label.CENTER); // Location panelFirst.setLayout(layout); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; c.weightx = 1; ++c.gridy; c.insets = new Insets(30, 150, 0, 150); panelFirst.add(degreeSB, c); ++c.gridy; c.insets = new Insets(30, 150, 0, 150); panelFirst.add(degreeLabel, c); degreeSB.addAdjustmentListener(new DegreeListener(this, degreeLabel, degreeSB)); panelFirst.setVisible(true); cl.show(panelCont, "1"); Cardframe.add(panelCont, BorderLayout.CENTER); Cardframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Cardframe.pack(); Cardframe.setVisible(true); updateRegression(); }
From source file:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java
@Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { // Dirty hack: the last item in the serverlist is always a fake server // that when double clicked produces an "add new server" wizard. if (value == null) { return getNewServerServer(list, index, isSelected); }//from ww w . ja va 2 s. co m final Server server = (Server) value; final JPanel p = createServerPanel(server, list, index, isSelected); final Color foreground = getForegroundColor(list, index, isSelected); final JLabel label = getServernameComponent(server, foreground); final JLabel tags = getTagComponent(server, foreground); // final ChartPanel chartPanel = getChartPanelComponent(); final GraphPanelCache gcp = GraphPanelCache.get(); final Component chartOrNothing; if (server.getServerStatistics() == null) { chartOrNothing = new JLabel(); } else { chartOrNothing = gcp.inBareServerCache(server) ? gcp.getBareChartPanel(server) : createAndStoreBareChartPanel(list, server); } p.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.gridx = 0; c.gridy = 0; c.insets = new Insets(5, 5, 1, 5); c.anchor = GridBagConstraints.FIRST_LINE_START; p.add(label, c); c.insets = new Insets(0, 5, 5, 5); c.gridy = 1; p.add(tags, c); c.fill = GridBagConstraints.BOTH; c.weighty = 1.0; c.gridy = 2; p.add(chartOrNothing, c); return p; }
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 w ww . j a v a 2 s . c o m*/ 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(); }