本文整理了Java中javax.swing.JTextPane.setPreferredSize()
方法的一些代码示例,展示了JTextPane.setPreferredSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextPane.setPreferredSize()
方法的具体详情如下:
包路径:javax.swing.JTextPane
类名称:JTextPane
方法名:setPreferredSize
暂无
代码示例来源:origin: stanfordnlp/CoreNLP
textPane.setPreferredSize(new java.awt.Dimension(250, 250));
textPane.addFocusListener(new java.awt.event.FocusAdapter() {
@Override
代码示例来源:origin: wiztools/rest-client
Dimension d = jtp_help_center.getPreferredSize();
jtp_help_center.setText(helpText);
jtp_help_center.setPreferredSize(d);
jtp_help_center.setCaretPosition(0);
JScrollPane jsp_center = new JScrollPane(jtp_help_center);
代码示例来源:origin: apache/pdfbox
@Override
public void actionPerformed(ActionEvent e)
{
if (showingDetails)
{
main.remove(details);
main.validate();
main.setPreferredSize(MESSAGE_SIZE);
}
else
{
if (details == null)
{
details = createDetailedMessage(error);
StringBuilder buffer = new StringBuilder();
stacktrace.setText(generateStackTrace(error, buffer).toString());
stacktrace.setCaretPosition(0);
stacktrace.setBackground(main.getBackground());
stacktrace.setPreferredSize(STACKTRACE_SIZE);
}
main.add(details, BorderLayout.CENTER);
main.validate();
main.setPreferredSize(TOTAL_SIZE);
}
showingDetails = !showingDetails;
showDetails.setText(showingDetails ? "<< Hide Details" : "Show Details >>");
ErrorDialog.this.pack();
}
});
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
JPanel pnel = new JPanel();
frame.setContentPane(pnel);
JTextPane txtpane = new JTextPane();
txtpane.setPreferredSize(new Dimension(200, 200));
JScrollPane jsp = new JScrollPane(txtpane,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
pnel.add(jsp);
frame.pack();
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
JScrollPane scrollPane = new JScrollPane();
//scrollPane.setBounds(402, 211, 178, 193); // Don't do this!
frame.getContentPane().add(scrollPane);
JPanel panel = new JPanel();
scrollPane.setViewportView(panel);
//panel.setLayout(null); // Use a Layout Manager
JTextPane textPane_branding = new JTextPane();
textPane_branding.setPreferredSize(new Dimension(78,191));
//textPane_branding.setBounds(98, 0, 78, 191);
panel.add(textPane_branding);
JTextPane textPane_trunk = new JTextPane();
textPane_trunk.setPreferredSize(new Dimension(88,191));
//textPane_trunk.setBounds(0, 0, 88, 191);
panel.add(textPane_trunk);
代码示例来源:origin: edu.illinois.lis/indri
/** Create the frame that shows the help file and render the html.
*/
private void makeHelp() {
java.net.URL helpURL = IndexUI.class.getResource(helpFile);
JTextPane help = new JTextPane();
//Create and set up the window.
helpFrame = new JFrame("Indri Index Builder Help");
help.setPreferredSize(new Dimension(650, 400));
help.setEditable(false);
help.addHyperlinkListener(new DocLinkListener(indriIcon.getImage()));
JScrollPane scroller = new JScrollPane(help);
try {
help.setPage(helpURL);
} catch (IOException ex) {
help.setText("Help file unavailable.");
}
helpFrame.getContentPane().add(scroller, BorderLayout.CENTER);
helpFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
helpFrame.setIconImage(indriIcon.getImage());
helpFrame.pack();
}
代码示例来源:origin: edu.illinois.lis/indri
/**
* Make the frame for displaying html documents
*/
private void makeDocHtmlFrame() {
docHtmlFrame = new JFrame("Html");
docHtmlFrame.setIconImage(createImageIcon(iconFile).getImage());
docHtmlPane = new JTextPane();
docHtmlPane.setEditable(false);
docHtmlPane.setBackground(linen);
docHtmlPane.setForeground(Color.black);
docHtmlPane.setPreferredSize(new Dimension(550, 350));
JScrollPane scroll = new JScrollPane(docHtmlPane);
scroll.setDoubleBuffered(true);
docHtmlFrame.getContentPane().add(scroll, BorderLayout.CENTER);
docHtmlFrame.pack();
docHtmlFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
}
代码示例来源:origin: edu.illinois.lis/indri
/** Create the frame that shows the help file and render the html.
Saves time when the user opens the help.
*/
private void makeHelp() {
java.net.URL helpURL = RetUI.class.getResource(helpFile);
Image image = createImageIcon(iconFile).getImage();
JTextPane help = new JTextPane();
//Create and set up the window.
helpFrame = new JFrame("Indri Retrieval UI Help");
help.setPreferredSize(new Dimension(650, 400));
help.setEditable(false);
help.addHyperlinkListener(new DocLinkListener(image));
JScrollPane scroller = new JScrollPane(help);
try {
help.setPage(helpURL);
} catch (IOException ex) {
help.setText("Help file unavailable.");
}
helpFrame.getContentPane().add(scroller, BorderLayout.CENTER);
helpFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
helpFrame.setIconImage(image);
helpFrame.pack();
}
代码示例来源:origin: blackears/svgSalamander
textpane_text.setPreferredSize(new java.awt.Dimension(400, 300));
jPanel1.add(textpane_text, java.awt.BorderLayout.CENTER);
代码示例来源:origin: com.metsci.ext.com.kitfox.svg/svg-salamander
textpane_text.setPreferredSize(new java.awt.Dimension(400, 300));
jPanel1.add(textpane_text, java.awt.BorderLayout.CENTER);
代码示例来源:origin: com.barchart.kitfox/kitfox-svg-core
textpane_text.setPreferredSize(new java.awt.Dimension(400, 300));
jPanel1.add(textpane_text, java.awt.BorderLayout.CENTER);
代码示例来源:origin: fr.ifremer/isis-fish
/**
* Affiche une boite de dialogue modale permettant de modifier l'expression
* R.
*
* @param rCall r instruction to edit
* @return user edited r instruction
*/
protected String editRInstruction(String rCall) {
JLabel label = new JLabel(t("Modifier le code R envoyé si vous le souhaitez"));
JTextPane text = new JTextPane();
text.setText(rCall);
text.setSize(400, 400);
text.setPreferredSize(text.getSize());
Box box = Box.createVerticalBox();
box.add(label);
box.add(new JScrollPane(text));
JOptionPane.showMessageDialog(null, box, t("R modif"), JOptionPane.QUESTION_MESSAGE);
return text.getText();
}
代码示例来源:origin: org.gdl-lang.gdl-tools/openehr-utils-gui-swing
private JTextPane getTextPane() {
if (jTextPane == null) {
jTextPane = new JTextPane();
StyledEditorKit kit = new StyledEditorKit();
jTextPane.setEditorKit(kit);
jTextPane.getDocument().putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n");
jTextPane.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 12));
jTextPane.setText(OpenEHRLanguageManager.getMessage("NullValueDesc"));
jTextPane.setEditable(false);
jTextPane.setBackground(null);
jTextPane.setPreferredSize(new java.awt.Dimension(250, 70));
}
return jTextPane;
}
代码示例来源:origin: org.gdl-lang.gdl-tools/openehr-utils-gui-swing
private JTextPane getTextPane() {
if (jTextPane == null) {
jTextPane = new JTextPane();
StyledEditorKit kit = new StyledEditorKit();
jTextPane.setEditorKit(kit);
jTextPane.getDocument().putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n");
jTextPane.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 12));
jTextPane.setText(_archetypeElementVO.getDescription());
jTextPane.setEditable(false);
jTextPane.setBackground(null);
jTextPane.setPreferredSize(new java.awt.Dimension(250, 70));
}
return jTextPane;
}
代码示例来源:origin: zgqq/mah
private void initInput() {
JTextPane input = new JTextPane();
int inputWidth = (int) (panelPrefWidth * 0.9);
int inputHeight = (int) (panelPrefHeight * 0.8);
input.setPreferredSize(new Dimension((inputWidth), inputHeight));
input.setBorder(BorderFactory.createCompoundBorder(
input.getBorder(),
BorderFactory.createEmptyBorder(5, 5, 5, 5)));
input.setFont(new Font(FontManager.getInstance().getCurrentFontName(), Font.PLAIN, 24));
limitInputCharacterNum(input);
listenInputMethod(input);
listenInput(input);
disposeKeybinds(input);
this.input = input;
this.panel.setPreferredSize(new Dimension(panelPrefWidth, panelPrefHeight));
this.panel.add(input);
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) throws Exception {
JTextPane pane = new JTextPane();
Style regular = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
Style invisible = pane.getStyledDocument().addStyle("invisible", regular);
StyleConstants.setFontSize(invisible, 0);
StyleConstants.setForeground(invisible, pane.getBackground());
pane.getStyledDocument().insertString(pane.getStyledDocument().getLength(),
"Hello, ", null);
pane.getStyledDocument().insertString(pane.getStyledDocument().getLength(),
"cruel ", pane.getStyledDocument().getStyle("invisible"));
pane.getStyledDocument().insertString(pane.getStyledDocument().getLength(),
"world!", null);
pane.setPreferredSize(new Dimension(500, 500));
JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.add(pane, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack(); frame.setVisible(true);
}
代码示例来源:origin: hneemann/Digital
/**
* Creates a new Frame
*
* @param owner the owner frame
* @param font the font to use
*/
public AllSolutionsDialog(JDialog owner, Font font) {
super(owner, Lang.get("win_allSolutions"), false);
setDefaultCloseOperation(HIDE_ON_CLOSE);
textPane = new JTextPane();
textPane.setContentType("text/html");
textPane.setFont(font);
textPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
textPane.setEditable(false);
textPane.setPreferredSize(Screen.getInstance().scale(new Dimension(600, 300)));
scroll = new JScrollPane(textPane);
getContentPane().add(scroll);
pack();
setLocation(0, 0);
}
代码示例来源:origin: antlr/antlrworks
public void awake() {
panel = new JPanel(new BorderLayout());
textPane = new JTextPane();
textPane.setBackground(Color.white);
textPane.setBorder(null);
textPane.setPreferredSize(new Dimension(300, 100));
textPane.setFont(new Font(AWPrefs.getEditorFont(), Font.PLAIN, AWPrefs.getEditorFontSize()));
TextUtils.createTabs(textPane);
TextUtils.setDefaultTextPaneProperties(textPane);
textScrollPane = new JScrollPane(textPane);
textScrollPane.setWheelScrollingEnabled(true);
treeModel = new EditorInterpreterTreeModel();
awTreePanel = new AWTreePanel(treeModel);
awTreePanel.setDelegate(this);
splitPane = new JSplitPane();
splitPane.setBorder(null);
splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setLeftComponent(textScrollPane);
splitPane.setRightComponent(awTreePanel);
splitPane.setContinuousLayout(true);
splitPane.setOneTouchExpandable(true);
panel.add(createControlPanel(), BorderLayout.NORTH);
panel.add(splitPane, BorderLayout.CENTER);
window.registerUndo(null, textPane);
}
代码示例来源:origin: fr.inria.wimmics/kggui
textPaneQuery.setPreferredSize(new Dimension(400, 250));
textPaneQuery.setMargin(new Insets(1, 1, 1, 1));
textPaneQuery.setText("Default text");
代码示例来源:origin: stackoverflow.com
public class DialogTest {
public static void main(String[] args) throws Exception {
JTextPane jtp = new JTextPane();
Document doc = jtp.getDocument();
for (int i = 0; i < 50; i++) {
doc.insertString(doc.getLength(), " Hello Java World ", new SimpleAttributeSet());
if ((3 == i) || (7 == i) || (15 == i)) {
doc.insertString(doc.getLength(), " Hello Java World ", new SimpleAttributeSet());
SimpleAttributeSet attrs = new SimpleAttributeSet();
StyleConstants.setUnderline(attrs, true);
StyleConstants.setForeground(attrs, Color.BLUE);
String text = "www.google.com";
URL url = new URL("http://" + text);
attrs.addAttribute(HTML.Attribute.HREF, url.toString());
doc.insertString(doc.getLength(), text, attrs);
}
}
//JScrollPane jsp = new JScrollPane(jtp);
//jsp.setPreferredSize(new Dimension(480, 150));
//jsp.setBorder(null);
jtp.setSize(new Dimension(480, 10));
jtp.setPreferredSize(new Dimension(480, jtp.getPreferredSize().height));
//JOptionPane.showMessageDialog(null, jsp, "Title", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, jtp, "Title", JOptionPane.INFORMATION_MESSAGE);
}}
内容来源于网络,如有侵权,请联系作者删除!