public @Override Dimension getPreferredSize() { try { return super.getPreferredSize(); } catch (RuntimeException e) { //Bug in javax.swing.text.html.BlockView return new Dimension(400, 600); } }
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 ?
public Dimension getPreferredSize() { try { return super.getPreferredSize(); } catch (RuntimeException e) { //Bug in javax.swing.text.html.BlockView return new Dimension (400, 600); } }
public Dimension getPreferredSize() { try { return super.getPreferredSize(); } catch (RuntimeException e) { //Bug in javax.swing.text.html.BlockView return new Dimension (400, 600); } }
@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); }
@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); }
@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); }
@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); }
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); }
@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; } } });
@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; } } });
public Dimension getPreferredSize() { if (pendingText != null) { forceSetText = true; setText(pendingText); } return super.getPreferredSize(); }
@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); } }
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");
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; }
@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); } }
@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); } }
/** 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_); }
@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); } }
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))); }