Java Code Examples for javax.swing.JTextPane#setText()

The following examples show how to use javax.swing.JTextPane#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotificationsManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void setupPane(JTextPane pane, final File[] files, String fileNames, final File projectDir, final String url, final String revision) {
     String msg = revision == null
             ? NbBundle.getMessage(NotificationsManager.class, "MSG_NotificationBubble_DeleteDescription", fileNames, CMD_DIFF) //NOI18N
             : NbBundle.getMessage(NotificationsManager.class, "MSG_NotificationBubble_Description", fileNames, url, CMD_DIFF); //NOI18N
    pane.setText(msg);

    pane.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                if(CMD_DIFF.equals(e.getDescription())) {
                    Context ctx = new Context(files);
                    DiffAction.diff(ctx, Setup.DIFFTYPE_REMOTE, NbBundle.getMessage(NotificationsManager.class, "LBL_Remote_Changes", projectDir.getName()), false); //NOI18N
                } else if (revision != null) {
                    try {
                        SearchHistoryAction.openSearch(new SVNUrl(url), projectDir, Long.parseLong(revision));
                    } catch (MalformedURLException ex) {
                        LOG.log(Level.WARNING, null, ex);
                    }
                }
            }
        }
    });
}
 
Example 2
Source File: SkinEditorMainGUI.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Pops up a dialog box showing an alert
 */
public void doAlertDialog(String title, String message) {
    JTextPane textArea = new JTextPane();
    ReportDisplay.setupStylesheet(textArea);

    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    textArea.setText("<pre>" + message + "</pre>");
    scrollPane.setPreferredSize(new Dimension(
            (int) (getSize().getWidth() / 1.5), (int) (getSize()
                    .getHeight() / 1.5)));
    JOptionPane.showMessageDialog(frame, scrollPane, title,
            JOptionPane.ERROR_MESSAGE);
}
 
Example 3
Source File: ClientGUI.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Pops up a dialog box showing an alert
 */
public void doAlertDialog(String title, String message) {
    JTextPane textArea = new JTextPane();
    ReportDisplay.setupStylesheet(textArea);

    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    textArea.setText("<pre>" + message + "</pre>");
    scrollPane.setPreferredSize(new Dimension(
            (int) (getSize().getWidth() / 1.5), (int) (getSize()
                    .getHeight() / 1.5)));
    JOptionPane.showMessageDialog(frame, scrollPane, title,
            JOptionPane.ERROR_MESSAGE);
}
 
Example 4
Source File: ROCViewer.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
public ROCViewer(AreaUnderCurve auc) {
	setLayout(new BorderLayout());

	String message = auc.toString();

	criterionName = auc.getName();

	// info string
	JPanel infoPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
	infoPanel.setOpaque(true);
	infoPanel.setBackground(Colors.WHITE);
	JTextPane infoText = new JTextPane();
	infoText.setEditable(false);
	infoText.setBackground(infoPanel.getBackground());
	infoText.setFont(infoText.getFont().deriveFont(Font.BOLD));
	infoText.setText(message);
	infoPanel.add(infoText);
	add(infoPanel, BorderLayout.NORTH);

	// plot panel
	plotter = new ROCChartPlotter();
	plotter.addROCData("ROC", auc.getRocData());
	JPanel innerPanel = new JPanel(new BorderLayout());
	innerPanel.add(plotter, BorderLayout.CENTER);
	innerPanel.setBorder(BorderFactory.createMatteBorder(5, 0, 10, 10, Colors.WHITE));
	add(innerPanel, BorderLayout.CENTER);
}
 
Example 5
Source File: HtmlViewer.java    From chipster with MIT License 5 votes vote down vote up
@Override
public JComponent getVisualisation(DataBean data) throws Exception {
	byte[] html = Session.getSession().getDataManager().getContentBytes(data, DataNotAvailableHandling.EMPTY_ON_NA);
	if (html != null) {
		JTextPane htmlPane = BrowsableHtmlPanel.createHtmlPanel();			
		htmlPane.setText(new String(html));
		return new JScrollPane(htmlPane);
	}
	return this.getDefaultVisualisation();
}
 
Example 6
Source File: StackTraceSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void underlineStacktraces(StyledDocument doc, JTextPane textPane, List<StackTracePosition> stacktraces, String comment) {
    Style defStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
    Style hlStyle = doc.addStyle("regularBlue-stacktrace", defStyle); // NOI18N
    hlStyle.addAttribute(HyperlinkSupport.STACKTRACE_ATTRIBUTE, new StackTraceAction());
    StyleConstants.setForeground(hlStyle, UIUtils.getLinkColor());
    StyleConstants.setUnderline(hlStyle, true);

    int last = 0;
    textPane.setText(""); // NOI18N
    for (StackTraceSupport.StackTracePosition stp : stacktraces) {
        int start = stp.getStartOffset();
        int end = stp.getEndOffset();

        if (last < start) {
            insertString(doc, comment, last, start, defStyle);
        }
        last = start;

        // for each line skip leading whitespaces (look bad underlined)
        boolean inStackTrace = (comment.charAt(start) > ' ');
        for (int i = start; i < end; i++) {
            char ch = comment.charAt(i);
            if ((inStackTrace && ch == '\n') || (!inStackTrace && ch > ' ')) {
                insertString(doc, comment, last, i, inStackTrace ? hlStyle : defStyle);
                inStackTrace = !inStackTrace;
                last = i;
            }
        }

        if (last < end) {
            insertString(doc, comment, last, end, inStackTrace ? hlStyle : defStyle);
        }
        last = end;
    }
    try {
        doc.insertString(doc.getLength(), comment.substring(last), defStyle);
    } catch (BadLocationException ex) {
        Support.LOG.log(Level.SEVERE, null, ex);
    }
}
 
Example 7
Source File: NetworkErrorPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    infoScrollPane = new JScrollPane();
    infoTextPane = new JTextPane();

    infoScrollPane.setBorder(null);

    infoTextPane.setEditable(false);
    infoTextPane.setBorder(null);
    infoTextPane.setContentType("text/html"); // NOI18N
    infoTextPane.setText(NbBundle.getMessage(NetworkErrorPanel.class, "NetworkErrorPanel.infoTextPane.text")); // NOI18N
    infoTextPane.setOpaque(false);
    infoScrollPane.setViewportView(infoTextPane);

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(infoScrollPane)
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(infoScrollPane)
            .addContainerGap())
    );
}
 
Example 8
Source File: JAboutFrame.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
public JAboutFrame(JByteMod jbm) {
  this.setTitle(JByteMod.res.getResource("about") + " " + jbm.getTitle());
  this.setModal(true);
  setBounds(100, 100, 400, 300);
  JPanel cp = new JPanel();
  cp.setLayout(new BorderLayout());
  cp.setBorder(new EmptyBorder(10, 10, 10, 10));
  setResizable(false);
  JButton close = new JButton(JByteMod.res.getResource("close"));
  close.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      JAboutFrame.this.dispose();
    }
  });
  JPanel jp = new JPanel(new GridLayout(1, 4));
  for (int i = 0; i < 3; i++)
    jp.add(new JPanel());

  jp.add(close);
  cp.add(jp, BorderLayout.PAGE_END);

  JTextPane title = new JTextPane();
  title.setContentType("text/html");
  title.setText(TextUtils.toHtml(jbm.getTitle()
      + "<br/>Copyright \u00A9 2016-2018 noverify<br/><font color=\"#0000EE\"><u>https://github.com/GraxCode/JByteMod-Beta</u></font><br/>Donate LTC: <font color=\"#333333\">LhwXLVASzb6t4vHSssA9FQwq2X5gAg8EKX</font>"));
  UIDefaults defaults = new UIDefaults();
  defaults.put("TextPane[Enabled].backgroundPainter", this.getBackground());
  title.putClientProperty("Nimbus.Overrides", defaults);
  title.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
  title.setBackground(null);
  title.setEditable(false);
  title.setBorder(null);
  cp.add(title, BorderLayout.CENTER);

  getContentPane().add(cp);
}
 
Example 9
Source File: ApplicationXML.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JComponent getTextComponent(String locator) throws Exception {
    JTextPane textComponent = new JTextPane();
    textComponent.setText(getContent(locator));
    textComponent.setFont(new Font("monospaced", Font.PLAIN, 12));
    textComponent.setEditable(false);
    textComponent.setCaretPosition(0);
    textComponent.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    return textComponent;
}
 
Example 10
Source File: MessageWizardPanel.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
private void initComponents() {
	setLayout(new BorderLayout());

       textPane = new JTextPane();
       textPane.setEditable(false);
       textPane.setText(message);
       add(new JScrollPane(textPane), BorderLayout.CENTER);
}
 
Example 11
Source File: PlaceSection.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
protected Component createInfoBar() {
   JTextPane info = new JTextPane();
   info.setEditable(false);
   info.setText("Loading place...");
   controller.getActivePlace().addSelectionListener((place) -> {
      if(!place.isPresent()) {
         info.setText("No active place");
         return;
      }
      
      info.setText(place.get().getName() + " [" + place.get().getServiceLevel() + "]");
   });
   return info;
}
 
Example 12
Source File: ModelController.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
private Window createAttributeDialog(Model model, String attributeName, String label) {
   JDialog window = new JDialog((Window) null, model.getAddress() + ": " + attributeName, ModalityType.MODELESS);
   
   JPanel panel = new JPanel(new BorderLayout());
   panel.add(new JLabel(label), BorderLayout.NORTH);
   // TODO make this a JsonField...
   JTextPane pane = new JTextPane();
   pane.setContentType("text/html");
   pane.setText(JsonPrettyPrinter.prettyPrint(JSON.toJson(model.get(attributeName))));
   
   ListenerRegistration l = model.addListener((event) -> {
      if(event.getPropertyName().equals(attributeName)) {
         // TODO set background green and slowly fade out
         pane.setText(JsonPrettyPrinter.prettyPrint(JSON.toJson(event.getNewValue())));
      }
   });
   
   panel.add(pane, BorderLayout.CENTER);
   
   window.addWindowListener(new WindowAdapter() {
      /* (non-Javadoc)
       * @see java.awt.event.WindowAdapter#windowClosed(java.awt.event.WindowEvent)
       */
      @Override
      public void windowClosed(WindowEvent e) {
         l.remove();
         attributeWindows.remove(model.getAddress() + ":"  + attributeName);
      }
   });
   
   return window;
}
 
Example 13
Source File: CommentPane.java    From lizzie with GNU General Public License v3.0 4 votes vote down vote up
/** Creates a window */
public CommentPane(LizzieMain owner) {
  super(owner);
  setLayout(new BorderLayout(0, 0));

  htmlKit = new LizziePane.HtmlKit();
  htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument();
  htmlStyle = htmlKit.getStyleSheet();
  String style =
      "body {background:#"
          + String.format(
              "%02x%02x%02x",
              Lizzie.config.commentBackgroundColor.getRed(),
              Lizzie.config.commentBackgroundColor.getGreen(),
              Lizzie.config.commentBackgroundColor.getBlue())
          + "; color:#"
          + String.format(
              "%02x%02x%02x",
              Lizzie.config.commentFontColor.getRed(),
              Lizzie.config.commentFontColor.getGreen(),
              Lizzie.config.commentFontColor.getBlue())
          + "; font-family:"
          + Lizzie.config.fontName
          + ", Consolas, Menlo, Monaco, 'Ubuntu Mono', monospace;"
          + (Lizzie.config.commentFontSize > 0
              ? "font-size:" + Lizzie.config.commentFontSize
              : "")
          + "}";
  htmlStyle.addRule(style);

  commentPane = new JTextPane();
  commentPane.setBorder(BorderFactory.createEmptyBorder());
  commentPane.setEditorKit(htmlKit);
  commentPane.setDocument(htmlDoc);
  commentPane.setText("");
  commentPane.setEditable(false);
  commentPane.setFocusable(false);
  commentPane.addMouseListener(
      new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
          Lizzie.frame.getFocus();
        }
      });
  scrollPane = new JScrollPane();
  scrollPane.setBorder(BorderFactory.createEmptyBorder());
  scrollPane.setVerticalScrollBarPolicy(
      javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
  add(scrollPane);
  scrollPane.setViewportView(commentPane);
  setVisible(false);

  //    mouseMotionAdapter = new MouseMotionAdapter() {
  //      @Override
  //      public void mouseDragged(MouseEvent e) {
  //        System.out.println("Mouse Dragged");
  //        owner.dispatchEvent(e);
  //      }
  //    };
  //    commentPane.addMouseMotionListener(mouseMotionAdapter);
}
 
Example 14
Source File: MainFrame.java    From procamcalib with GNU General Public License v2.0 4 votes vote down vote up
private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
    String version = MainFrame.class.getPackage().getImplementationVersion();
    if (version == null) {
        version = "unknown";
    }
    JTextPane textPane = new JTextPane();
    textPane.setEditable(false);
    textPane.setContentType("text/html");
    textPane.setText(
            "<font face=sans-serif><strong><font size=+2>ProCamCalib</font></strong> version " + version + "<br>" +
            "Copyright (C) 2009-2014 Samuel Audet &lt;<a href=\"mailto:[email protected]%28Samuel%20Audet%29\">[email protected]</a>&gt;<br>" +
            "Web site: <a href=\"http://www.ok.ctrl.titech.ac.jp/~saudet/procamcalib/\">http://www.ok.ctrl.titech.ac.jp/~saudet/procamcalib/</a><br>" +
            "<br>" +
            "Licensed under the GNU General Public License version 2 (GPLv2).<br>" +
            "Please refer to LICENSE.txt or <a href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a> for details."
            );
    textPane.setCaretPosition(0);
    Dimension dim = textPane.getPreferredSize();
    dim.height = dim.width*3/4;
    textPane.setPreferredSize(dim);

    textPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if(e.getEventType() == EventType.ACTIVATED) {
                try {
                    Desktop.getDesktop().browse(e.getURL().toURI());
                } catch(Exception ex) {
                    Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE,
                            "Could not launch browser to \"" + e.getURL()+ "\"", ex);
                }
            }
        }
    });

    // pass the scrollpane to the joptionpane.
    JDialog dialog = new JOptionPane(textPane, JOptionPane.PLAIN_MESSAGE).
            createDialog(this, "About");

    if ("com.sun.java.swing.plaf.gtk.GTKLookAndFeel".equals(UIManager.getLookAndFeel().getClass().getName())) {
        // under GTK, frameBackground is white, but rootPane color is OK...
        // but under Windows, the rootPane's color is funny...
        Color c = dialog.getRootPane().getBackground();
        textPane.setBackground(new Color(c.getRGB()));
    } else {
        Color frameBackground = this.getBackground();
        textPane.setBackground(frameBackground);
    }
    dialog.setVisible(true);
}
 
Example 15
Source File: BroadcastFrame.java    From JRakNet with MIT License 4 votes vote down vote up
/**
 * Creates a broadcast test frame.
 */
protected BroadcastFrame() {
	// Frame and content settings
	this.setResizable(false);
	this.setSize(FRAME_WIDTH, FRAME_HEIGHT);
	this.setTitle("JRakNet Broadcast Test");
	this.getContentPane().setLayout(null);

	// Discovered MCPE Servers
	JTextPane txtpnDiscoveredMcpeServers = new JTextPane();
	txtpnDiscoveredMcpeServers.setEditable(false);
	txtpnDiscoveredMcpeServers.setBackground(UIManager.getColor("Button.background"));
	txtpnDiscoveredMcpeServers.setText("Discovered servers");
	txtpnDiscoveredMcpeServers.setBounds(10, 10, 350, 20);
	this.getContentPane().add(txtpnDiscoveredMcpeServers);

	// How the client will discover servers on the local network
	JComboBox<String> comboBoxDiscoveryType = new JComboBox<String>();
	comboBoxDiscoveryType.setToolTipText(
			"Changing this will update how the client will discover servers, by default it will look for any possible connection on the network");
	comboBoxDiscoveryType.setModel(new DefaultComboBoxModel<String>(DISCOVERY_MODE_OPTIONS));
	comboBoxDiscoveryType.setBounds(370, 10, 115, 20);
	comboBoxDiscoveryType.addActionListener(new RakNetBroadcastDiscoveryTypeListener());
	this.getContentPane().add(comboBoxDiscoveryType);

	// Used to update the discovery port
	JTextField textFieldDiscoveryPort = new JTextField();
	textFieldDiscoveryPort.setBounds(370, 45, 115, 20);
	textFieldDiscoveryPort.setText(Integer.toString(Discovery.getPorts()[0]));
	this.getContentPane().add(textFieldDiscoveryPort);
	textFieldDiscoveryPort.setColumns(10);
	JButton btnUpdatePort = new JButton("Update Port");
	btnUpdatePort.setBounds(370, 76, 114, 23);
	btnUpdatePort.addActionListener(new RakNetBroadcastUpdatePortListener(textFieldDiscoveryPort));
	this.getContentPane().add(btnUpdatePort);

	// The text containing the discovered MCPE servers
	txtPnDiscoveredMcpeServerList = new JTextPane();
	txtPnDiscoveredMcpeServerList.setToolTipText("This is the list of the discovered servers on the local network");
	txtPnDiscoveredMcpeServerList.setEditable(false);
	txtPnDiscoveredMcpeServerList.setBackground(UIManager.getColor("Button.background"));
	txtPnDiscoveredMcpeServerList.setBounds(10, 30, 350, 165);
	this.getContentPane().add(txtPnDiscoveredMcpeServerList);
}
 
Example 16
Source File: CapabilityResponsePopUp.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
@Override
 protected Window createComponent() {
    JDialog window = new JDialog(null, "Response to " + command, ModalityType.MODELESS);
    window.setAlwaysOnTop(false);
    window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    // TODO remember dimensions
    window.setSize(800, 600);
  installEscapeCloseOperation(window);

  response = new JTextPane();
    response.setEditable(false);
    response.setContentType("text/html");
 	response.setText(text);
 	response.setCaretPosition(0);
 	
 	scroller = new JScrollPane(this.response);
 	
 	form = new FormView();
 	form.addField(
 			Fields
 				.textFieldBuilder()
 				.notEditable()
 				.labelled("Status")
 				.named("status")
 				.build()
);
 	form.addField(
 			Fields
 				.textFieldBuilder()
 				.notEditable()
 				.labelled("From")
 				.named("from")
 				.build()
);
 	form.addField(
 			Fields
 				.textFieldBuilder()
 				.notEditable()
 				.labelled("Type")
 				.named("type")
 				.build()
);
 	form.addField(
 			new JLabel("Attributes"),
 			scroller,
 			LabelLocation.TOP
);
    
    window.add(form.getComponent());
    return window;
 }
 
Example 17
Source File: ProjectFolder.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    projectFolderCheckBox = new JCheckBox();
    projectFolderLabel = new JLabel();
    projectFolderTextField = new JTextField();
    projectFolderBrowseButton = new JButton();
    projectFolderScrollPane = new JScrollPane();
    projectFolderTextPane = new JTextPane();

    Mnemonics.setLocalizedText(projectFolderCheckBox, NbBundle.getMessage(ProjectFolder.class, "LBL_SeparateProjectFolder")); // NOI18N

    projectFolderLabel.setLabelFor(projectFolderTextField);
    Mnemonics.setLocalizedText(projectFolderLabel, NbBundle.getMessage(ProjectFolder.class, "LBL_MetadataFolder")); // NOI18N
    projectFolderLabel.setEnabled(false);

    projectFolderTextField.setColumns(20);
    projectFolderTextField.setEnabled(false);

    Mnemonics.setLocalizedText(projectFolderBrowseButton, NbBundle.getMessage(ProjectFolder.class, "LBL_BrowseProject")); // NOI18N
    projectFolderBrowseButton.setEnabled(false);
    projectFolderBrowseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            projectFolderBrowseButtonActionPerformed(evt);
        }
    });

    projectFolderScrollPane.setBorder(null);

    projectFolderTextPane.setBackground(UIManager.getDefaults().getColor("Label.background"));
    projectFolderTextPane.setBorder(null);
    projectFolderTextPane.setFont(new Font("Dialog", 1, 12)); // NOI18N
    projectFolderTextPane.setText(NbBundle.getMessage(ProjectFolder.class, "TXT_MetadataInfo")); // NOI18N
    projectFolderScrollPane.setViewportView(projectFolderTextPane);
    projectFolderTextPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderTextPane.AccessibleContext.accessibleName")); // NOI18N
    projectFolderTextPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderTextPane.AccessibleContext.accessibleDescription")); // NOI18N

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(Alignment.LEADING)
        .addGroup(Alignment.TRAILING, layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                .addComponent(projectFolderCheckBox)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(projectFolderLabel)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(projectFolderTextField, GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addComponent(projectFolderBrowseButton))
        .addComponent(projectFolderScrollPane, GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addComponent(projectFolderCheckBox)
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                .addComponent(projectFolderTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addComponent(projectFolderLabel)
                .addComponent(projectFolderBrowseButton))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addComponent(projectFolderScrollPane))
    );

    projectFolderCheckBox.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderCheckBox.AccessibleContext.accessibleName")); // NOI18N
    projectFolderCheckBox.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderCheckBox.AccessibleContext.accessibleDescription")); // NOI18N
    projectFolderLabel.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderLabel.AccessibleContext.accessibleName")); // NOI18N
    projectFolderLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderLabel.AccessibleContext.accessibleDescription")); // NOI18N
    projectFolderTextField.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderTextField.AccessibleContext.accessibleName")); // NOI18N
    projectFolderTextField.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderTextField.AccessibleContext.accessibleDescription")); // NOI18N
    projectFolderBrowseButton.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderBrowseButton.AccessibleContext.accessibleName")); // NOI18N
    projectFolderBrowseButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderBrowseButton.AccessibleContext.accessibleDescription")); // NOI18N
    projectFolderScrollPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderScrollPane1.AccessibleContext.accessibleName")); // NOI18N
    projectFolderScrollPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.projectFolderScrollPane1.AccessibleContext.accessibleDescription")); // NOI18N

    getAccessibleContext().setAccessibleName(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.AccessibleContext.accessibleName")); // NOI18N
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ProjectFolder.class, "ProjectFolder.AccessibleContext.accessibleDescription")); // NOI18N
}
 
Example 18
Source File: MainFrame.java    From procamtracker with GNU General Public License v2.0 4 votes vote down vote up
private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
    String version = MainFrame.class.getPackage().getImplementationVersion();
    if (version == null) {
        version = "unknown";
    }
    JTextPane textPane = new JTextPane();
    textPane.setEditable(false);
    textPane.setContentType("text/html");
    textPane.setText(
            "<font face=sans-serif><strong><font size=+2>ProCamTracker</font></strong> version " + version + "<br>" +
            "Copyright (C) 2009-2014 Samuel Audet &lt;<a href=\"mailto:[email protected]%28Samuel%20Audet%29\">[email protected]</a>&gt;<br>" +
            "Web site: <a href=\"http://www.ok.ctrl.titech.ac.jp/~saudet/procamtracker/\">http://www.ok.ctrl.titech.ac.jp/~saudet/procamtracker/</a><br>" +
            "<br>" +
            "Licensed under the GNU General Public License version 2 (GPLv2).<br>" +
            "Please refer to LICENSE.txt or <a href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a> for details."
            );
    textPane.setCaretPosition(0);
    Dimension dim = textPane.getPreferredSize();
    dim.height = dim.width*3/4;
    textPane.setPreferredSize(dim);

    textPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if(e.getEventType() == EventType.ACTIVATED) {
                try {
                    Desktop.getDesktop().browse(e.getURL().toURI());
                } catch(Exception ex) {
                    Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE,
                            "Could not launch browser to \"" + e.getURL()+ "\"", ex);
                }
            }
        }
    });

    // pass the scrollpane to the joptionpane.
    JDialog dialog = new JOptionPane(textPane, JOptionPane.PLAIN_MESSAGE).
            createDialog(this, "About");

    if ("com.sun.java.swing.plaf.gtk.GTKLookAndFeel".equals(UIManager.getLookAndFeel().getClass().getName())) {
        // under GTK, frameBackground is white, but rootPane color is OK...
        // but under Windows, the rootPane's color is funny...
        Color c = dialog.getRootPane().getBackground();
        textPane.setBackground(new Color(c.getRGB()));
    } else {
        Color frameBackground = this.getBackground();
        textPane.setBackground(frameBackground);
    }
    dialog.setVisible(true);
}
 
Example 19
Source File: ChatPanel.java    From btdex with GNU General Public License v3.0 4 votes vote down vote up
public ChatPanel() {
  	super(new BorderLayout());

JPanel addressPanel = new JPanel(new BorderLayout());
addressPanel.setBorder(BorderFactory.createTitledBorder("Your contacts"));
addressList = new JList<>();
addressList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
addressList.setPreferredSize(new Dimension(300, 300));
addressPanel.add(addressList, BorderLayout.CENTER);		
add(addressPanel, BorderLayout.LINE_START);
addressList.addListSelectionListener(this);

pinField = new JPasswordField(12);
pinField.addActionListener(this);

  	JPanel panelSendMessage = new JPanel(new BorderLayout());
      inputField = new JTextField();
      inputField.setToolTipText("Enter your message");
      panelSendMessage.add(new Desc("Enter your message", inputField), BorderLayout.CENTER);
      inputField.addActionListener(this);
      inputField.setEnabled(false);

      btnSend = new JButton("");
Icon sendIcon = IconFontSwing.buildIcon(FontAwesome.PAPER_PLANE_O, 24, btnSend.getForeground());
      btnSend.setIcon(sendIcon);
      btnSend.setToolTipText("Send your message");
      btnSend.addActionListener(this);
      btnSend.setEnabled(false);
      panelSendMessage.add(new Desc(" ", btnSend), BorderLayout.EAST);

      displayField = new JTextPane();
      displayField.setContentType("text/html");
      displayField.setEditable(false);
      displayField.setText(HTML_FORMAT);

      scrollPane = new JScrollPane(displayField);
      scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
      
      JPanel panelCenter = new JPanel(new BorderLayout());
      panelCenter.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
      add(panelCenter, BorderLayout.CENTER);
      
      panelCenter.add(scrollPane, BorderLayout.CENTER);
      panelCenter.add(panelSendMessage, BorderLayout.SOUTH);
      
      setSize(280, 400);
  }
 
Example 20
Source File: AboutDialog.java    From SubTitleSearcher with Apache License 2.0 4 votes vote down vote up
private void initComponents() {

		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		setIconImage(MainWin.icon);
		setSize(500, 300);
		setResizable(false);

		setLocationRelativeTo(this.getParent());
		setTitle("About " + AppConfig.appTitle);

		JPanel mainPanel = new JPanel(new BorderLayout());
		add(mainPanel);

		JPanel leftPanel = new JPanel();
		mainPanel.add(leftPanel, BorderLayout.WEST);

		ImageIcon iconImg = new ImageIcon(MainWin.icon);
		iconImg.setImage(iconImg.getImage().getScaledInstance((int) (iconImg.getIconWidth() * 0.5), (int) (iconImg.getIconHeight() * 0.5), Image.SCALE_SMOOTH));
		JLabel iconLabel = new JLabel(iconImg);
		iconLabel.setBorder(BorderFactory.createEmptyBorder(6, 10, 6, 10));
		leftPanel.add(iconLabel);

		HyperlinkListener hlLsnr = new HyperlinkListener() {
			@Override
			public void hyperlinkUpdate(HyperlinkEvent e) {
				if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
					return;
				// 超链接标记中必须带有协议指定,e.getURL()才能得到,否则只能用e.getDescription()得到href的内容。
				// JOptionPane.showMessageDialog(InfoDialog.this, "URL:"+e.getURL()+"\nDesc:"+ e.getDescription());
				URL linkUrl = e.getURL();
				if (linkUrl != null) {
					try {
						Desktop.getDesktop().browse(linkUrl.toURI());
					} catch (Exception e1) {
						e1.printStackTrace();
						JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "无法打开超链接:" + linkUrl + "\n详情:" + e1, JOptionPane.ERROR_MESSAGE);
					}
				} else {
					JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "超链接信息不完整:" + e.getDescription() + "\n请确保链接带有协议信息,如http://,mailto:", JOptionPane.ERROR_MESSAGE);
				}
			}
		};

		JTextPane infoArea = new JTextPane();
		//设置css单位(px/pt)和chrome一致
		infoArea.putClientProperty(JTextPane.W3C_LENGTH_UNITS, true);
		infoArea.addHyperlinkListener(hlLsnr);
		infoArea.setContentType("text/html");
		infoArea.setText(getInfo());
		infoArea.setEditable(false);
		infoArea.setBorder(BorderFactory.createEmptyBorder(2, 10, 6, 10));
		infoArea.setFocusable(false);

		JScrollPane infoAreaScrollPane = new JScrollPane(infoArea);
		infoAreaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		infoAreaScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		infoAreaScrollPane.getViewport().setBackground(Color.WHITE);
		mainPanel.add(infoAreaScrollPane, BorderLayout.CENTER);

	}