Java Code Examples for javax.swing.JEditorPane#setBorder()

The following examples show how to use javax.swing.JEditorPane#setBorder() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebStorePanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private double getAdjustedHeight(){
    JEditorPane fakePane = new JEditorPane();
    fakePane.setEditable(false);
    fakePane.setBorder(null);
    fakePane.setContentType("text/html"); // NOI18N
    fakePane.setFont(description.getFont());
    Dimension size = description.getPreferredSize();
    size.setSize( size.getWidth(), Short.MAX_VALUE);
    fakePane.setSize( size);
    fakePane.setText(description.getText());
    Font font = description.getFont();
    String bodyRule = "body { font-family: " + font.getFamily() + "; " +
            "font-size: " + font.getSize() + "pt; }";
    ((HTMLDocument)fakePane.getDocument()).getStyleSheet().addRule(bodyRule);
    return fakePane.getPreferredSize().getHeight();
}
 
Example 2
Source File: AnnotationDrawUtils.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Calculates the preferred height of an editor pane with the given fixed width for the
 * specified string.
 *
 * @param comment
 *            the annotation comment string
 * @param width
 *            the width of the content
 * @return the preferred height given the comment
 */
public static int getContentHeight(final String comment, final int width, final Font font) {
	if (comment == null) {
		throw new IllegalArgumentException("comment must not be null!");
	}
	// do not create Swing components for headless mode
	if (RapidMiner.getExecutionMode().isHeadless()) {
		return 0;
	}
	JEditorPane dummyEditorPane = new JEditorPane("text/html", "");
	dummyEditorPane.setText(comment);
	dummyEditorPane.setBorder(null);
	dummyEditorPane.setSize(width, Short.MAX_VALUE);
	dummyEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
	dummyEditorPane.setFont(font);

	// height is not exact. Multiply by magic number to get a more fitting value...
	if (SystemInfoUtilities.getOperatingSystem() == OperatingSystem.OSX
			|| SystemInfoUtilities.getOperatingSystem() == OperatingSystem.UNIX
			|| SystemInfoUtilities.getOperatingSystem() == OperatingSystem.SOLARIS) {
		return (int) (dummyEditorPane.getPreferredSize().getHeight() * 1.05f);
	} else {
		return (int) dummyEditorPane.getPreferredSize().getHeight();
	}
}
 
Example 3
Source File: HelloWorldView.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
protected DataViewComponent createComponent() {

        //Data area for master view:
        JEditorPane generalDataArea = new JEditorPane();
        generalDataArea.setBorder(BorderFactory.createEmptyBorder(14, 8, 14, 8));

        //Panel, which we'll reuse in all four of our detail views for this sample:
        JPanel panel = new JPanel();

        //Master view:
        DataViewComponent.MasterView masterView = new DataViewComponent.MasterView("Hello World Overview", null, generalDataArea);

        //Configuration of master view:
        DataViewComponent.MasterViewConfiguration masterConfiguration =
                new DataViewComponent.MasterViewConfiguration(false);

        //Add the master view and configuration view to the component:
        dvc = new DataViewComponent(masterView, masterConfiguration);

        //Add detail views to the component:
        dvc.addDetailsView(new DataViewComponent.DetailsView(
                "Hello World Details 1", null, 10, panel, null), DataViewComponent.TOP_LEFT);

        return dvc;

    }
 
Example 4
Source File: HelloWorldView.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
protected DataViewComponent createComponent() {

        //Data area for master view:
        JEditorPane generalDataArea = new JEditorPane();
        generalDataArea.setBorder(BorderFactory.createEmptyBorder(14, 8, 14, 8));

        //Panel, which we'll reuse in all four of our detail views for this sample:
        JPanel panel = new JPanel();

        //Master view:
        DataViewComponent.MasterView masterView = new DataViewComponent.MasterView("Hello World Overview", null, generalDataArea);

        //Configuration of master view:
        DataViewComponent.MasterViewConfiguration masterConfiguration =
                new DataViewComponent.MasterViewConfiguration(false);

        //Add the master view and configuration view to the component:
        dvc = new DataViewComponent(masterView, masterConfiguration);

        //Add detail views to the component:
        dvc.addDetailsView(new DataViewComponent.DetailsView(
                "Hello World Details 1", null, 10, panel, null), DataViewComponent.TOP_LEFT);

        return dvc;

    }
 
Example 5
Source File: OutOfDateDialog.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
static Component showOutOfDateComponent(final Version latestVersionOut) {
  final JPanel panel = new JPanel(new BorderLayout());
  final JEditorPane intro = new JEditorPane("text/html", getOutOfDateMessage(latestVersionOut));
  intro.setEditable(false);
  intro.setOpaque(false);
  intro.setBorder(BorderFactory.createEmptyBorder());
  final HyperlinkListener hyperlinkListener =
      e -> {
        if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
          OpenFileUtility.openUrl(e.getDescription());
        }
      };
  intro.addHyperlinkListener(hyperlinkListener);
  panel.add(intro, BorderLayout.NORTH);
  final JEditorPane updates = new JEditorPane("text/html", getOutOfDateReleaseUpdates());
  updates.setEditable(false);
  updates.setOpaque(false);
  updates.setBorder(BorderFactory.createEmptyBorder());
  updates.addHyperlinkListener(hyperlinkListener);
  updates.setCaretPosition(0);
  final JScrollPane scroll = new JScrollPane(updates);
  panel.add(scroll, BorderLayout.CENTER);
  final Dimension maxDimension = panel.getPreferredSize();
  maxDimension.width = Math.min(maxDimension.width, 700);
  maxDimension.height = Math.min(maxDimension.height, 480);
  panel.setMaximumSize(maxDimension);
  panel.setPreferredSize(maxDimension);
  return panel;
}
 
Example 6
Source File: AboutDialog.java    From FancyBing with GNU General Public License v3.0 5 votes vote down vote up
private JPanel createPanel(String text)
{
    JPanel panel = new JPanel(new GridLayout(1, 1));
    JEditorPane editorPane = new JEditorPane();
    editorPane.setBorder(GuiUtil.createEmptyBorder());
    editorPane.setEditable(false);
    if (Platform.isMac())
    {
        editorPane.setForeground(UIManager.getColor("Label.foreground"));
        editorPane.setBackground(UIManager.getColor("Label.background"));
    }
    else
    {
        editorPane.setForeground(Color.black);
        editorPane.setBackground(Color.white);
    }
    panel.add(editorPane);
    EditorKit editorKit =
        JEditorPane.createEditorKitForContentType("text/html");
    editorPane.setEditorKit(editorKit);
    editorPane.setText(text);
    editorPane.addHyperlinkListener(new HyperlinkListener()
        {
            public void hyperlinkUpdate(HyperlinkEvent event)
            {
                HyperlinkEvent.EventType type = event.getEventType();
                if (type == HyperlinkEvent.EventType.ACTIVATED)
                {
                    URL url = event.getURL();
                    if (! Platform.openInExternalBrowser(url))
                        m_messageDialogs.showError(null,
                                                   i18n("MSG_ABOUT_OPEN_URL_FAIL"),
                                                   "", false);
                }
            }
        });
    return panel;
}
 
Example 7
Source File: BasicHTMLRenderer.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new JEditorPane with the given text
 *
 * @param text
 * 		the html text
 */
BasicHTMLRenderer(String text) {
	renderer = new JEditorPane("text/html", text);
	renderer.addHyperlinkListener(e -> {
		if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
			RMUrlHandler.handleUrl(e.getDescription());
		}
	});
	renderer.setOpaque(false);
	renderer.setEditable(false);
	renderer.setBorder(null);
}
 
Example 8
Source File: AnnotationDrawer.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new drawer for the specified model and decorator.
 *
 * @param model
 *            the model containing all relevant drawing data
 * @param rendererModel
 *            the process renderer model
 */
public AnnotationDrawer(final AnnotationsModel model, final ProcessRendererModel rendererModel) {
	this.model = model;
	this.rendererModel = rendererModel;

	this.displayCache = new HashMap<>();
	this.cachedID = new HashMap<>();

	pane = new JEditorPane("text/html", "");
	pane.setBorder(null);
	pane.setOpaque(false);
	pane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
}
 
Example 9
Source File: DefaultHtmlPrintElement.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Dimension getComputedSize(JRGenericPrintElement element) {
	String htmlContent = (String) element.getParameterValue(HtmlPrintElement.PARAMETER_HTML_CONTENT);
	JEditorPane editorPane = new JEditorPane();
	editorPane.setEditorKitForContentType("text/html", new SynchronousImageLoaderKit());
	editorPane.setContentType("text/html");
	editorPane.setText(htmlContent);
	editorPane.setBorder(null);
	return editorPane.getPreferredSize();
}
 
Example 10
Source File: DefaultHtmlPrintElement.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public JRPrintImage createImageFromComponentElement(JRComponentElement componentElement) throws JRException {
	HtmlComponent html = (HtmlComponent) componentElement.getComponent();
	
	JEditorPane editorPane = new JEditorPane();
	editorPane.setEditorKitForContentType("text/html", new SynchronousImageLoaderKit());
	editorPane.setContentType("text/html");
	
	String htmlContent = "";
	
	if (html.getHtmlContentExpression() != null) {
		htmlContent = JRExpressionUtil.getExpressionText(html.getHtmlContentExpression());
	}
	
	editorPane.setText(htmlContent);
	editorPane.setBorder(null);
	editorPane.setSize(editorPane.getPreferredSize());
	
	JRBasePrintImage printImage = new JRBasePrintImage(componentElement.getDefaultStyleProvider());
	printImage.setX(componentElement.getX());
	printImage.setY(componentElement.getY());
	printImage.setWidth(componentElement.getWidth());
	printImage.setHeight(componentElement.getHeight());
	printImage.setScaleImage(html.getScaleType());
	printImage.setHorizontalImageAlign(html.getHorizontalImageAlign());
	printImage.setVerticalImageAlign(html.getVerticalImageAlign());
	printImage.setStyle(componentElement.getStyle());
	printImage.setMode(componentElement.getModeValue());
	printImage.setBackcolor(componentElement.getBackcolor());
	printImage.setForecolor(componentElement.getForecolor());

	printImage.setRenderer(new AwtComponentRendererImpl(editorPane));
	
	return printImage;
}
 
Example 11
Source File: DefaultHtmlPrintElement.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public JRPrintImage createImageFromElement(JRGenericPrintElement element) {
	String htmlContent = (String) element.getParameterValue(HtmlPrintElement.PARAMETER_HTML_CONTENT);
	String scaleType = (String) element.getParameterValue(HtmlPrintElement.PARAMETER_SCALE_TYPE);
	String horizontalAlignment = (String) element.getParameterValue(HtmlPrintElement.PARAMETER_HORIZONTAL_ALIGN);
	String verticalAlignment = (String) element.getParameterValue(HtmlPrintElement.PARAMETER_VERTICAL_ALIGN);
	
	JEditorPane editorPane = new JEditorPane();
	editorPane.setEditorKitForContentType("text/html", new SynchronousImageLoaderKit());
	editorPane.setContentType("text/html");
	
	editorPane.setText(htmlContent);
	editorPane.setBorder(null);
	editorPane.setSize(editorPane.getPreferredSize());

	JRBasePrintImage printImage = new JRBasePrintImage(element.getDefaultStyleProvider());
	printImage.setX(element.getX());
	printImage.setY(element.getY());
	printImage.setWidth(element.getWidth());
	printImage.setHeight(element.getHeight());
	printImage.setScaleImage(ScaleImageEnum.getByName(scaleType));
	printImage.setHorizontalImageAlign(HorizontalImageAlignEnum.getByName(horizontalAlignment));
	printImage.setVerticalImageAlign(VerticalImageAlignEnum.getByName(verticalAlignment));
	printImage.setStyle(element.getStyle());
	printImage.setMode(element.getModeValue());
	printImage.setBackcolor(element.getBackcolor());
	printImage.setForecolor(element.getForecolor());
	printImage.setRenderer(new AwtComponentRendererImpl(editorPane));

	return printImage;
}
 
Example 12
Source File: HostView.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
@Override
    protected DataViewComponent createComponent() {

        //Data area for master view:
        JEditorPane generalDataArea = new JEditorPane();
        generalDataArea.setText("Below you see the system properties of" +
                " all running apps!");
        generalDataArea.setBorder(BorderFactory.createEmptyBorder(14, 8, 14, 8));

        //Master view:
        DataViewComponent.MasterView masterView =
                new DataViewComponent.MasterView("All System Properties",
                null, generalDataArea);

        //Configuration of master view:
        DataViewComponent.MasterViewConfiguration masterConfiguration =
                new DataViewComponent.MasterViewConfiguration(false);

        //Add the master view and configuration view to the component:
        dvc = new DataViewComponent(masterView, masterConfiguration);

        //Get all the applications deployed to the host:
        Set apps = host.getRepository().getDataSources(Application.class);

        //Get the iterator:
        Iterator it = apps.iterator();

        //Set count to zero:
        int count = 0;

        //Iterate through our applications:
        while (it.hasNext()) {

            //Increase the count:
            count = count + 1;

            //Now we have our application:
            Application app = (Application) it.next();

            //Get the process id:
            String pid = count + ": " + (String.valueOf(app.getPid()));

            //Get the system properties:
            Properties jvmProperties = null;
            jvm = JvmFactory.getJVMFor(app);
            if (jvm.isGetSystemPropertiesSupported()) {
                jvmProperties = jvm.getSystemProperties();
            }

            //Extrapolate the name from the type:
            ApplicationType appType = ApplicationTypeFactory.getApplicationTypeFor(app);
            String appName = appType.getName();

            //Put the first application top left:
            if (count == 1) {

                dvc.addDetailsView(new SystemPropertiesViewSupport(jvmProperties).getDetailsView(app, appName), DataViewComponent.TOP_LEFT);

//            //Put the second application top right:
            } else if (count == 2) {
                dvc.addDetailsView(new SystemPropertiesViewSupport(jvmProperties).getDetailsView(app, appName), DataViewComponent.TOP_RIGHT);

//
//            //Put the third application bottom left:    
            } else if (count == 3) {
                dvc.addDetailsView(new SystemPropertiesViewSupport(jvmProperties).getDetailsView(app, appName), DataViewComponent.BOTTOM_LEFT);

            //Put the fourth application bottom right:        
            } else if (count == 4) {
                dvc.addDetailsView(new SystemPropertiesViewSupport(jvmProperties).getDetailsView(app, appName), DataViewComponent.BOTTOM_RIGHT);

            //Put all other applications bottom right, 
            //which creates tabs within the bottom right tab    
            } else {
                dvc.addDetailsView(new SystemPropertiesViewSupport(jvmProperties).getDetailsView(app, appName), DataViewComponent.BOTTOM_RIGHT);
            }

        }

        return dvc;

    }
 
Example 13
Source File: PropertySheetPanel.java    From orbit-image-analysis with GNU General Public License v3.0 4 votes vote down vote up
private void buildUI() {
  LookAndFeelTweaks.setBorderLayout(this);
  LookAndFeelTweaks.setBorder(this);

  actionPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 2, 0));
  actionPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
  add("North", actionPanel);

  sortButton = new JToggleButton(new ToggleSortingAction());
  sortButton.setUI(new BlueishButtonUI());
  sortButton.setText(null);
  actionPanel.add(sortButton);

  asCategoryButton = new JToggleButton(new ToggleModeAction());
  asCategoryButton.setUI(new BlueishButtonUI());
  asCategoryButton.setText(null);
  actionPanel.add(asCategoryButton);

  descriptionButton = new JToggleButton(new ToggleDescriptionAction());
  descriptionButton.setUI(new BlueishButtonUI());
  descriptionButton.setText(null);
  actionPanel.add(descriptionButton);

  split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
  split.setBorder(null);
  split.setResizeWeight(1.0);
  split.setContinuousLayout(true);
  add("Center", split);
  
  tableScroll = new JScrollPane();
  split.setTopComponent(tableScroll);

  descriptionPanel = new JEditorPane("text/html", "<html>");
  descriptionPanel.setBorder(BorderFactory.createEmptyBorder());
  descriptionPanel.setEditable(false);
  descriptionPanel.setBackground(UIManager.getColor("Panel.background"));
  LookAndFeelTweaks.htmlize(descriptionPanel);

  selectionListener = new SelectionListener();

  descriptionScrollPane = new JScrollPane(descriptionPanel);
  descriptionScrollPane.setBorder(LookAndFeelTweaks.addMargin(BorderFactory
    .createLineBorder(UIManager.getColor("controlDkShadow"))));
  descriptionScrollPane.getViewport().setBackground(
    descriptionPanel.getBackground());
  descriptionScrollPane.setMinimumSize(new Dimension(50, 50));
  split.setBottomComponent(descriptionScrollPane);
  
  // by default description is not visible, toolbar is visible.
  setDescriptionVisible(false);
  setToolBarVisible(true);
}
 
Example 14
Source File: UsageDialog.java    From gpx-animator with Apache License 2.0 4 votes vote down vote up
/**
 * Create the dialog.
 */
public UsageDialog() {
    final ResourceBundle resourceBundle = Preferences.getResourceBundle();

    setTitle(resourceBundle.getString("ui.dialog.usage.title"));
    setBounds(100, 100, 657, 535);
    getContentPane().setLayout(new BorderLayout());
    final JPanel contentPanel = new JPanel();
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.LINE_AXIS));

    final JEditorPane dtrpngpxNavigator = new JEditorPane();
    dtrpngpxNavigator.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    dtrpngpxNavigator.setEditable(false);
    dtrpngpxNavigator.setContentType("text/html");

    final StringWriter sw = new StringWriter();
    final PrintWriter pw = new PrintWriter(sw);
    pw.println("<dl>"); //NON-NLS
    Help.printHelp((option, argument, track, defaultValue) -> {
        // TODO html escape
        pw.print("<dt><b>--"); //NON-NLS
        pw.print(option.getName());
        if (argument != null) {
            pw.print(" &lt;"); //NON-NLS
            pw.print(argument);
            pw.print("&gt;"); //NON-NLS
        }
        pw.println("</b></dt>"); //NON-NLS
        pw.print("<dd>"); //NON-NLS
        pw.print(option.getHelp());
        if (track) {
            pw.print("; ".concat(resourceBundle.getString("ui.dialog.usage.multiple")));
        }
        if (defaultValue != null) {
            pw.print("; ".concat(resourceBundle.getString("ui.dialog.usage.default")).concat(" "));
            pw.print(defaultValue);
        }
        pw.println("</dd>"); //NON-NLS
    });
    pw.println("</dl>"); //NON-NLS
    pw.close();

    dtrpngpxNavigator.setText(resourceBundle.getString("ui.dialog.usage.cliparams").concat(sw.toString()));

    dtrpngpxNavigator.setCaretPosition(0);

    final JScrollPane scrollPane = new JScrollPane(dtrpngpxNavigator);
    contentPanel.add(scrollPane);

    final JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
    getContentPane().add(buttonPane, BorderLayout.PAGE_END);

    final JButton okButton = new JButton(resourceBundle.getString("ui.dialog.usage.button.ok"));
    okButton.addActionListener(e -> UsageDialog.this.dispose());
    buttonPane.add(okButton);
    getRootPane().setDefaultButton(okButton);
}
 
Example 15
Source File: JdotxtPreferencesDialog.java    From jdotxt with GNU General Public License v3.0 4 votes vote down vote up
private JPanel getHelpPanel() {
	JPanel panel = new JPanel();
	panel.setLayout(new BorderLayout());
	panel.setBackground(Color.WHITE);
	panel.setOpaque(true);

	JLabel labelIcon = new JLabel(new ImageIcon(JdotxtGUI.icon.getImage().getScaledInstance(64, 64, java.awt.Image.SCALE_SMOOTH)));
	labelIcon.setVerticalAlignment(SwingConstants.TOP);
	panel.add(labelIcon, BorderLayout.WEST);
	labelIcon.setPreferredSize(new Dimension(100, 100));

	JPanel panelInfo = new JPanel();
	panel.add(panelInfo, BorderLayout.CENTER);
	panelInfo.setLayout(new BoxLayout(panelInfo, BoxLayout.Y_AXIS));
	panelInfo.add(Box.createVerticalStrut(10));
	panelInfo.setBackground(Color.WHITE);
	panelInfo.setOpaque(true);

	JLabel labelTitle = new JLabel(JdotxtGUI.lang.getWord("jdotxt") + " (Version " + Jdotxt.VERSION + ")");
	labelTitle.setFont(JdotxtGUI.fontB.deriveFont(16f));
	panelInfo.add(labelTitle);

	panelInfo.add(Box.createVerticalStrut(20));

	JEditorPane textInfo = new JEditorPane();
	textInfo.setContentType("text/html");
	textInfo.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
	textInfo.setFont(JdotxtGUI.fontR);
	textInfo.setText(JdotxtGUI.lang.getWord("Text_help"));
	textInfo.setEditable(false);
	textInfo.setFocusable(false);
	textInfo.setAlignmentX(Component.LEFT_ALIGNMENT);
	textInfo.setBorder(BorderFactory.createEmptyBorder());
	textInfo.setMaximumSize(textInfo.getPreferredSize());

	panelInfo.add(textInfo);

	panelInfo.add(Box.createVerticalStrut(20));

	JLabel labelShortcuts = new JLabel(JdotxtGUI.lang.getWord("Shortcuts"));
	labelShortcuts.setFont(JdotxtGUI.fontB.deriveFont(14f));
	panelInfo.add(labelShortcuts);

	panelInfo.add(Box.createVerticalStrut(20));

	JEditorPane textShortcuts = new JEditorPane();
	textShortcuts.setContentType("text/html");
	textShortcuts.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
	textShortcuts.setFont(JdotxtGUI.fontR);
	textShortcuts.setText(JdotxtGUI.lang.getWord("Text_shortcuts"));
	textShortcuts.setEditable(false);
	textShortcuts.setFocusable(false);
	textShortcuts.setAlignmentX(Component.LEFT_ALIGNMENT);
	textShortcuts.setBorder(BorderFactory.createEmptyBorder());
	textShortcuts.setMaximumSize(textShortcuts.getPreferredSize());

	panelInfo.add(textShortcuts);
	panelInfo.add(Box.createVerticalGlue());

	panel.revalidate();
	return panel;
}
 
Example 16
Source File: MainWindow.java    From dummydroid with Apache License 2.0 4 votes vote down vote up
public MainWindow() {
	super("Dummy Droid");
	setDefaultCloseOperation(EXIT_ON_CLOSE);
	JMenuBar mbar = new JMenuBar();
	JMenu fileMenu = new JMenu(new FileMenuAction());
	fileMenu.add(new JMenuItem(new QuitAction()));
	mbar.add(fileMenu);
	setJMenuBar(mbar);

	FormData formData = new FormData();

	JEditorPane description = new HypertextPane("");
	description.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
	description.addHyperlinkListener(new BrowseUtil());
	JPanel formContainer = new JPanel();
	formContainer.setLayout(new CardLayout());

	NavigateAction forward = new NavigateAction(description, formContainer, NavigateAction.FORWARD,
			formData);
	NavigateAction backward = new NavigateAction(description, formContainer, NavigateAction.BACK,
			formData);

	formContainer.add(new LoadForm(forward, backward), LoadForm.class.getName());
	formContainer.add(new HardwareForm(forward, backward), HardwareForm.class.getName());
	formContainer.add(new SoftwareForm(forward, backward), SoftwareForm.class.getName());
	formContainer.add(new MiscForm(forward, backward), MiscForm.class.getName());
	formContainer.add(new NativeForm(forward, backward), NativeForm.class.getName());
	formContainer.add(new SharedlibForm(forward, backward), SharedlibForm.class.getName());
	formContainer.add(new FeaturesForm(forward, backward), FeaturesForm.class.getName());
	formContainer.add(new LocalesForm(forward, backward), LocalesForm.class.getName());
	formContainer.add(new CredentialsForm(forward,backward),CredentialsForm.class.getName());
	formContainer.add(new CheckinForm(forward, backward), CheckinForm.class.getName());

	JButton next = new JButton(forward);
	JButton previous = new JButton(backward);
	JLabel content = new JLabel("");
	JPanel buttonBar = new JPanel(new FlowLayout(FlowLayout.RIGHT));
	buttonBar.add(previous);
	buttonBar.add(next);
	content.setLayout(new BorderLayout());
	JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
			new JScrollPane(description), formContainer);
	splitPane.setResizeWeight(1);
	content.add(splitPane, BorderLayout.CENTER);
	content.add(buttonBar, BorderLayout.SOUTH);
	setContentPane(content);
	forward.toScreen();
}
 
Example 17
Source File: YogaCombinationsView.java    From Astrosoft with GNU General Public License v2.0 4 votes vote down vote up
private Component createYogaDetailPane(){
	
	//JPanel yogaDetail= new JPanel();
	
	editorPane = new JEditorPane();
	
	editorPane.setContentType("text/html");
	editorPane.setEditable(false);
			
	yogaChanged((YogaResults.Result)yogaList.getSelectedValue()); 
	
	editorPane.setBorder(BorderFactory.createEtchedBorder());
	
	return editorPane;
	
	
}
 
Example 18
Source File: PropertySheetPanel.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
private void buildUI() {
  LookAndFeelTweaks.setBorderLayout(this);
  LookAndFeelTweaks.setBorder(this);

  actionPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 2, 0));
  actionPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
  actionPanel.setOpaque(false);
  add("North", actionPanel);

  sortButton = new JToggleButton(new ToggleSortingAction());
  sortButton.setUI(new BlueishButtonUI());
  sortButton.setText(null);
  sortButton.setOpaque(false);
  actionPanel.add(sortButton);

  asCategoryButton = new JToggleButton(new ToggleModeAction());
  asCategoryButton.setUI(new BlueishButtonUI());
  asCategoryButton.setText(null);
  asCategoryButton.setOpaque(false);
  actionPanel.add(asCategoryButton);

  descriptionButton = new JToggleButton(new ToggleDescriptionAction());
  descriptionButton.setUI(new BlueishButtonUI());
  descriptionButton.setText(null);
  descriptionButton.setOpaque(false);
  actionPanel.add(descriptionButton);

  split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
  split.setBorder(null);
  split.setResizeWeight(1.0);
  split.setContinuousLayout(true);
  add("Center", split);
  
  tableScroll = new JScrollPane();
  tableScroll.setBorder(BorderFactory.createEmptyBorder());
  split.setTopComponent(tableScroll);

  descriptionPanel = new JEditorPane("text/html", "<html>");
  descriptionPanel.setBorder(BorderFactory.createEmptyBorder());
  descriptionPanel.setEditable(false);
  descriptionPanel.setBackground(UIManager.getColor("Panel.background"));
  LookAndFeelTweaks.htmlize(descriptionPanel);

  selectionListener = new SelectionListener();

  descriptionScrollPane = new JScrollPane(descriptionPanel);
  descriptionScrollPane.setBorder(LookAndFeelTweaks.addMargin(BorderFactory
    .createLineBorder(UIManager.getColor("controlDkShadow"))));
  descriptionScrollPane.getViewport().setBackground(
    descriptionPanel.getBackground());
  descriptionScrollPane.setMinimumSize(new Dimension(50, 50));
  split.setBottomComponent(descriptionScrollPane);
  
  // by default description is not visible, toolbar is visible.
  setDescriptionVisible(false);
  setToolBarVisible(true);
}
 
Example 19
Source File: ValueRetroTab.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public ValueRetroTab(final Program program) {
	super(program, TabsValues.get().oldTitle(), Images.TOOL_VALUES.getIcon(), true);

	ListenerClass listener = new ListenerClass();

	backgroundHexColor = Integer.toHexString(jPanel.getBackground().getRGB());
	backgroundHexColor = backgroundHexColor.substring(2, backgroundHexColor.length());

	gridHexColor = Integer.toHexString(jPanel.getBackground().darker().getRGB());
	gridHexColor = gridHexColor.substring(2, gridHexColor.length());

	jCharacters = new JComboBox<String>();
	jCharacters.setActionCommand(ValueRetroAction.OWNER_SELECTED.name());
	jCharacters.addActionListener(listener);

	jCharacter = new JEditorPane("text/html", "<html>");
	jCharacter.setEditable(false);
	jCharacter.setOpaque(false);
	jCharacter.setBorder(null);
	JScrollPane jCharacterScroll = new JScrollPane(jCharacter);
	jCharacterScroll.setBorder(null);

	jCorporations = new JComboBox<String>();
	jCorporations.setActionCommand(ValueRetroAction.CORP_SELECTED.name());
	jCorporations.addActionListener(listener);

	jCorporation = new JEditorPane("text/html", "<html>");
	jCorporation.setEditable(false);
	jCorporation.setOpaque(false);
	jCorporation.setBorder(null);
	JScrollPane jCorporationScroll = new JScrollPane(jCorporation);
	jCorporationScroll.setBorder(null);

	JLabel jTotalLabel = new JLabel(" " + TabsValues.get().grandTotal());
	jTotalLabel.setBackground(new Color(34, 34, 34));
	jTotalLabel.setForeground(Color.WHITE);
	Font font = jTotalLabel.getFont();
	jTotalLabel.setFont(new Font(font.getName(), Font.BOLD, font.getSize() + 2));
	jTotalLabel.setOpaque(true);

	jTotal = new JEditorPane("text/html", "<html>");
	jTotal.setEditable(false);
	jTotal.setOpaque(false);
	jTotal.setBorder(null);
	JScrollPane jTotalScroll = new JScrollPane(jTotal);
	jTotalScroll.setBorder(null);

	layout.setHorizontalGroup(
		layout.createSequentialGroup()
			.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
				.addGroup(layout.createSequentialGroup()
					.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
						.addComponent(jTotalScroll, 10, 10, Short.MAX_VALUE)
						.addComponent(jTotalLabel, 10, 10, Short.MAX_VALUE)
					)
					.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
						.addComponent(jCharacterScroll, 10, 10, Short.MAX_VALUE)
						.addGroup(layout.createSequentialGroup()
							.addGap(3)
							.addComponent(jCharacters, 10, 10, Short.MAX_VALUE)
							.addGap(3)
						)
					)
					.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
						.addComponent(jCorporationScroll, 10, 10, Short.MAX_VALUE)
						.addGroup(layout.createSequentialGroup()
							.addGap(3)
							.addComponent(jCorporations, 10, 10, Short.MAX_VALUE)
							.addGap(3)
						)
					)
				)
			)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				.addComponent(jTotalLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jCharacters, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jCorporations, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			)
			.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				.addComponent(jTotalScroll, 0, 0, Short.MAX_VALUE)
				.addComponent(jCharacterScroll, 0, 0, Short.MAX_VALUE)
				.addComponent(jCorporationScroll, 0, 0, Short.MAX_VALUE)
			)
	);
}
 
Example 20
Source File: ToolTipSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private JEditorPane createHtmlTextToolTip() {
    class HtmlTextToolTip extends JEditorPane {
        public @Override void setSize(int width, int height) {
            Dimension prefSize = getPreferredSize();
            if (width >= prefSize.width) {
                width = prefSize.width;
            } else { // smaller available width
                super.setSize(width, 10000); // the height is unimportant
                prefSize = getPreferredSize(); // re-read new pref width
            }
            if (height >= prefSize.height) { // enough height
                height = prefSize.height;
            }
            super.setSize(width, height);
        }
        @Override
        public void setKeymap(Keymap map) {
            //#181722: keymaps are shared among components with the same UI
            //a default action will be set to the Keymap of this component below,
            //so it is necessary to use a Keymap that is not shared with other components
            super.setKeymap(addKeymap(null, map));
        }
    }

    JEditorPane tt = new HtmlTextToolTip();
    /* See NETBEANS-403. It still appears possible to use Escape to close the popup when the
    focus is in the editor. */
    tt.putClientProperty(SUPPRESS_POPUP_KEYBOARD_FORWARDING_CLIENT_PROPERTY_KEY, true);

    // setup tooltip keybindings
    filterBindings(tt.getActionMap());
    tt.getActionMap().put(HIDE_ACTION.getValue(Action.NAME), HIDE_ACTION);
    tt.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), HIDE_ACTION.getValue(Action.NAME));
    tt.getKeymap().setDefaultAction(NO_ACTION);

    Font font = UIManager.getFont(UI_PREFIX + ".font"); // NOI18N
    Color backColor = UIManager.getColor(UI_PREFIX + ".background"); // NOI18N
    Color foreColor = UIManager.getColor(UI_PREFIX + ".foreground"); // NOI18N

    if (font != null) {
        tt.setFont(font);
    }
    if (foreColor != null) {
        tt.setForeground(foreColor);
    }
    if (backColor != null) {
        tt.setBackground(backColor);
    }

    tt.setOpaque(true);
    tt.setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createLineBorder(tt.getForeground()),
        BorderFactory.createEmptyBorder(0, 3, 0, 3)
    ));
    tt.setContentType("text/html"); //NOI18N

    return tt;
}