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();
}
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);
}
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");
}
}
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;
}
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);
}
Aggregations