Search in sources :

Example 41 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 42 with JEditorPane

use of javax.swing.JEditorPane in project ChatGameFontificator by GlitchCog.

the class ControlWindow method setupHelp.

private void setupHelp() {
    final String helpTitle = "Chat Game Fontificator Help";
    help = new JDialog(this, true);
    help.setTitle(helpTitle);
    help.setSize(640, 480);
    help.setLayout(new GridBagLayout());
    JEditorPane helpPane = new JEditorPane();
    helpPane.setContentType("text/html");
    helpPane.setText(helpText);
    helpPane.setEditable(false);
    JScrollPane scrollHelp = new JScrollPane(helpPane, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    JButton ok = new JButton("Close");
    ok.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            help.setVisible(false);
        }
    });
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.NORTH;
    help.add(new JLabel("The function of each option available in the Control Window tabs is explained below"), gbc);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.gridy = 1;
    help.add(scrollHelp, gbc);
    gbc.gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.SOUTH;
    gbc.weighty = 0.0;
    help.add(ok, gbc);
    help.setResizable(false);
}
Also used : JScrollPane(javax.swing.JScrollPane) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JEditorPane(javax.swing.JEditorPane) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JDialog(javax.swing.JDialog)

Example 43 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 44 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 45 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)60 JScrollPane (javax.swing.JScrollPane)22 Dimension (java.awt.Dimension)12 JPanel (javax.swing.JPanel)12 IOException (java.io.IOException)11 JButton (javax.swing.JButton)11 JLabel (javax.swing.JLabel)11 JFrame (javax.swing.JFrame)10 GridBagLayout (java.awt.GridBagLayout)9 GridBagConstraints (java.awt.GridBagConstraints)8 JDialog (javax.swing.JDialog)7 HyperlinkEvent (javax.swing.event.HyperlinkEvent)6 BorderLayout (java.awt.BorderLayout)5 JTextField (javax.swing.JTextField)5 HyperlinkListener (javax.swing.event.HyperlinkListener)5 StyledEditorKit (javax.swing.text.StyledEditorKit)5 JCheckBox (javax.swing.JCheckBox)4 JSplitPane (javax.swing.JSplitPane)4 JTree (javax.swing.JTree)4 Component (java.awt.Component)3