本文整理汇总了Java中javax.swing.JTextPane类的典型用法代码示例。如果您正苦于以下问题:Java JTextPane类的具体用法?Java JTextPane怎么用?Java JTextPane使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JTextPane类属于javax.swing包,在下文中一共展示了JTextPane类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: About
import javax.swing.JTextPane; //导入依赖的package包/类
/**
* Create the frame.
*/
public About() {
ImageIcon img = new ImageIcon("icon.PNG");
this.setIconImage(img.getImage());
this.setTitle("About");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 705, 335);
contentPane = new JPanel();
contentPane.setBackground(SystemColor.activeCaptionBorder);
contentPane.setToolTipText("erh");
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JTextPane txtpnByIkerGarca = new JTextPane();
txtpnByIkerGarca.setBackground(SystemColor.menu);
txtpnByIkerGarca.setEditable(false);
txtpnByIkerGarca.setText("By: Iker Garc\u00EDa Ferrero\r\nDate: 03/01/2017\r\n\r\n--Contact--\r\nMail: [email protected] \r\n\r\nThe source code can be found here:\r\nhttps://github.com/ikergarcia1996/Simple-AI_Ikerg-app_INTELLIGENT_POINTS\r\n\r\nA demostration and explanation can be found here (Spanish):\r\nhttps://www.youtube.com/hardware360grados\r\n\r\nThis program uses Processing 3.2.3\r\n\r\nCopyright 2017 Iker Garc\u00EDa \"Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)\" ");
txtpnByIkerGarca.setToolTipText("");
txtpnByIkerGarca.setBounds(12, 13, 664, 262);
contentPane.add(txtpnByIkerGarca);
}
示例2: HelpWindow
import javax.swing.JTextPane; //导入依赖的package包/类
public HelpWindow() {
super(Main.NAME + ": Help");
setIconImage(Main.icon);
final JTextPane text = new JTextPane();
text.setText("Basic Configuration:\n"
+ "Create a folder where you will put the shortcuts to display and set it in the settings\n"
+ "(it should not be the default Desktop folder, as then icons would be displayed twice).\n"
+ "Fill that folder with subfolders - these will be the different icon groups.\n"
+ "In each subfolder, place shortcuts to display, or make subfolders if you want to display not only a shortcut,\n"
+ "but some alternative shortcuts or related data too. This subfolder can be expanded with a right click on the icon later.\n"
+ "\n"
+ "Controls:\n"
+ "Left click on icon: start application or open file\n"
+ "Right click on icon: show sub-icons (if any)\n"
+ "Double click on group title: open folder in explorer\n"
+ "Middle click on icon or group title: rename file or folder");
text.setEditable(false);
add(text);
pack();
}
示例3: setupPane
import javax.swing.JTextPane; //导入依赖的package包/类
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);
}
}
}
}
});
}
示例4: LocRecordsView
import javax.swing.JTextPane; //导入依赖的package包/类
public LocRecordsView(final Window parent, final ServiceFactory factory) {
super(parent, Resources.getLabel("LocRecords"), ModalityType.APPLICATION_MODAL);
final String rawLocRecords = factory.getGeo().getLocRecordsStr();
final JTextPane text = new JTextPane();
text.setEditable(true);
text.setText(rawLocRecords);
text.setPreferredSize(new Dimension(800, 400));
getContentPane().add(text, BorderLayout.CENTER);
final JButton save = new JButton("Save");
save.addActionListener(e -> {
final Pair<String, Exception> error = factory.getGeo().parseAndLoadDNSRecords(text.getText());
text.setText(factory.getGeo().getLocRecordsStr());
if (StringUtils.isNotEmpty(error.getKey())) {
JOptionPane.showMessageDialog(LocRecordsView.this, Resources.getLabel("dns.loc.warning", error.getKey()), Resources.getLabel("warning"),
JOptionPane.WARNING_MESSAGE);
} else {
JOptionPane.showMessageDialog(LocRecordsView.this, Resources.getLabel("dns.loc.updated"));
LocRecordsView.this.dispose();
}
});
getContentPane().add(save, BorderLayout.SOUTH);
pack();
setLocationRelativeTo(parent);
setVisible(true);
}
示例5: pane
import javax.swing.JTextPane; //导入依赖的package包/类
/** Constructs an antialias-capable JTextPane with a DefaultHighlighter associated with it.
* @param attributes - see {@link edu.mit.csail.sdg.alloy4.OurUtil#make OurUtil.make(component, attributes...)}
*/
public static JTextPane pane(Object... attributes) {
JTextPane ans = new JTextPane() {
static final long serialVersionUID = 0;
@Override public void paint(Graphics gr) {
if (antiAlias && gr instanceof Graphics2D) {
((Graphics2D)gr).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
}
super.paint(gr);
}
};
OurUtil.make(ans, attributes);
ans.setHighlighter(new DefaultHighlighter());
map.put(ans, Boolean.TRUE);
return ans;
}
示例6: cut
import javax.swing.JTextPane; //导入依赖的package包/类
public void cut() {
if (doCopy()) {
Doc doc = getSelectedDoc();
JTextPane pane = doc.getTextPane();
int start = pane.getSelectionStart();
int end = pane.getSelectionEnd();
if (start == end) {
throw new IllegalStateException ("no selection");
}
try {
pane.getDocument().remove(start, end-start);
} catch (Exception e) {
e.printStackTrace();
}
} else {
throw new NullPointerException ("no document");
}
}
示例7: DocumentHandler
import javax.swing.JTextPane; //导入依赖的package包/类
/**
* Constructor
*
* @param textPane
*/
public DocumentHandler(JTextPane textPane) {
this.textPane = textPane;
setFormatter(new RecordFormatter());
StyledDocument document = (StyledDocument) this.textPane.getDocument();
infoStyle = document.addStyle("INFO", null);
StyleConstants.setFontFamily(infoStyle, "Monospaced");
StyleConstants.setBackground(infoStyle, Color.white);
StyleConstants.setForeground(infoStyle, Color.blue);
severStyle = document.addStyle("SEVER", null);
StyleConstants.setFontFamily(severStyle, "Monospaced");
StyleConstants.setBackground(severStyle, Color.white);
StyleConstants.setForeground(severStyle, Color.red);
}
示例8: addDate
import javax.swing.JTextPane; //导入依赖的package包/类
private void addDate (JTextPane pane, RevisionItem item, boolean selected, Collection<SearchHighlight> highlights) throws BadLocationException {
LogEntry entry = item.getUserData();
StyledDocument sd = pane.getStyledDocument();
// clear document
clearSD(pane, sd);
Style selectedStyle = createSelectedStyle(pane);
Style normalStyle = createNormalStyle(pane);
Style style;
if (selected) {
style = selectedStyle;
} else {
style = normalStyle;
}
// add date
sd.insertString(sd.getLength(), entry.getDate(), style);
}
示例9: createDefaultHelp
import javax.swing.JTextPane; //导入依赖的package包/类
/**
* Creates a default help panel, listing all the setting kinds for a given exploration key
* with corresponding explanations.
*/
protected JTextPane createDefaultHelp(ExploreKey key) {
JTextPane result = createTextPane();
StringBuilder text = getExplanation(key);
StringBuilder list = new StringBuilder();
HTMLTag dt = new HTMLTag("dt");
HTMLTag dd = new HTMLTag("dd");
HTMLTag strong = HTMLConverter.STRONG_TAG;
for (SettingKey kind : key.getKindType()
.getEnumConstants()) {
list.append(dt.on(strong.on(StringHandler.toUpper(kind.getName()))));
list.append(dd.on(kind.getExplanation()));
}
new HTMLTag("dl").on(list);
text.append(list);
result.setText(text.toString());
return result;
}
示例10: initComponents
import javax.swing.JTextPane; //导入依赖的package包/类
private void initComponents() {
Box vBox = Box.createVerticalBox();
Box hBox = Box.createHorizontalBox();
synView = new JTextPane();
synView.setContentType("text/html");
synView.setEditable(false);
synScroll = new JScrollPane(synView);
synScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
synScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
vBox.add(Box.createVerticalStrut(20));
vBox.add(hBox);
vBox.add(Box.createVerticalStrut(20));
hBox.add(Box.createHorizontalStrut(20));
hBox.add(synScroll);
hBox.add(Box.createHorizontalStrut(20));
this.setLayout(new GridLayout(1, 1));
this.add(vBox);
}
示例11: createComponent
import javax.swing.JTextPane; //导入依赖的package包/类
private static JComponent createComponent() {
createStyles();
for (int i = 0; i < data.length; i++) {
Paragraph p = data[i];
addParagraph(p);
}
JTextPane textPane = new JTextPane(doc);
JScrollPane scroller = new JScrollPane();
JViewport port = scroller.getViewport();
port.setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
port.add(textPane);
return scroller;
}
示例12: setupPane
import javax.swing.JTextPane; //导入依赖的package包/类
@Override
protected void setupPane(JTextPane pane, final File[] files, final File projectDir, final String url, final String revision) {
String text = NbBundle.getMessage(
KenaiNotificationListener.class,
"MSG_NotificationBubble_Description",
getFileNames(files),
HgKenaiAccessor.getInstance().getRevisionUrl(url, revision)); //NOI18N
pane.setText(text);
pane.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
URL url = e.getURL();
assert url != null;
HtmlBrowser.URLDisplayer displayer = HtmlBrowser.URLDisplayer.getDefault ();
assert displayer != null : "HtmlBrowser.URLDisplayer found."; //NOI18N
if (displayer != null) {
displayer.showURL (url);
} else {
Mercurial.LOG.info("No URLDisplayer found."); //NOI18N
}
}
}
});
}
示例13: createRandomHelp
import javax.swing.JTextPane; //导入依赖的package包/类
/** Creates the help panel for the isomorphism checking setting. */
protected JTextPane createRandomHelp(BooleanKey kind) {
JTextPane result = createTextPane();
StringBuilder text = getExplanation(ExploreKey.RANDOM);
text.append("Determines if successor states are explored in random order.");
text.append(HTMLConverter.HTML_LINEBREAK);
text.append(HTMLConverter.HTML_LINEBREAK);
switch (kind) {
case FALSE:
text.append(
"Currently set to <b>false</b>, meaning that when the successors of a given state "
+ "are explored, the next state to be picked is determined by the search strategy "
+ "and deterministally fixed between one exploration and the next.");
break;
case TRUE:
text.append("Currently set to <b>true</b>, meaning that whenever the next successor of "
+ "a given state is explored, a random choice is made between the as yet unexplored "
+ "states.");
break;
default:
assert false;
}
result.setText(text.toString());
return result;
}
示例14: NodeViewerData
import javax.swing.JTextPane; //导入依赖的package包/类
/**
*
*/
public NodeViewerData() {
this.setLayout(new BorderLayout());
this.dataArea = new JTextPane();
this.toolbar = new JToolBar();
this.toolbar.setFloatable(false);
JScrollPane scroller = new JScrollPane(this.dataArea);
scroller
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
this.add(scroller, BorderLayout.CENTER);
this.add(this.toolbar, BorderLayout.NORTH);
JButton saveButton = new JButton(ZooInspectorIconResources
.getSaveIcon());
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (selectedNode != null) {
if (JOptionPane.showConfirmDialog(NodeViewerData.this,
"Are you sure you want to save this node?"
+ " (this action cannot be reverted)",
"Confirm Save", JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
zooInspectorManager.setData(selectedNode, dataArea
.getText());
}
}
}
});
this.toolbar.add(saveButton);
}
示例15: init
import javax.swing.JTextPane; //导入依赖的package包/类
private void init() {
txpText = new JTextPane();
txpLines = new JTextPane();
// needed for correct layouting
Insets ins = txpLines.getInsets();
txpLines.setMargin(new Insets(ins.top + 1, ins.left, ins.bottom, ins.right));
textHighlighter = new BookmarkHighlighter();
lineHighlighter = new BookmarkHighlighter();
txpText.setHighlighter(textHighlighter);
//txpText.setMinimumSize(new Dimension(100, 100));
txpText.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
txpText.setEditable(false);
txpLines.setHighlighter(lineHighlighter);
txpLines.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
txpLines.setBackground(Color.LIGHT_GRAY);
txpLines.setEnabled(false);
txpLines.setForeground(Color.BLACK);
txpLines.addMouseListener(mouseInputListener);
fm = txpText.getFontMetrics(txpText.getFont());
JPanel pnlBookmarks = new JPanel();
pnlBookmarks.setLayout(new BorderLayout());
pnlBookmarks.add(txpText, BorderLayout.CENTER);
JScrollPane jspBookmarks = new JScrollPane(pnlBookmarks);
jspBookmarks.setRowHeaderView(txpLines);
jspBookmarks.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
jspBookmarks.getVerticalScrollBar().setUnitIncrement(15);
this.setLayout(new BorderLayout());
this.add(jspBookmarks, BorderLayout.CENTER);
}