javax.swing.JEditorPane.getPreferredSize()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(167)

本文整理了Java中javax.swing.JEditorPane.getPreferredSize()方法的一些代码示例,展示了JEditorPane.getPreferredSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.getPreferredSize()方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:getPreferredSize

JEditorPane.getPreferredSize介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-awt

public @Override Dimension getPreferredSize() {
  try {
    return super.getPreferredSize();
  } catch (RuntimeException e) {
    //Bug in javax.swing.text.html.BlockView
    return new Dimension(400, 600);
  }
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

Dimension d = textArea.getPreferredSize();
Rectangle r = null;
try {
  d = textArea.getPreferredSize();
  d.width += 25; // Just a little extra space
  final int maxWindowW = ft.getMaxSize() != null ?

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

public Dimension getPreferredSize() {
  try {
    return super.getPreferredSize();
  } catch (RuntimeException e) {
    //Bug in javax.swing.text.html.BlockView
    return new Dimension (400, 600);
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

public Dimension getPreferredSize() {
  try {
    return super.getPreferredSize();
  } catch (RuntimeException e) {
    //Bug in javax.swing.text.html.BlockView
    return new Dimension (400, 600);
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

@Override
public Dimension calculatePreferredSize() {
  //TODO returns a Dimension that is either X wide, or as wide as necessary
  //to show the title. It is Y high.
  return new Dimension(iconLabel.getPreferredSize().width + errorMessage.getPreferredSize().width, 206);
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

@Override
public Dimension calculatePreferredSize() {
  //TODO returns a Dimension that is either X wide, or as wide as necessary
  //to show the title. It is Y high.
  return new Dimension(iconLabel.getPreferredSize().width + errorMessage.getPreferredSize().width, 206);
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

@Override
public Dimension calculatePreferredSize() {
  //TODO returns a Dimension that is either X wide, or as wide as necessary
  //to show the title. It is Y high.
  return new Dimension(iconLabel.getPreferredSize().width + errorMessage.getPreferredSize().width, 206);
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

@Override
public Dimension calculatePreferredSize() {
  //TODO returns a Dimension that is either X wide, or as wide as necessary
  //to show the title. It is Y high.
  return new Dimension(iconLabel.getPreferredSize().width + errorMessage.getPreferredSize().width, 206);
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

public Dimension calculatePreferredSize() {
  //TODO returns a Dimension that is either X wide, or as wide as necessary
  //to show the title. It is Y high.
  return new Dimension(iconLabel.getPreferredSize().width + errorMessage.getPreferredSize().width, 206);
}

代码示例来源:origin: de.sciss/jsyntaxpane

@Override
  public void run() {
    int preferredHeight = editor.getPreferredSize().height;
    //  Document change has caused a change in the number of lines.
    //  Repaint to reflect the new line numbers
    if (lastHeight != preferredHeight) {
      setPreferredWidth();
      repaint();
      lastHeight = preferredHeight;
    }
  }
});

代码示例来源:origin: de.sciss/syntaxpane

@Override
  public void run() {
    int preferredHeight = editor.getPreferredSize().height;
    //  Document change has caused a change in the number of lines.
    //  Repaint to reflect the new line numbers
    if (lastHeight != preferredHeight) {
      setPreferredWidth(false);
      repaint();
      lastHeight = preferredHeight;
    }
  }
});

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

public Dimension getPreferredSize() {
  if (pendingText != null) {
    forceSetText = true;
    setText(pendingText);
  }
  return super.getPreferredSize();
}

代码示例来源:origin: com.eas.platypus/platypus-js-grid

@Override
public Dimension getPreferredSize() {
  if (colGroup.isLeaf()) {
    int colGroupPWidth = colGroup.getWidth();
    setSize(colGroupPWidth, Integer.MAX_VALUE / 2);
    Dimension d = super.getPreferredSize();
    return new Dimension(colGroupPWidth, d.height);
  } else {
    Dimension d = super.getPreferredSize();
    return new Dimension(0, d.height);
  }
}

代码示例来源: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: 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: com.eas.platypus/platypus-js-grid

@Override
public Dimension getMaximumSize() {
  if (colGroup.isLeaf()) {
    Dimension d = super.getMaximumSize();
    return new Dimension(Math.min(d.width, colGroup.getMaxWidth()), d.height);
  } else {
    Dimension d = super.getPreferredSize();
    return new Dimension(Integer.MAX_VALUE, d.height);
  }
}

代码示例来源:origin: com.eas.platypus/platypus-js-grid

@Override
public Dimension getMinimumSize() {
  if (colGroup.isLeaf()) {
    Dimension d = super.getMinimumSize();
    View view = getUI().getRootView(this);
    if (view != null) {
      d.width = Math.round(view.getMinimumSpan(View.X_AXIS));
    }
    return new Dimension(Math.max(d.width, colGroup.getMinWidth()), d.height);
  } else {
    Dimension d = super.getPreferredSize();
    return new Dimension(0, d.height);
  }
}

代码示例来源:origin: net.sf.jt400/jt400

/**
Returns the preferred size of the viewport for a view component.
@return the preferred size of the viewport for a view component.
**/
public Dimension getPreferredScrollableViewportSize()
{
  if (pheight_ == 0)
  {
    if (getFont() == null)
      return super.getPreferredScrollableViewportSize();
    // Determine the preferred hieght - height of the font
    // times the number of rows+1.
    pheight_ = getFontMetrics(getFont()).getHeight() * (numRows_ + 1);
  }
  return new Dimension(getPreferredSize().width, pheight_);
}

代码示例来源:origin: freeplane/freeplane

@SuppressWarnings("unchecked")
  public void actionPerformed(ActionEvent e) {
    final DefaultMutableTreeNode menuEntryTree = MenuUtils.createAcceleratebleMenuEntryTree("main_menu");
    final String title = TextUtils.getText("hot_keys_table");
    final String html = formatAsHtml(menuEntryTree.children());
    JEditorPane refPane = new JEditorPane("text/html", html);
    refPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, false);
    refPane.setCaretPosition(0);
    refPane.setEditable(false);
    final Dimension preferredSize = refPane.getPreferredSize();
    JScrollPane scrollPane = new JScrollPane(refPane, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(preferredSize.width, 600));
    JOptionPane pane = new JOptionPane(scrollPane, JOptionPane.INFORMATION_MESSAGE);
    JDialog dialog = pane.createDialog(UITools.getMenuComponent(), title);
     // the line below is added to the example from the docs
     dialog.setModal(false); // this says not to block background components
    dialog.setResizable(true);
    dialog.setVisible(true);
  }
}

代码示例来源: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)));
}

相关文章

JEditorPane类方法