List of usage examples for java.awt GridBagConstraints EAST
int EAST
To view the source code for java.awt GridBagConstraints EAST.
Click Source Link
From source file:EditorPaneExample15.java
public EditorPaneExample15() { super("JEditorPane Example 15"); pane = new JEditorPane(); pane.setEditable(false); // Read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;/*from w w w. jav a 2 s . c o m*/ c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; urlCombo = new JComboBox(); panel.add(urlCombo, c); urlCombo.setEditable(true); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, c); getContentPane().add(panel, "South"); // Allocate the empty tree model DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty"); emptyModel = new DefaultTreeModel(emptyRootNode); // Create and place the heading tree tree = new JTree(emptyModel); tree.setPreferredSize(new Dimension(200, 200)); getContentPane().add(new JScrollPane(tree), "East"); // Change page based on combo selection urlCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (populatingCombo == true) { return; } Object selection = urlCombo.getSelectedItem(); loadNewPage(selection); } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadComplete(); displayLoadTime(); populateCombo(findLinks(pane.getDocument(), null)); TreeNode node = buildHeadingTree(pane.getDocument()); tree.setModel(new DefaultTreeModel(node)); enableInput(); loadingPage = false; } } }); // Listener for tree selection tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent evt) { TreePath path = evt.getNewLeadSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object userObject = node.getUserObject(); if (userObject instanceof Heading) { Heading heading = (Heading) userObject; try { Rectangle textRect = pane.modelToView(heading.getOffset()); textRect.y += 3 * textRect.height; pane.scrollRectToVisible(textRect); } catch (BadLocationException e) { } } } } }); // Listener for hypertext events pane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent evt) { // Ignore hyperlink events if the frame is busy if (loadingPage == true) { return; } if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane sp = (JEditorPane) evt.getSource(); if (evt instanceof HTMLFrameHyperlinkEvent) { HTMLDocument doc = (HTMLDocument) sp.getDocument(); doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt); } else { loadNewPage(evt.getURL()); } } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { pane.setCursor(handCursor); } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { pane.setCursor(defaultCursor); } } }); }
From source file:EditorPaneExample17.java
public EditorPaneExample17() { super("JEditorPane Example 17"); pane = new JEditorPane(); pane.setEditable(true); // Editable getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;//from w ww .j a v a 2 s . co m c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridy = 5; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; editableBox = new JCheckBox("Editable JEditorPane"); panel.add(editableBox, c); editableBox.setSelected(true); editableBox.setForeground(typeLabel.getForeground()); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; urlCombo = new JComboBox(); panel.add(urlCombo, c); urlCombo.setEditable(true); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, c); getContentPane().add(panel, "South"); // Register a custom EditorKit for HTML ClassLoader loader = getClass().getClassLoader(); if (loader != null) { // Java 2 JEditorPane.registerEditorKitForContentType("text/html", "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit", loader); } else { // JDK 1.1 JEditorPane.registerEditorKitForContentType("text/html", "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit"); } // Allocate the empty tree model DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty"); emptyModel = new DefaultTreeModel(emptyRootNode); // Create and place the heading tree tree = new JTree(emptyModel); tree.setPreferredSize(new Dimension(200, 200)); getContentPane().add(new JScrollPane(tree), "East"); // Change page based on combo selection urlCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (populatingCombo == true) { return; } Object selection = urlCombo.getSelectedItem(); loadNewPage(selection); } }); // Change editability based on the checkbox editableBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pane.setEditable(editableBox.isSelected()); pane.revalidate(); pane.repaint(); } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadComplete(); displayLoadTime(); populateCombo(findLinks(pane.getDocument(), null)); TreeNode node = buildHeadingTree(pane.getDocument()); tree.setModel(new DefaultTreeModel(node)); enableInput(); loadingPage = false; } } }); // Listener for tree selection tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent evt) { TreePath path = evt.getNewLeadSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object userObject = node.getUserObject(); if (userObject instanceof Heading) { Heading heading = (Heading) userObject; try { Rectangle textRect = pane.modelToView(heading.getOffset()); textRect.y += 3 * textRect.height; pane.scrollRectToVisible(textRect); } catch (BadLocationException e) { } } } } }); // Listener for hypertext events pane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent evt) { // Ignore hyperlink events if the frame is busy if (loadingPage == true) { return; } if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane sp = (JEditorPane) evt.getSource(); if (evt instanceof HTMLFrameHyperlinkEvent) { HTMLDocument doc = (HTMLDocument) sp.getDocument(); doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt); } else { loadNewPage(evt.getURL()); } } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { pane.setCursor(handCursor); } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { pane.setCursor(defaultCursor); } } }); }
From source file:EditorPaneExample13.java
public EditorPaneExample13() { super("JEditorPane Example 13"); pane = new JEditorPane(); pane.setEditable(false); // Read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;/* ww w . j av a2 s .c o m*/ c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; urlCombo = new JComboBox(); panel.add(urlCombo, c); urlCombo.setEditable(true); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, c); getContentPane().add(panel, "South"); // Load a new default style sheet InputStream is = EditorPaneExample13.class.getResourceAsStream("changedDefault.css"); if (is != null) { try { StyleSheet ss = loadStyleSheet(is); editorKit.setStyleSheet(ss); } catch (IOException e) { System.out.println("Failed to load new default style sheet"); } } // Allocate the empty tree model DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty"); emptyModel = new DefaultTreeModel(emptyRootNode); // Create and place the heading tree tree = new JTree(emptyModel); tree.setPreferredSize(new Dimension(200, 200)); getContentPane().add(new JScrollPane(tree), "East"); // Change page based on combo selection urlCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (populatingCombo == true) { return; } Object selection = urlCombo.getSelectedItem(); loadNewPage(selection); } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadComplete(); displayLoadTime(); populateCombo(findLinks(pane.getDocument(), null)); TreeNode node = buildHeadingTree(pane.getDocument()); tree.setModel(new DefaultTreeModel(node)); enableInput(); loadingPage = false; } } }); // Listener for tree selection tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent evt) { TreePath path = evt.getNewLeadSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object userObject = node.getUserObject(); if (userObject instanceof Heading) { Heading heading = (Heading) userObject; try { Rectangle textRect = pane.modelToView(heading.getOffset()); textRect.y += 3 * textRect.height; pane.scrollRectToVisible(textRect); } catch (BadLocationException e) { } } } } }); // Listener for hypertext events pane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent evt) { // Ignore hyperlink events if the frame is busy if (loadingPage == true) { return; } if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane sp = (JEditorPane) evt.getSource(); if (evt instanceof HTMLFrameHyperlinkEvent) { HTMLDocument doc = (HTMLDocument) sp.getDocument(); doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt); } else { loadNewPage(evt.getURL()); } } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { pane.setCursor(handCursor); } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { pane.setCursor(defaultCursor); } } }); }
From source file:EditorPaneExample14.java
public EditorPaneExample14() { super("JEditorPane Example 14"); pane = new JEditorPane(); pane.setEditable(false); // Read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;// w ww. j a va 2s .c o m c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; urlCombo = new JComboBox(); panel.add(urlCombo, c); urlCombo.setEditable(true); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, c); getContentPane().add(panel, "South"); // Modify the default style sheet InputStream is = EditorPaneExample14.class.getResourceAsStream("changedDefault.css"); if (is != null) { try { addToStyleSheet(editorKit.getStyleSheet(), is); } catch (IOException e) { System.out.println("Failed to modify default style sheet"); } } // Allocate the empty tree model DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty"); emptyModel = new DefaultTreeModel(emptyRootNode); // Create and place the heading tree tree = new JTree(emptyModel); tree.setPreferredSize(new Dimension(200, 200)); getContentPane().add(new JScrollPane(tree), "East"); // Change page based on combo selection urlCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (populatingCombo == true) { return; } Object selection = urlCombo.getSelectedItem(); loadNewPage(selection); } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadComplete(); displayLoadTime(); populateCombo(findLinks(pane.getDocument(), null)); TreeNode node = buildHeadingTree(pane.getDocument()); tree.setModel(new DefaultTreeModel(node)); enableInput(); loadingPage = false; } } }); // Listener for tree selection tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent evt) { TreePath path = evt.getNewLeadSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object userObject = node.getUserObject(); if (userObject instanceof Heading) { Heading heading = (Heading) userObject; try { Rectangle textRect = pane.modelToView(heading.getOffset()); textRect.y += 3 * textRect.height; pane.scrollRectToVisible(textRect); } catch (BadLocationException e) { } } } } }); // Listener for hypertext events pane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent evt) { // Ignore hyperlink events if the frame is busy if (loadingPage == true) { return; } if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane sp = (JEditorPane) evt.getSource(); if (evt instanceof HTMLFrameHyperlinkEvent) { HTMLDocument doc = (HTMLDocument) sp.getDocument(); doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt); } else { loadNewPage(evt.getURL()); } } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { pane.setCursor(handCursor); } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { pane.setCursor(defaultCursor); } } }); }
From source file:net.daboross.outputtablesclient.gui.OutputInterface.java
public OutputInterface(final Application application) { this.application = application; // persistEnabled JSONObject parentObj = application.getPersist().getStorageObject(); JSONObject tempPersistEnabled = parentObj.optJSONObject("last-shown-panels"); if (tempPersistEnabled == null) { tempPersistEnabled = new JSONObject(); parentObj.put("last-shown-panels", tempPersistEnabled); }/*from w w w .jav a2 s .c om*/ persistEnabled = tempPersistEnabled; // constraints toggleButtonConstraints = new GBC().ipadx(2).ipady(2).gridx(0).gridy(-1) .fill(GridBagConstraints.HORIZONTAL); tablePanelConstraints = new GBC().gridx(0).gridy(-1).weightx(1).weighty(0).anchor(GridBagConstraints.EAST) .fill(GridBagConstraints.HORIZONTAL); // mainTabPanel mainTabPanel = new JPanel(); mainTabPanel.setLayout(new GridBagLayout()); application.getRoot().getMainPanel().add(mainTabPanel, new GBC().weightx(1).weighty(1).fill(GridBagConstraints.BOTH).gridx(0).gridy(1)); // toggleButtonPanel toggleButtonPanel = new JPanel(); toggleButtonPanel.setLayout(new GridBagLayout()); mainTabPanel.add(toggleButtonPanel, new GBC().weightx(0).weighty(0).gridx(0).gridy(0) .insets(new Insets(0, 0, 10, 10)).anchor(GridBagConstraints.NORTHWEST)); // tableRootPanel tableRootPanel = new JPanel(new GridBagLayout()); mainTabPanel.add(tableRootPanel, new GBC().weightx(1).weighty(1).fill(GridBagConstraints.BOTH).gridx(2) .gridy(0).anchor(GridBagConstraints.EAST)); // maps tableKeyToTableButton = new TreeMap<>(); tableKeyToTableEnabled = new TreeMap<>(); tableKeyToTablePanel = new HashMap<>(); tableKeyAndKeyToValuePanel = new HashMap<>(); tableKeyAndKeyToValueLabel = new HashMap<>(); tableKeyToTableTitledBoarder = new HashMap<>(); }
From source file:savant.chromatogram.ChromatogramPlugin.java
@Override public void init(JPanel panel) { NavigationUtils.addLocationChangedListener(new Listener<LocationChangedEvent>() { @Override// w ww. jav a 2 s . co m public void handleEvent(LocationChangedEvent event) { updateChromatogram(); } }); GenomeUtils.addGenomeChangedListener(new Listener<GenomeChangedEvent>() { @Override public void handleEvent(GenomeChangedEvent event) { updateChromatogram(); } }); panel.setLayout(new GridBagLayout()); panel.setBorder(BorderFactory.createEtchedBorder()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridy = 0; gbc.anchor = GridBagConstraints.EAST; panel.add(new JLabel("File:"), gbc); pathField = new JTextField(); gbc.gridwidth = 3; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; panel.add(pathField, gbc); JButton browseButton = new JButton("Browse\u2026"); browseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { File f = DialogUtils.chooseFileForOpen("Chromatogram File", null, null); if (f != null) { try { pathField.setText(f.getAbsolutePath()); if (canvas != null) { canvas.getParent().remove(canvas); canvas = null; } chromatogram = ChromatogramFactory.create(f); updateEndField(); updateChromatogram(); } catch (UnsupportedChromatogramFormatException x) { DialogUtils.displayMessage("Unable to Open Chromatogram", String.format( "<html><i>%s</i> does not appear to be a valid chromatogram file.<br><br><small>Supported formats are ABI and SCF.</small></html>", f.getName())); } catch (Exception x) { DialogUtils.displayException("Unable to Open Chromatogram", String.format("<html>There was an error opening <i>%s</i>.</html>", f.getName()), x); } } } }); gbc.weightx = 0.0; gbc.fill = GridBagConstraints.NONE; panel.add(browseButton, gbc); JLabel startLabel = new JLabel("Start Base:"); gbc.gridy++; gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.EAST; panel.add(startLabel, gbc); startField = new JTextField("0"); startField.setColumns(12); startField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { updateEndField(); } }); gbc.weightx = 0.5; gbc.anchor = GridBagConstraints.WEST; panel.add(startField, gbc); JLabel endLabel = new JLabel("End Base:"); gbc.weightx = 0.0; gbc.anchor = GridBagConstraints.EAST; panel.add(endLabel, gbc); endField = new JTextField(); endField.setColumns(12); endField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { NumberFormat numberParser = NumberFormat.getIntegerInstance(); int endBase = numberParser.parse(endField.getText()).intValue(); if (chromatogram != null) { int startBase = endBase - chromatogram.getSequenceLength(); startField.setText(String.valueOf(startBase)); if (canvas != null) { canvas.updatePos(startBase); } } } catch (ParseException x) { Toolkit.getDefaultToolkit().beep(); } } }); gbc.weightx = 0.5; gbc.anchor = GridBagConstraints.WEST; panel.add(endField, gbc); JCheckBox fillCheck = new JCheckBox("Fill Background"); fillCheck.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { canvas.updateFillbackground(((JCheckBox) ae.getSource()).isSelected()); } }); gbc.gridy++; gbc.gridx = 1; gbc.weightx = 0.0; panel.add(fillCheck, gbc); // Add a filler panel at the bottom to force our components to the top. gbc.gridy++; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1.0; panel.add(new JPanel(), gbc); }
From source file:com.litt.core.security.license.gui.ConfigPanel.java
/** * Create the panel./*www.ja va2s .co m*/ */ 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:org.pentaho.reporting.engine.classic.demo.ancient.demo.internationalisation.LocaleSelectionReportController.java
public LocaleSelectionReportController() { final UpdateAction updateAction = new UpdateAction(); localesModel = createLocalesModel(); final JComboBox cbx = new JComboBox(localesModel); setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0;//from ww w . j a va 2 s . c o m gbc.gridy = 0; add(new JLabel("Select locale:"), gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.weightx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; add(cbx, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.anchor = GridBagConstraints.EAST; add(new JButton(updateAction)); }
From source file:org.openconcerto.erp.core.finance.accounting.ui.ResultatPanel.java
public ResultatPanel() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.add(new JLabel("Vous allez gnrer le fichier result_2033B.pdf contenant le rsultat."), c); c.gridy++;/*from www . ja v a 2 s . co m*/ try { this.add(new JLabel("Il se trouvera dans le dossier " + new File(TemplateNXProps.getInstance().getStringProperty("Location2033BPDF")) .getCanonicalPath()), c); } catch (IOException e1) { e1.printStackTrace(); } final JButton buttonFermer = new JButton("Fermer"); buttonFermer.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { ((JFrame) SwingUtilities.getRoot(ResultatPanel.this)).dispose(); } }); final JButton buttonOuvrir = new JButton("Ouvrir dossier"); buttonOuvrir.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { final String file = TemplateNXProps.getInstance().getStringProperty("Location2033BPDF"); File f = new File(file); FileUtils.browseFile(f); } }); // FIXME impossible de gnrer si le fichier est ouvert final JButton buttonGenerer = new JButton("Gnrer"); buttonGenerer.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { final Map2033B map = new Map2033B(new JProgressBar()); map.generateMap(); } }); c.gridx = GridBagConstraints.RELATIVE; c.gridwidth = 1; c.weightx = 0; c.fill = GridBagConstraints.NONE; this.add(buttonOuvrir, c); c.gridy++; c.anchor = GridBagConstraints.EAST; c.weightx = 1; buttonGenerer.setHorizontalAlignment(SwingConstants.RIGHT); this.add(buttonGenerer, c); c.weightx = 0; this.add(buttonFermer, c); }
From source file:SimpleAuthenticator.java
protected PasswordAuthentication getPasswordAuthentication() { // given a prompt? String prompt = getRequestingPrompt(); if (prompt == null) prompt = "Please login..."; // protocol/*from w ww. jav a 2 s . c o m*/ String protocol = getRequestingProtocol(); if (protocol == null) protocol = "Unknown protocol"; // get the host String host = null; InetAddress inet = getRequestingSite(); if (inet != null) host = inet.getHostName(); if (host == null) host = "Unknown host"; // port String port = ""; int portnum = getRequestingPort(); if (portnum != -1) port = ", port " + portnum + " "; // Build the info string String info = "Connecting to " + protocol + " mail service on host " + host + port; //JPanel d = new JPanel(); // XXX - for some reason using a JPanel here causes JOptionPane // to display incorrectly, so we workaround the problem using // an anonymous JComponent. JComponent d = new JComponent() { }; GridBagLayout gb = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); d.setLayout(gb); c.insets = new Insets(2, 2, 2, 2); c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0.0; d.add(constrain(new JLabel(info), gb, c)); d.add(constrain(new JLabel(prompt), gb, c)); c.gridwidth = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; d.add(constrain(new JLabel("Username:"), gb, c)); c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; String user = getDefaultUserName(); JTextField username = new JTextField(user, 20); d.add(constrain(username, gb, c)); c.gridwidth = 1; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; c.weightx = 0.0; d.add(constrain(new JLabel("Password:"), gb, c)); c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; JPasswordField password = new JPasswordField("", 20); d.add(constrain(password, gb, c)); // XXX - following doesn't work if (user != null && user.length() > 0) password.requestFocus(); else username.requestFocus(); int result = JOptionPane.showConfirmDialog(frame, d, "Login", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.OK_OPTION) return new PasswordAuthentication(username.getText(), password.getText()); else return null; }