use of javax.swing.JTextPane in project JMRI by JMRI.
the class JLogoutputFrame method createMainFrame.
/**
* createMainFrame
* <p>
* @return the initialized main frame
*/
private JFrame createMainFrame() {
// JPanel messagePane = createMessagePane();
JFrame result = new JFrame();
result.setPreferredSize(new Dimension(400, 300));
JTextPane textPane = new JTextPane();
myAppender = createAppender(textPane);
textPane.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textPane);
scrollPane.setPreferredSize(new Dimension(400, 300));
result.getContentPane().add(scrollPane, BorderLayout.CENTER);
String fontFamily = "Courier New";
Font font = new Font(fontFamily, Font.PLAIN, 1);
// Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
// for ( int i = 0; i < fonts.length; i++ )
// {
// if ( fonts[i].getFamily().equals( fontFamily ) )
// {
// textPane.setFont( fonts[i] );
// break;
// } // if fonts[i].getFamily().equals( fontFamily )
// } // for i
textPane.setFont(font);
result.pack();
result.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
return result;
}
use of javax.swing.JTextPane in project jabref by JabRef.
the class MergeEntries method setupFieldRows.
private int setupFieldRows(JPanel mergePanel) {
// For all fields in joint add a row and possibly radio buttons
int row = 2;
int maxLabelWidth = -1;
for (String field : allFields) {
JLabel label = boldFontLabel(new SentenceCaseFormatter().format(field));
mergePanel.add(label, CELL_CONSTRAINTS.xy(1, (2 * row) - 1, "left, top"));
Optional<String> leftString = leftEntry.getField(field);
Optional<String> rightString = rightEntry.getField(field);
if (leftString.equals(rightString)) {
identicalFields.add(field);
} else {
differentFields.add(field);
}
maxLabelWidth = Math.max(maxLabelWidth, label.getPreferredSize().width);
// Left text pane
if (leftString.isPresent()) {
JTextPane tf = new DiffHighlightingTextPane();
mergePanel.add(tf, CELL_CONSTRAINTS.xy(3, (2 * row) - 1, "f, f"));
leftTextPanes.put(field, tf);
}
// Add radio buttons if the two entries do not have identical fields
if (identicalFields.contains(field)) {
// Will only happen if both entries have the field and the content is identical
mergedEntry.setField(field, leftString.get());
} else {
ButtonGroup group = new ButtonGroup();
List<JRadioButton> list = new ArrayList<>(3);
for (int k = 0; k < 3; k++) {
JRadioButton button = new JRadioButton();
group.add(button);
mergePanel.add(button, CELL_CONSTRAINTS.xy(5 + (k * 2), (2 * row) - 1));
button.addChangeListener(e -> updateAll());
list.add(button);
}
radioButtons.put(field, list);
if (leftString.isPresent()) {
list.get(0).setSelected(true);
if (!rightString.isPresent()) {
list.get(2).setEnabled(false);
}
} else {
list.get(0).setEnabled(false);
list.get(2).setSelected(true);
}
}
// Right text pane
if (rightString.isPresent()) {
JTextPane tf = new DiffHighlightingTextPane();
mergePanel.add(tf, CELL_CONSTRAINTS.xy(11, (2 * row) - 1, "f, f"));
rightTextPanes.put(field, tf);
}
row++;
}
return maxLabelWidth;
}
use of javax.swing.JTextPane in project sling by apache.
the class Util method showStartupDialog.
static JTextPane showStartupDialog(final String title, final Dimension screenSize) {
JTextPane text = new JTextPane();
text.setText("...");
JDialog d = new JDialog((Window) null);
d.setTitle(title);
d.add(text);
d.setSize((int) screenSize.getWidth() / 2, 30);
d.setLocation((int) screenSize.getWidth() / 4, (int) screenSize.getHeight() / 2 - 15);
d.setVisible(true);
return text;
}
use of javax.swing.JTextPane in project jgnash by ccavanaugh.
the class PartialTwo method initComponents.
private void initComponents() {
table = new PartialTable(qAcc);
deleteButton = new JButton(rb.getString("Button.Delete"));
helpPane = new JTextPane();
helpPane.setEditable(false);
helpPane.setEditorKit(new StyledEditorKit());
helpPane.setBackground(getBackground());
helpPane.setText(TextResource.getString("QifTwo.txt"));
addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent evt) {
refreshInfo();
}
});
deleteButton.addActionListener(this);
}
use of javax.swing.JTextPane in project GCViewer by chewiebug.
the class TextFileViewer method initComponents.
private void initComponents(String fileName) {
super.initComponents();
JTextPane textPane = new JTextPane();
textPane.setEditable(false);
textPane.setContentType("text/html");
textPane.addHyperlinkListener(new HyperlinkAdapter(this));
try {
textPane.setText(readFile(fileName));
textPane.setCaretPosition(0);
} catch (IOException e) {
e.printStackTrace();
}
JScrollPane scrollPane = new JScrollPane(textPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
getContentPane().add("Center", scrollPane);
pack();
}
Aggregations