javax.swing.JEditorPane#setPreferredSize ( )源码实例Demo

下面列出了javax.swing.JEditorPane#setPreferredSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: PropertiesCustomEditor.java
/** This method is called from within the constructor to
 * initialize the form.
 */
private void initComponents() {
    setLayout(new BorderLayout());
    
    editorPane = new JEditorPane();
    editorPane.setContentType("text/x-properties"); // NOI18N
    // XXX pretty arbitrary! No way to set by rows & columns??
    editorPane.setPreferredSize(new Dimension(200, 100));
    add(new JScrollPane(editorPane), BorderLayout.CENTER);

    warnings = new JTextField(30);
    warnings.setEditable(false);
    add(warnings, BorderLayout.SOUTH);
}
 
源代码2 项目: sc2gears   文件: BrowserDialog.java
/**
 * Completes the initialization of the dialog.
 * @param url           URL of the page to be displayed
 * @param preferredSize optional preferred size of the browser component
 */
private void completeInit( final String url, final Dimension preferredSize ) {
	final JEditorPane browserPane = GuiUtils.createEditorPane();
	browserPane.setPreferredSize( preferredSize );
	final JScrollPane scrollPane = new JScrollPane( browserPane );
	scrollPane.setBorder( BorderFactory.createEmptyBorder( 10, 10, 10, 10 ) );
	getContentPane().add( scrollPane, BorderLayout.CENTER );
	
	final JButton okButton = createCloseButton( "button.close" );
	getContentPane().add( GuiUtils.wrapInPanel( okButton ), BorderLayout.SOUTH );
	
	// Load page content in a new thread to not block the AWT event dispatcher thread
	new NormalThread( "Browser dialog content loader" ) {
		@Override
           public void run() {
			try {
				browserPane.setCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) );
		        browserPane.setPage( url );
	        } catch ( final IOException ie ) {
		        ie.printStackTrace();
		        browserPane.setContentType( "text/html" );
		        browserPane.setText( "<html><body style='font-family:arial;font-size:10px;font-style:italic;background:#ffffff;'>"
						+ "<p>This content is currently unavailable. Please try again later.</p></body></html>" );
	        } finally {
				browserPane.setCursor( null );
	        }
           }
	}.start();
	
	packAndShow( okButton, false );
}
 
源代码3 项目: jeddict   文件: ClassMemberPanel.java
private String getCode(String code, String title) {
    JEditorPane editorPane = new JEditorPane();
    editorPane.setContentType("text/x-java");
    editorPane.setPreferredSize(new java.awt.Dimension(600, 400));
    editorPane.setText(code);
    OptionDialog dialog = new OptionDialog(editorPane, title);
    dialog.setVisible(true);
    if (OK_OPTION == dialog.getDialogResult()) {
        return editorPane.getText();
    } else {
        return code;
    }
}
 
源代码4 项目: snap-desktop   文件: TransferMaskDialog.java
private JComponent createHelpPanel() {
    JEditorPane helpPane = new JEditorPane("text/html", null);
    helpPane.setEditable(false);
    helpPane.setPreferredSize(new Dimension(400, 120));
    helpPane.setText("<html><body>Copying the <b>definition</b> of a mask means the mathematical expression " +
    		"is evaluated in the target product. This is only possible,  " +
    		"if the bands which are used in this expression are present in the target product.<br/> " +
    		"Copying the <b>pixel</b> means the data of the mask is transferred to the target product. " +
    		"This is only possible when both product overlap spatially.</body></html>");
    JScrollPane helpPanelScrollPane = new JScrollPane(helpPane);
    helpPanelScrollPane.setBorder(BorderFactory.createTitledBorder("Description"));
    return helpPanelScrollPane;
}
 
源代码5 项目: pentaho-reporting   文件: CompoundDemoFrame.java
protected JComponent createDescriptionTextPane(final URL url)
{
  final JEditorPane editorPane = new JEditorPane();
  editorPane.setEditable(false);
  editorPane.setPreferredSize(new Dimension(400, 200));
  if (url != null)
  {
    try
    {
      editorPane.setPage(url);
    }
    catch (IOException e)
    {
      logger.error("Failed to load demo description", e);
      editorPane.setText("Unable to load the demo description. Error: " + e
          .getMessage());
    }
  }
  else
  {
    editorPane.setText(
        "Unable to load the demo description. No such resource.");
  }

  return new JScrollPane(editorPane,
      JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
      JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}
 
源代码6 项目: pentaho-reporting   文件: SimpleDemoFrame.java
protected JComponent createDefaultContentPane()
{
  final JPanel content = new JPanel(new BorderLayout());
  content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

  final InternalDemoHandler demoHandler = getDemoHandler();
  final JEditorPane editorPane = new JEditorPane();
  final URL url = demoHandler.getDemoDescriptionSource();
  editorPane.setEditable(false);
  editorPane.setPreferredSize(new Dimension(400, 200));
  if (url != null)
  {
    try
    {
      editorPane.setPage(url);
    }
    catch (IOException e)
    {
      editorPane.setText("Unable to load the demo description. Error: " + e.getMessage());
    }
  }
  else
  {
    editorPane.setText("Unable to load the demo description. No such resource.");
  }

  final JScrollPane scroll = new JScrollPane(editorPane,
      JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

  final JButton previewButton = new JButton(getPreviewAction());

  final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
  splitPane.setTopComponent(scroll);
  splitPane.setBottomComponent(demoHandler.getPresentationComponent());
  content.add(splitPane, BorderLayout.CENTER);
  content.add(previewButton, BorderLayout.SOUTH);
  return content;
}
 
源代码7 项目: Course_Generator   文件: frmReleaseNote.java
private void initComponents() {

		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		setTitle(bundle.getString("frmReleaseNote.title")); // Release notes
		setAlwaysOnTop(true);

		// -- Layout
		// ------------------------------------------------------------
		Container paneGlobal = getContentPane();
		paneGlobal.setLayout(new GridBagLayout());

		editorStat = new JEditorPane();
		editorStat.setContentType("text/html");
		editorStat.setEditable(false);
		editorStat.setPreferredSize(new Dimension(600, 400));
		scrollPaneStat = new JScrollPane(editorStat);

		Utils.addComponent(paneGlobal, scrollPaneStat, 0, 0, 1, 1, 1, 1, 10, 10, 0, 10,
				GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);

		chkDisable = new javax.swing.JCheckBox();
		chkDisable.setText(bundle.getString("frmReleaseNote.chkDisable.Text")); // Stop displaying this dialog box.
		Utils.addComponent(paneGlobal, chkDisable, 0, 1, 1, 1, 1, 0, 10, 10, 10, 10,
				GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);

		// == BUTTONS
		// ===========================================================
		jPanelButtons = new javax.swing.JPanel();
		jPanelButtons.setLayout(new FlowLayout());
		Utils.addComponent(paneGlobal, jPanelButtons, 0, 2, GridBagConstraints.REMAINDER, 1, 0, 0, 0, 0, 0, 0,
				GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL);

		btClose = new javax.swing.JButton();
		btClose.setText(bundle.getString("frmReleaseNote.btClose.text")); // Close
		btClose.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				// -- Is the checkbox checked? Yes, set ReleaseNote to version in order to avoid
				// the display of the dialog at the next start
				if (chkDisable.isSelected()) {
					settings.ReleaseVersion = version;
				}
				setVisible(false);
			}
		});

		// -- Add buttons
		jPanelButtons.add(btClose);

		// --
		pack();
		setLocationRelativeTo(null);
	}
 
源代码8 项目: stendhal   文件: UpdateProgressBar.java
private void initializeComponents() {
	JPanel contentPane = (JPanel) this.getContentPane();

	contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
	contentPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	if (fromVersion == null) {
		contentPane.add(new JLabel("Please wait while " + ClientGameConfiguration.get("GAME_NAME") + " is downloaded..."));
	} else {
		contentPane.add(new JLabel("Downloading updates..."));
	}
	contentPane.add(Box.createVerticalStrut(5));

	progressBar = new JProgressBar(0, max);
	progressBar.setStringPainted(false);
	progressBar.setValue(0);
	contentPane.add(progressBar);
	contentPane.add(Box.createVerticalStrut(5));

	if (urlBase != null) {
		// Set up page display.
		browser = new JEditorPane();
		browser.setContentType("text/html");
		browser.setEditable(false);
		Dimension dim = new Dimension(600, 440);
		browser.setPreferredSize(dim);
		browser.addPropertyChangeListener("page", new UpdateProgressBarMetaRefreshSupport());
		browser.addHyperlinkListener(new UpdateProgressBarHyperLinkListener());

		Dimension windowSize = new Dimension(640, 480);
		setPreferredSize(windowSize);
		// TODO: load page async?
		try {
			browser.setPage(urlBase + fromVersion + "/" + toVersion + ".html");
		} catch (IOException e) {
			System.out.println(e);
		}

		// Gige the page scroll bars if it needs them
		final JScrollPane scrollPane = new JScrollPane(browser);
		contentPane.add(scrollPane);
	}
}
 
源代码9 项目: COMP3204   文件: ArtARDemo.java
@Override
public JPanel getComponent(int width, int height) throws IOException {
	final JPanel container = new JPanel();
	container.setSize(width, height);
	container.setPreferredSize(container.getSize());

	final OverlayLayout overlay = new OverlayLayout(container);
	container.setLayout(overlay);

	labelField = new JEditorPane();
	labelField.setOpaque(false);
	labelField.setSize(640 - 50, 480 - 50);
	labelField.setPreferredSize(labelField.getSize());
	labelField.setMaximumSize(labelField.getSize());
	labelField.setContentType("text/html");

	// add a HTMLEditorKit to the editor pane
	final HTMLEditorKit kit = new HTMLEditorKit();
	labelField.setEditorKit(kit);

	final StyleSheet styleSheet = kit.getStyleSheet();
	styleSheet.addRule("body {color:#FF00FF; font-family:courier;}");
	styleSheet.addRule("h1 {font-size: 60pt}");
	styleSheet.addRule("h2 {font-size: 50pt }");

	final Document doc = kit.createDefaultDocument();
	labelField.setDocument(doc);

	// final GridBagConstraints gbc = new GridBagConstraints();
	// gbc.gridy = 1;
	// panel.add(labelField, gbc);
	container.add(labelField);
	// labelField.setAlignmentX(0.5f);
	// labelField.setAlignmentY(0.5f);

	final JPanel panel = super.getComponent(width, height);
	container.add(panel);

	vc.getDisplay().addVideoListener(this);

	isRunning = true;
	new Thread(this).start();

	return container;
}
 
private JComponent createPanel(String html) {
	System.setProperty("awt.useSystemAAFontSettings", "on");
	final JEditorPane editorPane = new JEditorPane();    	
	HTMLEditorKit kit = new HTMLEditorKit();
	editorPane.setEditorKit(kit);
    editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
    editorPane.setFont(new Font("Arial", Font.PLAIN, 12));
    editorPane.setPreferredSize(new Dimension(350, 120));
    editorPane.setEditable(false);
    editorPane.setContentType("text/html");
    editorPane.setBackground(new Color(234, 241, 248));        
   
    Document doc = kit.createDefaultDocument();
    editorPane.setDocument(doc);
    editorPane.setText(html);

    // Add Hyperlink listener to process hyperlinks
    editorPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(final HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        SwingUtilities.getWindowAncestor(editorPane).setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                        editorPane.setToolTipText(e.getURL().toExternalForm());
                    }
                });
            } else if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
                EventQueue.invokeLater(new Runnable() {
                    public void run() {                            
                        SwingUtilities.getWindowAncestor(editorPane).setCursor(Cursor.getDefaultCursor());
                        editorPane.setToolTipText(null);
                    }
                });
            } else if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {       
            	    FileUtil.openUrl(e.getURL().toString(), AboutAction.class);                       
            }
        }
    });        
    editorPane.addMouseListener(mouseListener);
    JScrollPane sp = new JScrollPane(editorPane);       
    return sp;
}