public void setSideBarDescription(String description) { _imagePanel.setVisible(true); _descriptionTextArea.setText(description); Dimension d1 = _descriptionTextArea.getPreferredSize(); Dimension d2 = _descriptionTextArea.getSize(); _descriptionTextArea.setFont(new Font("Arial", Font.PLAIN, 8)); _descriptionTextArea.setSize(d2.width, d1.height); this.doLayout(); }
private void initializeGUIComponents() { topLevelContainer = new JPanel(); topLevelContainer.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); topLevelContainer.setLayout(new BoxLayout(topLevelContainer, BoxLayout.Y_AXIS)); setContentPane(topLevelContainer); JPanel formPanel = new JPanel(); JPanel errorPanel = new JPanel(); JPanel userAgreementNoticePanel = new JPanel(); JPanel userAgreementPanel = new JPanel(); JPanel alreadyRegisteredPanel = new JPanel(); JPanel buttonsPanel = new JPanel(); topLevelContainer.add(formPanel); topLevelContainer.add(errorPanel); topLevelContainer.add(Box.createVerticalGlue()); topLevelContainer.add(userAgreementNoticePanel); topLevelContainer.add(userAgreementPanel); topLevelContainer.add(alreadyRegisteredPanel); topLevelContainer.add(buttonsPanel); formPanel.setLayout(new BorderLayout()); JPanel formLabels = new JPanel(new GridLayout(11, 1)); formLabels.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); JPanel formFields = new JPanel(new GridLayout(11, 1)); formPanel.add(formLabels, BorderLayout.LINE_START); formPanel.add(formFields, BorderLayout.CENTER); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 1; formLabels.add(new JLabel("First Name")); firstNameField = new JTextField(); JPanel firstNameFieldPanel = new JPanel(new GridBagLayout()); firstNameFieldPanel.add(firstNameField, constraints); formFields.add(firstNameFieldPanel); formLabels.add(new JLabel("Last Name")); lastNameField = new JTextField(); JPanel lastNameFieldPanel = new JPanel(new GridBagLayout()); lastNameFieldPanel.add(lastNameField, constraints); formFields.add(lastNameFieldPanel); formLabels.add(new JLabel("Email Address")); emailAddressField = new JTextField(); JPanel emailAddressFieldPanel = new JPanel(new GridBagLayout()); emailAddressFieldPanel.add(emailAddressField, constraints); formFields.add(emailAddressFieldPanel); formLabels.add(new JLabel("")); femaleRadioButton = new JRadioButton("Female"); formFields.add(femaleRadioButton); formLabels.add(new JLabel("Sex")); maleRadioButton = new JRadioButton("Male"); formFields.add(maleRadioButton); formLabels.add(new JLabel("Country")); countryComboBox = new DisableableComboBox(); JPanel countryComboBoxPanel = new JPanel(new GridBagLayout()); countryComboBoxPanel.add(countryComboBox, constraints); formFields.add(countryComboBoxPanel); formLabels.add(new JLabel("Birthday (Optional)")); JPanel birthdayPanel = new JPanel(new GridLayout(1, 3, 10, 0)); formFields.add(birthdayPanel); birthdayYearComboBox = new JComboBox(); birthdayMonthComboBox = new JComboBox(); birthdayDayComboBox = new JComboBox(); JPanel birthdayYearComboBoxPanel = new JPanel(new GridBagLayout()); JPanel birthdayMonthComboBoxPanel = new JPanel(new GridBagLayout()); JPanel birthdayDayComboBoxPanel = new JPanel(new GridBagLayout()); birthdayYearComboBoxPanel.add(birthdayYearComboBox, constraints); birthdayMonthComboBoxPanel.add(birthdayMonthComboBox, constraints); birthdayDayComboBoxPanel.add(birthdayDayComboBox, constraints); birthdayPanel.add(birthdayYearComboBoxPanel); birthdayPanel.add(birthdayMonthComboBoxPanel); birthdayPanel.add(birthdayDayComboBoxPanel); formLabels.add(new JLabel("Password")); JPanel passwordFieldPanel = new JPanel(new GridBagLayout()); passwordField = new JPasswordField(); passwordFieldPanel.add(passwordField, constraints); formFields.add(passwordFieldPanel); formLabels.add(new JLabel("Password Confirmation")); JPanel passwordConfirmFieldPanel = new JPanel(new GridBagLayout()); passwordConfirmField = new JPasswordField(); passwordConfirmFieldPanel.add(passwordConfirmField, constraints); formFields.add(passwordConfirmFieldPanel); formLabels.add(new JLabel("Profile Picture")); JPanel filePanel = new JPanel(); filePanel.setLayout(new BoxLayout(filePanel, BoxLayout.X_AXIS)); imageFromFileRadioButton = new JRadioButton("Image from file"); filePanel.add(imageFromFileRadioButton); fileSelector = new FileSelector(filePanel); filePanel.add(fileSelector); formFields.add(filePanel); formLabels.add(new JLabel("")); noProfilePictureRadioButton = new JRadioButton("No profile picture"); formFields.add(noProfilePictureRadioButton); setMaxHeightToPreferredHeight(formPanel); errorPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 5)); errorLabel = new JLabel("Error message"); errorLabel.setForeground(Color.RED); errorPanel.add(errorLabel); setMaxHeightToPreferredHeight(errorPanel); userAgreementNoticePanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 5)); userAgreementNoticePanel.add( new JLabel("By clicking 'Create Account', you agree to the user agreement below:")); setMaxHeightToPreferredHeight(userAgreementNoticePanel); userAgreementPanel.setLayout(new BorderLayout()); JScrollPane userAgreementScrollPane = new JScrollPane(); userAgreementTextPane = new JTextPane(); userAgreementTextPane.setContentType("text/html"); userAgreementTextPane.setText("<b>This</b> is some test text!!!"); userAgreementTextPane.setPreferredSize( new Dimension(userAgreementTextPane.getPreferredSize().width, 150)); userAgreementScrollPane.setViewportView(userAgreementTextPane); userAgreementPanel.add(userAgreementScrollPane, BorderLayout.CENTER); setMaxHeightToPreferredHeight(userAgreementPanel); alreadyRegisteredPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 5)); alreadyRegisteredPanel.add(new JLabel("Already registered?")); setMaxHeightToPreferredHeight(alreadyRegisteredPanel); buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS)); loginButton = new JButton("Login"); cancelButton = new JButton("Cancel"); createAccountButton = new JButton("Create Account"); buttonsPanel.add(loginButton); buttonsPanel.add(Box.createHorizontalGlue()); buttonsPanel.add(cancelButton); buttonsPanel.add(Box.createRigidArea(new Dimension(10, 0))); buttonsPanel.add(createAccountButton); setMaxHeightToPreferredHeight(buttonsPanel); ButtonGroup sexButtonGroup = new ButtonGroup(); sexButtonGroup.add(maleRadioButton); sexButtonGroup.add(femaleRadioButton); ButtonGroup profilePictureButtonGroup = new ButtonGroup(); profilePictureButtonGroup.add(imageFromFileRadioButton); profilePictureButtonGroup.add(noProfilePictureRadioButton); }
public void doInit() { final InviteResponseMessageBox _this = this; if (!this.message.isDealtWith()) { // Show the response. this.responseBox = new Box(BoxLayout.Y_AXIS); this.add(this.responseBox); JComponent l = UIUtils.createBoldSubHeader( String.format( "%s the invitation", (this.message.isAccepted() ? "Accepted" : "Rejected")), (this.message.isAccepted() ? Constants.ACCEPTED_ICON_NAME : Constants.REJECTED_ICON_NAME)); this.responseBox.add(l); this.responseBox.setBorder(UIUtils.createPadding(5, 5, 0, 5)); if (this.message.isAccepted()) { if ((this.message.getEditorName() != null) || (this.message.getEditorAvatar() != null)) { JTextPane desc = UIUtils.createHelpTextPane( "Additionally they provided the following name/avatar.", this.projectViewer); this.responseBox.add(Box.createVerticalStrut(5)); this.responseBox.add(desc); desc.setBorder(null); desc.setSize(new Dimension(UIUtils.getPopupWidth() - 20, desc.getPreferredSize().height)); Box editorInfo = new Box(BoxLayout.X_AXIS); editorInfo.setAlignmentX(Component.LEFT_ALIGNMENT); editorInfo.setBorder(UIUtils.createPadding(5, 5, 5, 5)); this.responseBox.add(editorInfo); if (this.message.getEditorAvatar() != null) { JLabel avatar = new JLabel(); avatar.setAlignmentY(Component.TOP_ALIGNMENT); avatar.setVerticalAlignment(SwingConstants.TOP); editorInfo.add(avatar); avatar.setOpaque(false); avatar.setIcon( new ImageIcon(UIUtils.getScaledImage(_this.message.getEditorAvatar(), 50))); avatar.setBorder( new CompoundBorder(UIUtils.createPadding(0, 0, 0, 5), UIUtils.createLineBorder())); } if (this.message.getEditorName() != null) { JLabel name = new JLabel(this.message.getEditorName()); editorInfo.add(name); name.setBorder(null); name.setAlignmentY(Component.TOP_ALIGNMENT); name.setVerticalAlignment(JLabel.TOP); name.setAlignmentX(Component.LEFT_ALIGNMENT); name.setFont( name.getFont() .deriveFont((float) UIUtils.getScaledFontSize(14)) .deriveFont(java.awt.Font.PLAIN)); } } } final EditorEditor ed = this.message.getEditor(); JButton ok = new JButton("Ok, got it"); ok.addActionListener( new ActionAdapter() { public void actionPerformed(ActionEvent ev) { try { if (_this.message.isAccepted()) { ed.setEditorStatus(EditorEditor.EditorStatus.current); if (_this.message.getEditorName() != null) { ed.setName(_this.message.getEditorName()); } if (_this.message.getEditorAvatar() != null) { ed.setAvatar(_this.message.getEditorAvatar()); } EditorsEnvironment.updateEditor(ed); // Is this response for an invite message or just out of the blue from a web // service invite? if (!EditorsEnvironment.hasSentMessageOfTypeToEditor( ed, InviteMessage.MESSAGE_TYPE)) { EditorsEnvironment.sendUserInformationToEditor(ed, null, null, null); } } else { ed.setEditorStatus(EditorEditor.EditorStatus.rejected); EditorsEnvironment.updateEditor(ed); } _this.message.setDealtWith(true); EditorsEnvironment.updateMessage(_this.message); _this.responseBox.setVisible(false); } catch (Exception e) { Environment.logError("Unable to update editor: " + ed, e); UIUtils.showErrorMessage( _this.projectViewer, "Unable to update {editor}, please contact Quoll Writer support for assitance."); return; } } }); JButton[] buts = new JButton[] {ok}; JPanel bb = UIUtils.createButtonBar2(buts, Component.LEFT_ALIGNMENT); bb.setOpaque(false); bb.setAlignmentX(Component.LEFT_ALIGNMENT); bb.setBorder(UIUtils.createPadding(5, 0, 0, 0)); this.responseBox.add(bb); return; } boolean accepted = this.message.isAccepted(); String iconName = (accepted ? Constants.ACCEPTED_ICON_NAME : Constants.REJECTED_ICON_NAME); String message = "Accepted invitation to be {an editor}"; if (!accepted) { message = "Rejected invitation to be {an editor}"; } JComponent h = UIUtils.createBoldSubHeader(message, iconName); this.add(h); }
private void updateTabbedPaneSize() { tabbedPane.setPreferredSize( new Dimension( (int) textPane3270.getPreferredSize().getWidth() + 40, (int) textPane3270.getPreferredSize().getHeight() + 40)); }
public void show() { final String aboutText = Tools.getLabel(messages.getString("guiMenuAbout")); JTextPane aboutPane = new JTextPane(); aboutPane.setBackground(new Color(0, 0, 0, 0)); aboutPane.setBorder(BorderFactory.createEmptyBorder()); aboutPane.setContentType("text/html"); aboutPane.setEditable(false); aboutPane.setOpaque(false); aboutPane.setText( String.format( "<html>" + "<p>LanguageTool %s (%s)<br>" + "Copyright (C) 2005-2014 the LanguageTool community and Daniel Naber<br>" + "This software is licensed under the GNU Lesser General Public License.<br>" + "<a href=\"http://www.languagetool.org\">http://www.languagetool.org</a></p>" + "<p>Maintainers of the language modules:</p><br>" + "</html>", JLanguageTool.VERSION, JLanguageTool.BUILD_DATE)); aboutPane.addHyperlinkListener( new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (Exception ex) { Tools.showError(ex); } } } } }); JTextPane maintainersPane = new JTextPane(); maintainersPane.setBackground(new Color(0, 0, 0, 0)); maintainersPane.setBorder(BorderFactory.createEmptyBorder()); maintainersPane.setContentType("text/html"); maintainersPane.setEditable(false); maintainersPane.setOpaque(false); maintainersPane.setText(getMaintainers()); int maxHeight = java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2; if (maintainersPane.getPreferredSize().height > maxHeight) { maintainersPane.setPreferredSize( new Dimension(maintainersPane.getPreferredSize().width, maxHeight)); } JScrollPane scrollPane = new JScrollPane(maintainersPane); scrollPane.setBorder(BorderFactory.createEmptyBorder()); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); panel.add(aboutPane); panel.add(scrollPane); JOptionPane.showMessageDialog(parent, panel, aboutText, JOptionPane.INFORMATION_MESSAGE); }
private void addCenterPanel(GridBagConstraints mainPanelConstraints) { JPanel panel = new JPanel(new GridBagLayout()); panel.setBorder(BorderFactory.createEtchedBorder()); add(panel, mainPanelConstraints); GridBagConstraints panelConstraints = new GridBagConstraints(); panelConstraints.gridx = 0; panelConstraints.gridy = 0; panelConstraints.fill = GridBagConstraints.HORIZONTAL; panelConstraints.anchor = GridBagConstraints.PAGE_START; panelConstraints.weighty = 0; panelConstraints.weightx = 0; panelConstraints.insets = new Insets(10, 10, 10, 10); panelConstraints.gridwidth = 2; SimpleAttributeSet plain = new SimpleAttributeSet(); StyleConstants.setForeground(plain, Color.black); StyleConstants.setBold(plain, false); SimpleAttributeSet bold = new SimpleAttributeSet(); StyleConstants.setForeground(bold, Color.black); StyleConstants.setBold(bold, true); JTextPane header = new JTextPane(); header.setEditable(false); header.setOpaque(false); Document doc = header.getDocument(); try { doc.insertString(0, "A new version of JPedal is available.", bold); } catch (BadLocationException e) { e.printStackTrace(); } panel.add(header, panelConstraints); panelConstraints.gridwidth = 1; panelConstraints.gridy = 1; panelConstraints.insets = new Insets(10, 10, 0, 10); JTextPane currentVersionLabel = new JTextPane(); currentVersionLabel.setEditable(false); currentVersionLabel.setOpaque(false); doc = currentVersionLabel.getDocument(); try { doc.insertString(0, "Your current version:", plain); } catch (BadLocationException e) { e.printStackTrace(); } currentVersionLabel.setMinimumSize(currentVersionLabel.getPreferredSize()); panel.add(currentVersionLabel, panelConstraints); panelConstraints.weightx = 1; panelConstraints.gridx = 1; JTextPane currentVersionPane = new JTextPane(); currentVersionPane.setEditable(false); currentVersionPane.setOpaque(false); doc = currentVersionPane.getDocument(); try { doc.insertString(0, currentVersion, plain); } catch (BadLocationException e) { e.printStackTrace(); } panel.add(currentVersionPane, panelConstraints); panelConstraints.insets = new Insets(0, 10, 10, 10); panelConstraints.weightx = 0; panelConstraints.gridx = 0; panelConstraints.gridy = 2; JTextPane availableVersionLabel = new JTextPane(); availableVersionLabel.setEditable(false); availableVersionLabel.setOpaque(false); doc = availableVersionLabel.getDocument(); try { doc.insertString(0, "Available Version:", plain); } catch (BadLocationException e) { e.printStackTrace(); } panel.add(availableVersionLabel, panelConstraints); panelConstraints.gridwidth = 2; panelConstraints.weightx = 1; panelConstraints.gridx = 1; JTextPane availableVersionPane = new JTextPane(); availableVersionPane.setEditable(false); availableVersionPane.setOpaque(false); doc = availableVersionPane.getDocument(); try { doc.insertString(0, availableVersion, plain); } catch (BadLocationException e) { e.printStackTrace(); } panel.add(availableVersionPane, panelConstraints); panelConstraints.insets = new Insets(10, 10, 10, 10); panelConstraints.weightx = 0; panelConstraints.gridx = 0; panelConstraints.gridy = 3; JTextPane moreInfo = new JTextPane(); moreInfo.setEditable(false); moreInfo.setOpaque(false); doc = moreInfo.getDocument(); try { doc.insertString(0, "Press ", plain); doc.insertString(doc.getLength(), "More info... ", bold); doc.insertString( doc.getLength(), "to open a web page where you can download JPedal or learn more about the new version", plain); } catch (BadLocationException e) { e.printStackTrace(); } panel.add(moreInfo, panelConstraints); panelConstraints.gridy = 4; JTextPane configure = new JTextPane(); doc = configure.getDocument(); try { doc.insertString(0, "To configure automatic updates settings, see ", plain); doc.insertString(doc.getLength(), "View | Preferences", bold); } catch (BadLocationException e) { e.printStackTrace(); } configure.setEditable(false); configure.setOpaque(false); panel.add(configure, panelConstraints); panelConstraints.weighty = 1; panelConstraints.gridy = 5; JTextPane manual = new JTextPane(); doc = manual.getDocument(); try { doc.insertString(0, "To check for new updates manually, use ", plain); doc.insertString(doc.getLength(), "Help | Check for Updates", bold); } catch (BadLocationException e) { e.printStackTrace(); } manual.setEditable(false); manual.setOpaque(false); panel.add(manual, panelConstraints); }