本文整理了Java中javax.swing.JEditorPane.setSize()
方法的一些代码示例,展示了JEditorPane.setSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.setSize()
方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:setSize
暂无
代码示例来源:origin: stackoverflow.com
public class HTMLPrinter implements Printable{
private final JEditorPane printPane;
public HTMLPrinter(JEditorPane editorPane){
printPane = editorPane;
}
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex){
if (pageIndex >= 1) return Printable.NO_SUCH_PAGE;
Graphics2D g2d = (Graphics2D)graphics;
g2d.setClip(0, 0, (int)pageFormat.getImageableWidth(), (int)pageFormat.getImageableHeight());
g2d.translate((int)pageFormat.getImageableX(), (int)pageFormat.getImageableY());
RepaintManager rm = RepaintManager.currentManager(printPane);
boolean doubleBuffer = rm.isDoubleBufferingEnabled();
rm.setDoubleBufferingEnabled(false);
printPane.setSize((int)pageFormat.getImageableWidth(), 1);
printPane.print(g2d);
rm.setDoubleBufferingEnabled(doubleBuffer);
return Printable.PAGE_EXISTS;
}
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
textArea.setSize(d);
代码示例来源:origin: stackoverflow.com
String text = "Potentially looooooong text. " +
"Lorem ipsum dolor sit amet, consectetuer" +
"adipiscing elit, sed diam nonummy nibh euismod " +
"tincidunt ut laoreet dolore magna aliquam" +
"adipiscing elit, sed diam nonummy nibh euismod" +
"erat volutpat. Ut wisi enim ad minim veniam, " +
"quis nostrud exerci tation.";
final JEditorPane editorPane = new JEditorPane("text/html", text);
editorPane.setSize(300, Integer.MAX_VALUE);
editorPane.setEditable(false);
代码示例来源:origin: stackoverflow.com
//load the webpage into the editor
JEditorPane ed = new JEditorPane(new URL("http://www.google.com"));
ed.setSize(200,200);
//create a new image
BufferedImage image = new BufferedImage(ed.getWidth(), ed.getHeight(),
BufferedImage.TYPE_INT_ARGB);
//paint the editor onto the image
SwingUtilities.paintComponent(image.createGraphics(),
ed,
new JPanel(),
0, 0, image.getWidth(), image.getHeight());
//save the image to file
ImageIO.write((RenderedImage)image, "png", new File("google.png"));
代码示例来源:origin: stackoverflow.com
public static int getContentHeight(String content) {
JEditorPane dummyEditorPane=new JEditorPane();
dummyEditorPane.setSize(100,Short.MAX_VALUE);
dummyEditorPane.setText(content);
return dummyEditorPane.getPreferredSize().height;
}
int h=getContentHeight("Long text to be measured in the JEditorPane");
代码示例来源:origin: stackoverflow.com
public class Example1 {
private static final int WIDTH = 1204;
private static final int HEIGHT = 768;
public static void main(String[] args) throws IOException {
// open HTML page
JEditorPane editorPane = new JEditorPane();
editorPane.setEditable(false);
URL urlToPage = new File("/home/me/Temp/cover.html").toURI().toURL();
editorPane.setPage(urlToPage);
editorPane.setSize(WIDTH, HEIGHT);
// render the page
BufferedImage renderedImage = new BufferedImage(640, 480, BufferedImage.TYPE_INT_RGB);
editorPane.print(renderedImage.getGraphics());
// write result to file
ImageIO.write(renderedImage, "PNG", new File("/home/me/Temp/hello-world.png"));
}
}
代码示例来源:origin: sanity/tahrir
private int calculatePanelHeight(BroadcastMessage bm) {
// we have to estimate the width of the text pane, so that getPreferredSize
// can calculate the height based on the length of the message text.
// the trouble here is that JTable needs a fixed pixel height, where as
// the rest of the dimensions are calculated by the layout manager, leading
// to this magic number. maybe we should consider getting rid of the JTable
// (which is currently used to list the posts)
final int messageTextWidth = 360;
final JEditorPane dummyTextPane = new JEditorPane();
dummyTextPane.setSize(messageTextWidth, Short.MAX_VALUE);
dummyTextPane.setText(bm.signedBroadcastMessage.parsedBroadcastMessage.getPlainTextBroadcastMessage());
return dummyTextPane.getPreferredSize().height + 100;
}
代码示例来源:origin: stackoverflow.com
JEditorPane pane = new JEditorPane();
pane.setBorder(null);
pane.setSize(w, h);
pane.setContentType("text/html");
pane.setEditable(false);
pane.setText(html);
pane.paint(g2);
代码示例来源:origin: org.jvnet.hudson.plugins.hudsontrayapp/client-common
/**
* This method initializes descriptionEditorPane
*
* @return javax.swing.JEditorPane
*/
private JEditorPane getDescriptionEditorPane() {
if (descriptionEditorPane == null) {
descriptionEditorPane = new JEditorPane();
descriptionEditorPane.setSize(new Dimension(546, 128));
descriptionEditorPane.setBackground(SystemColor.control);
descriptionEditorPane.setPreferredSize(new Dimension(48, 48));
descriptionEditorPane.setText("");
descriptionEditorPane.setEditable(false);
descriptionEditorPane.setContentType("text/html");
descriptionEditorPane.setFont(new Font("SansSerif", Font.PLAIN, 12));
}
return descriptionEditorPane;
}
代码示例来源:origin: bspkrs/MCPMappingViewer
ep.setSize(100, 100);
ep.setEditable(false);
ep.setBackground(label.getBackground());
代码示例来源:origin: nroduit/Weasis
public void doPagesLayout() {
setLayout(null);
removeAll();
this.rootView = sourcePane.getUI().getRootView(sourcePane);
sourcePane.setSize(pageWidth - margins.top - margins.bottom, Integer.MAX_VALUE);
Dimension d = sourcePane.getPreferredSize();
sourcePane.setSize(pageWidth - margins.top - margins.bottom, d.height);
calculatePageInfo();
int count = pages.size();
this.setPreferredSize(new Dimension(pageWidth * 2 + 50, PAGE_SHIFT + count * (pageHeight + PAGE_SHIFT)));
}
代码示例来源:origin: stackoverflow.com
@Override
public void componentResized(ComponentEvent e) {
editor.setSize(new Dimension(
scroller.getWidth()-20,
scroller.getHeight()-20));
代码示例来源:origin: stefanhaustein/nativehtml
@Override
public float getIntrinsicContentBoxHeightForWidth(float contentBoxWidth, float parentContentBoxWidth) {
check();
float scale = document.getSettings().getScale();
String html = serialize();
if (resizer == null) {
resizer = new JEditorPane();
configureEditor(resizer);
}
resizer.setText(html);
/* View view = (View) resizer.getClientProperty(
javax.swing.plaf.basic.BasicHTML.propertyKey);
view.setSize(width, 0);
float h = view.getPreferredSpan(View.Y_AXIS);
System.out.println("TexComponent height (w=" + width + "):" + h);
*/
resizer.setSize(Math.round(contentBoxWidth * scale), Short.MAX_VALUE);
float h= resizer.getPreferredSize().height;
return Math.round((h + HEIGHT_CORRECTION) / scale) ;
}
代码示例来源:origin: freeplane/freeplane
private void setTipTextUnsafe(String tipText) throws Exception{
tip.setSize(0, 0);
tip.setPreferredSize(null);
tip.setText(tipText);
((HTMLDocument)tip.getDocument()).setBase(baseUrl);
Dimension preferredSize = tip.getPreferredSize();
if (preferredSize.width > maximumWidth && contentType.equals(FreeplaneTooltip.TEXT_HTML)) {
final HTMLDocument document = (HTMLDocument) tip.getDocument();
document.getStyleSheet().addRule("body { width: " + maximumWidth + "}");
// bad hack: call "setEditable" only to update view
tip.setEditable(true);
tip.setEditable(false);
preferredSize = tip.getPreferredSize();
if (preferredSize.width > maximumWidth) {
}
}
tip.setSize(preferredSize);
preferredSize = tip.getPreferredSize();
tip.setPreferredSize(preferredSize);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2
@Override
public void setSize(Dimension d){
if (d.width < getParent().getSize().width)
d.width = getParent().getSize().width;
super.setSize(d);
}
代码示例来源:origin: org.jspresso.framework/jspresso-swing-components
detailsButton.setText(translationProvider.getTranslation("details",
locale) + ">>");
messagePane.setSize(0, 0);
messagePane.setSize(messagePane.getPreferredSize());
setSize(getWidth(), collapsedHeight);
代码示例来源:origin: com.fifesoft/rsyntaxtextarea
textArea.setSize(d);
代码示例来源:origin: org.swinglabs.swingx/swingx-all
errorMessage.setSize(0, 0);
errorMessage.setSize(errorMessage.getPreferredSize());
pane.setSize(pane.getWidth(), collapsedHeight);
} else {
代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop
errorMessage.setSize(0, 0);
errorMessage.setSize(errorMessage.getPreferredSize());
pane.setSize(pane.getWidth(), collapsedHeight);
} else {
代码示例来源:origin: com.haulmont.thirdparty/swingx-core
errorMessage.setSize(0, 0);
errorMessage.setSize(errorMessage.getPreferredSize());
pane.setSize(pane.getWidth(), collapsedHeight);
} else {
内容来源于网络,如有侵权,请联系作者删除!