Search in sources :

Example 71 with JEditorPane

use of javax.swing.JEditorPane in project pcgen by PCGen.

the class CastSpell method setSpellModel.

/**
	 * <p>
	 * Sets the spell model for the dialog.  Although the dialog
	 * functions fine without this, setting the spell model turns on
	 * some additional capabilities.
	 * </p>
	 *
	 * @param model A non-null spell model.
	 */
public void setSpellModel(SpellModel model) {
    StringBuilder text = new StringBuilder();
    if (descPanel.getComponents().length == 0) {
        descText = new JEditorPane("text/html", "<html></html>");
        descScroll = new JScrollPane(descText);
        descPanel.add(descScroll, BorderLayout.CENTER);
    }
    descText.setBackground(getContentPane().getBackground());
    text.append("<html><body><font size='-2'>");
    text.append("<b>Duration: </b>" + model.getDuration() + ' ');
    text.append("<b>Range: </b>" + model.getRange() + ' ');
    text.append("<b>Save: </b>" + model.getSaveInfo() + ' ');
    text.append("<b>Cast: </b>" + model.getCastingTime() + ' ');
    text.append("<b>Target/Area: </b>" + model.getTarget() + ' ');
    text.append("<b>Desc: </b>" + model.getDesc() + ' ');
    text.append("</font></body></html>");
    descText.setText(text.toString());
    descPanel.setPreferredSize(new Dimension(mainPanel.getWidth() - 16, 75));
    descPanel.setMaximumSize(new Dimension(mainPanel.getWidth() - 16, 75));
    descPanel.setMinimumSize(new Dimension(mainPanel.getWidth() - 16, 75));
    pack();
    tEffect.setText(model.getDesc());
}
Also used : JScrollPane(javax.swing.JScrollPane) JEditorPane(javax.swing.JEditorPane) Dimension(java.awt.Dimension)

Example 72 with JEditorPane

use of javax.swing.JEditorPane in project pcgen by PCGen.

the class DataInstaller method initComponents.

/**
	 * Build the user interface ready for display.
	 */
private void initComponents() {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);
    GridBagLayout gridbag = new GridBagLayout();
    setTitle(TITLE);
    setLayout(gridbag);
    // Data set selection row
    Utility.buildConstraints(gbc, 0, 0, 1, 1, 0.0, 0.0);
    JLabel dataSetLabel = new JLabel(LanguageBundle.getString("in_diDataSet"), SwingConstants.RIGHT);
    gridbag.setConstraints(dataSetLabel, gbc);
    add(dataSetLabel, gbc);
    Utility.buildConstraints(gbc, 1, 0, 2, 1, 1.0, 0.0);
    dataSetSel = new JTextField("", SwingConstants.WEST);
    dataSetSel.setEditable(false);
    gridbag.setConstraints(dataSetSel, gbc);
    add(dataSetSel, gbc);
    Utility.buildConstraints(gbc, 3, 0, 1, 1, 0.0, 0.0);
    gbc.fill = GridBagConstraints.NONE;
    selectButton = new JButton();
    //$NON-NLS-1$
    CommonMenuText.name(selectButton, "select");
    gridbag.setConstraints(selectButton, gbc);
    add(selectButton, gbc);
    selectButton.addActionListener(listener);
    // Data set details row
    Utility.buildConstraints(gbc, 0, 1, 4, 1, 1.0, 1.0);
    dataSetDetails = new JEditorPane("text/html", "<html></html>");
    dataSetDetails.setPreferredSize(new Dimension(400, 200));
    dataSetDetails.setEditable(false);
    dataSetDetails.setBackground(getBackground());
    gbc.fill = GridBagConstraints.BOTH;
    JScrollPane jScrollPane = new JScrollPane();
    jScrollPane.setViewportView(dataSetDetails);
    gridbag.setConstraints(jScrollPane, gbc);
    add(jScrollPane, gbc);
    // Location row
    Utility.buildConstraints(gbc, 0, 2, 1, 1, 0.0, 0.0);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    JLabel locLabel = new JLabel(LanguageBundle.getString("in_diLocation"), SwingConstants.RIGHT);
    gridbag.setConstraints(locLabel, gbc);
    add(locLabel, gbc);
    ButtonGroup exclusiveGroup = new ButtonGroup();
    locDataButton = new JRadioButton(LanguageBundle.getString("in_diData"));
    locDataButton.setToolTipText(LanguageBundle.getString("in_diData_tip"));
    exclusiveGroup.add(locDataButton);
    locVendorDataButton = new JRadioButton(LanguageBundle.getString("in_diVendorData"));
    locVendorDataButton.setToolTipText(LanguageBundle.getString("in_diVendorData_tip"));
    exclusiveGroup.add(locVendorDataButton);
    locHomebrewDataButton = new JRadioButton(LanguageBundle.getString("in_diHomebrewData"));
    locHomebrewDataButton.setToolTipText(LanguageBundle.getString("in_diHomebrewData_tip"));
    exclusiveGroup.add(locHomebrewDataButton);
    JPanel optionsPanel = new JPanel();
    optionsPanel.add(locDataButton);
    optionsPanel.add(locVendorDataButton);
    optionsPanel.add(locHomebrewDataButton);
    Utility.buildConstraints(gbc, 1, 2, 3, 1, 0.0, 0.0);
    gridbag.setConstraints(optionsPanel, gbc);
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    add(optionsPanel, gbc);
    // Buttons row
    installButton = new JButton();
    //$NON-NLS-1$
    CommonMenuText.name(installButton, "diInstall");
    installButton.addActionListener(listener);
    closeButton = new JButton();
    //$NON-NLS-1$
    CommonMenuText.name(closeButton, "close");
    closeButton.addActionListener(listener);
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.add(installButton);
    buttonsPanel.add(closeButton);
    Utility.buildConstraints(gbc, 2, 3, 2, 1, 0.0, 0.0);
    gridbag.setConstraints(buttonsPanel, gbc);
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    add(buttonsPanel, gbc);
    pack();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) ButtonGroup(javax.swing.ButtonGroup) JButton(javax.swing.JButton) JEditorPane(javax.swing.JEditorPane) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField)

Example 73 with JEditorPane

use of javax.swing.JEditorPane in project jdk8u_jdk by JetBrains.

the class InsetsEncapsulation method run.

@Override
public void run() {
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    runTest(new JScrollBar());
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) JTextArea(javax.swing.JTextArea) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTableHeader(javax.swing.table.JTableHeader) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JScrollBar(javax.swing.JScrollBar) JTextPane(javax.swing.JTextPane) JToggleButton(javax.swing.JToggleButton) JSlider(javax.swing.JSlider) JMenuItem(javax.swing.JMenuItem) JComponent(javax.swing.JComponent) Component(java.awt.Component) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JToolBar(javax.swing.JToolBar) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JPopupMenu(javax.swing.JPopupMenu) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) JTable(javax.swing.JTable) JEditorPane(javax.swing.JEditorPane) JSpinner(javax.swing.JSpinner) JRootPane(javax.swing.JRootPane) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 74 with JEditorPane

use of javax.swing.JEditorPane in project jdk8u_jdk by JetBrains.

the class XArrayDataViewer method loadArray.

public static Component loadArray(Object value) {
    Component comp = null;
    if (isViewableValue(value)) {
        Object[] arr;
        if (value instanceof Collection) {
            arr = ((Collection<?>) value).toArray();
        } else if (value instanceof Map) {
            arr = ((Map<?, ?>) value).entrySet().toArray();
        } else if (value instanceof Object[]) {
            arr = (Object[]) value;
        } else {
            int length = Array.getLength(value);
            arr = new Object[length];
            for (int i = 0; i < length; i++) {
                arr[i] = Array.get(value, i);
            }
        }
        JEditorPane arrayEditor = new JEditorPane();
        arrayEditor.setContentType("text/html");
        arrayEditor.setEditable(false);
        Color evenRowColor = arrayEditor.getBackground();
        int red = evenRowColor.getRed();
        int green = evenRowColor.getGreen();
        int blue = evenRowColor.getBlue();
        String evenRowColorStr = "rgb(" + red + "," + green + "," + blue + ")";
        Color oddRowColor = new Color(red < 20 ? red + 20 : red - 20, green < 20 ? green + 20 : green - 20, blue < 20 ? blue + 20 : blue - 20);
        String oddRowColorStr = "rgb(" + oddRowColor.getRed() + "," + oddRowColor.getGreen() + "," + oddRowColor.getBlue() + ")";
        Color foreground = arrayEditor.getForeground();
        String textColor = String.format("%06x", foreground.getRGB() & 0xFFFFFF);
        StringBuilder sb = new StringBuilder();
        sb.append("<html><body text=#" + textColor + "><table width=\"100%\">");
        for (int i = 0; i < arr.length; i++) {
            if (i % 2 == 0) {
                sb.append("<tr style=\"background-color: " + evenRowColorStr + "\"><td><pre>" + (arr[i] == null ? arr[i] : htmlize(arr[i].toString())) + "</pre></td></tr>");
            } else {
                sb.append("<tr style=\"background-color: " + oddRowColorStr + "\"><td><pre>" + (arr[i] == null ? arr[i] : htmlize(arr[i].toString())) + "</pre></td></tr>");
            }
        }
        if (arr.length == 0) {
            sb.append("<tr style=\"background-color: " + evenRowColorStr + "\"><td></td></tr>");
        }
        sb.append("</table></body></html>");
        arrayEditor.setText(sb.toString());
        JScrollPane scrollp = new JScrollPane(arrayEditor);
        comp = scrollp;
    }
    return comp;
}
Also used : JScrollPane(javax.swing.JScrollPane) Color(java.awt.Color) JEditorPane(javax.swing.JEditorPane) Collection(java.util.Collection) Component(java.awt.Component) Map(java.util.Map)

Example 75 with JEditorPane

use of javax.swing.JEditorPane in project jdk8u_jdk by JetBrains.

the class JDialog186Aux method main.

public static void main(String[] args) throws Exception {
    Robot robot = new Robot();
    robot.setAutoDelay(100);
    JFrame frame = new JFrame("JDialog186Aux");
    frame.addWindowFocusListener(focusListener);
    JEditorPane editorPane = new JEditorPane();
    frame.getContentPane().add(editorPane);
    frame.setLocation(new Point(400, 0));
    frame.setSize(350, 100);
    frame.addWindowFocusListener(focusListener);
    frame.setVisible(true);
    synchronized (JDialog186.lock) {
        while (!frame.isFocused()) {
            try {
                JDialog186.lock.wait();
            } catch (InterruptedException ignored) {
            }
        }
    }
    int keyCode;
    for (char c : expectedText) {
        keyCode = KeyStroke.getKeyStroke((c), 0).getKeyCode();
        robot.keyPress(keyCode);
        robot.keyRelease(keyCode);
    }
    frame.dispose();
    if (!editorPane.getText().equals(new String(expectedText).toLowerCase()))
        System.exit(19);
}
Also used : JFrame(javax.swing.JFrame) JEditorPane(javax.swing.JEditorPane) Point(java.awt.Point) Robot(java.awt.Robot) Point(java.awt.Point)

Aggregations

JEditorPane (javax.swing.JEditorPane)130 JScrollPane (javax.swing.JScrollPane)54 Dimension (java.awt.Dimension)34 JPanel (javax.swing.JPanel)34 JButton (javax.swing.JButton)22 JLabel (javax.swing.JLabel)21 BorderLayout (java.awt.BorderLayout)20 IOException (java.io.IOException)16 HyperlinkEvent (javax.swing.event.HyperlinkEvent)16 JFrame (javax.swing.JFrame)15 HyperlinkListener (javax.swing.event.HyperlinkListener)15 JDialog (javax.swing.JDialog)14 GridBagConstraints (java.awt.GridBagConstraints)12 GridBagLayout (java.awt.GridBagLayout)12 URL (java.net.URL)12 ActionEvent (java.awt.event.ActionEvent)11 FlowLayout (java.awt.FlowLayout)10 HTMLEditorKit (javax.swing.text.html.HTMLEditorKit)10 Component (java.awt.Component)9 JSplitPane (javax.swing.JSplitPane)9