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

The following examples show how to use javax.swing.JEditorPane#setOpaque() . 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: AboutDialog.java    From jeveassets with GNU General Public License v2.0 6 votes vote down vote up
private JEditorPane createEditorPane(final boolean addBorder, final String text) {
	JEditorPane jEditorPane = new JEditorPane("text/html",
			"<html><div style=\"font-family: Arial, Helvetica, sans-serif; font-size: 11pt; white-space: nowrap;\">"
			+ text
			+ "</div>"
			);
	jEditorPane.setEditable(false);
	jEditorPane.setFocusable(false);
	jEditorPane.setOpaque(false);
	jEditorPane.setFont(jPanel.getFont());
	jEditorPane.addHyperlinkListener(DesktopUtil.getHyperlinkListener(getDialog()));
	if (addBorder) {
		jEditorPane.setBorder(BorderFactory.createEmptyBorder(11, 11, 11, 11));
	}
	return jEditorPane;
}
 
Example 2
Source File: HTMLDialogBox.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Turns HTML into a clickable dialog text component.
 * @param html String of valid HTML.
 * @return a JTextComponent with the HTML inside.
 */
public JTextComponent createHyperlinkListenableJEditorPane(String html) {
	final JEditorPane bottomText = new JEditorPane();
	bottomText.setContentType("text/html");
	bottomText.setEditable(false);
	bottomText.setText(html);
	bottomText.setOpaque(false);
	final HyperlinkListener hyperlinkListener = new HyperlinkListener() {
		public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
			if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
				if (Desktop.isDesktopSupported()) {
					try {
						Desktop.getDesktop().browse(hyperlinkEvent.getURL().toURI());
					} catch (IOException | URISyntaxException exception) {
						// Auto-generated catch block
						exception.printStackTrace();
					}
				}

			}
		}
	};
	bottomText.addHyperlinkListener(hyperlinkListener);
	return bottomText;
}
 
Example 3
Source File: DocumentationUI.java    From whyline with MIT License 5 votes vote down vote up
public DocumentationUI(WhylineUI whylineUI) {
	
	super("documentation", whylineUI);

	doc = new JEditorPane("text/html", "");
	// This makes the pane respect the background, foreground, font.
	doc.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
	doc.setBackground(UI.getControlBackColor());
	doc.setForeground(UI.getControlTextColor());
	doc.setOpaque(true);
	doc.setFont(UI.getMediumFont());
	doc.setEditable(false);
	
	WhylineScrollPane pane = new WhylineScrollPane(doc);
	pane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
	pane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
	pane.setBorder(new WhylineControlBorder());
	
	setContent(pane);

	setMinimumSize(new Dimension(UI.getDefaultInfoPaneWidth(whylineUI), 0));
	
	doc.addHyperlinkListener(new HyperlinkListener() {
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
				Util.openURL(e.getURL().toString());
		}
	});
	
}
 
Example 4
Source File: Main.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
public Main() {
  setLayout(new BorderLayout());

  JTabbedPane tabs = new JTabbedPane();
  add("Center", tabs);

  addDemo(tabs, "JButtonBar", "ButtonBarMain");
  addDemo(tabs, "JDirectoryChooser", "ChooseDirectory");
  addDemo(tabs, "JFontChooser", "ChooseFont");
  addDemo(tabs, "JOutlookBar", "OutlookBarMain");
  addDemo(tabs, "JTaskPane", "TaskPaneMain");
  addDemo(tabs, "PropertySheet", "PropertySheetMain");
  addDemo(tabs, "JTipOfTheDay", "TOTDTest");
  
  try {
    JEditorPane pane = new JEditorPane("text/html", "<html>") {
      protected void paintComponent(java.awt.Graphics g) {
        Graphics2D g2d = (Graphics2D)g;
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
          RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        super.paintComponent(g);
      }
    };
    pane.setPage(Main.class.getResource("demo.html"));
    pane.setBackground(Color.white);
    pane.setEditable(false);
    pane.setOpaque(true);
    add("South", pane);
  } catch (Exception e) {
  }
}
 
Example 5
Source File: MultiSizeIssue.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
public static void chooseBandsWithSameSize() {
    String title = Dialogs.getDialogTitle("Choose bands with same size.");
    int optionType = JOptionPane.OK_CANCEL_OPTION;
    int messageType = JOptionPane.INFORMATION_MESSAGE;

    final StringBuilder msgTextBuilder = new StringBuilder("The functionality you have chosen is not supported for bands of different sizes.<br/>");

    JPanel panel = new JPanel(new BorderLayout(4, 4));
    final JEditorPane textPane = new JEditorPane("text/html", msgTextBuilder.toString());
    setFont(textPane);
    textPane.setEditable(false);
    textPane.setOpaque(false);
    textPane.addHyperlinkListener(e -> {
        if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
            try {
                Desktop.getDesktop().browse(e.getURL().toURI());
            } catch (IOException | URISyntaxException e1) {
                Dialogs.showWarning("Could not open URL: " + e.getDescription());
            }
        }
    });
    panel.add(textPane, BorderLayout.CENTER);
    final JComboBox<Object> resamplerBox = new JComboBox<>();

    NotifyDescriptor d = new NotifyDescriptor(panel, title, optionType, messageType, null, null);
    DialogDisplayer.getDefault().notify(d);
}
 
Example 6
Source File: DemoPanel.java    From littleluck with Apache License 2.0 5 votes vote down vote up
private static JComponent createDescriptionArea(URL descriptionURL) {
    JEditorPane descriptionPane = new HTMLPanel();
    descriptionPane.setEditable(false);
    descriptionPane.setMargin(margin);
    descriptionPane.setOpaque(true);
    try {
        descriptionPane.setPage(descriptionURL);
    } catch (IOException e) {
        System.err.println("couldn't load description from URL:" + descriptionURL);
    }
    return descriptionPane;
}
 
Example 7
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 8
Source File: MultiSizeIssue.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
public static void warningMaskForBandsWithDifferentSize() {
        String title = Dialogs.getDialogTitle("Mask deleted due to bands with different sizes.");
        int optionType = JOptionPane.OK_OPTION;
        int messageType = JOptionPane.INFORMATION_MESSAGE;

        final StringBuilder msgTextBuilder = new StringBuilder("The current mask will be deleted as you chose bands with different sizes.<br/>");

        JPanel panel = new JPanel(new BorderLayout(4, 4));
        final JEditorPane textPane = new JEditorPane("text/html", msgTextBuilder.toString());
        setFont(textPane);
        textPane.setEditable(false);
        textPane.setOpaque(false);
//        textPane.addHyperlinkListener(e -> {
//            if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
//                try {
//                    Desktop.getDesktop().browse(e.getURL().toURI());
//                } catch (IOException | URISyntaxException e1) {
//                    Dialogs.showWarning("Could not open URL: " + e.getDescription());
//                }
//            }
//        });
        panel.add(textPane, BorderLayout.CENTER);
        final JComboBox<Object> resamplerBox = new JComboBox<>();

        Object[] options = {"CLOSE"};
        NotifyDescriptor d = new NotifyDescriptor(panel, title, optionType, messageType, options, options[0]);
        DialogDisplayer.getDefault().notify(d);
    }
 
Example 9
Source File: AccountImportDialog.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
public DonePanel() {
	jResult = new JLabel();
	jResult.setFont(new Font(this.getFont().getName(), Font.BOLD, this.getFont().getSize()));

	jHelp = new JEditorPane("text/html", "");
	//jHelp.setLineWrap(true);
	//jHelp.setWrapStyleWord(true);
	jHelp.addHyperlinkListener(DesktopUtil.getHyperlinkListener(getDialog()));
	jHelp.setFont(this.getFont());
	jHelp.setEditable(false);
	jHelp.setOpaque(false);
	jHelp.setFocusable(false);
	jHelp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

	JScrollPane jScroll = new JScrollPane(jHelp, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	jScroll.setBorder(BorderFactory.createLineBorder(this.getBackground().darker(), 1));

	cardLayout.setHorizontalGroup(
		cardLayout.createParallelGroup()
			.addGroup(cardLayout.createSequentialGroup()
				.addGap(5)
				.addComponent(jResult)
			)
			.addComponent(jScroll, 400, 400, 400)
	);
	cardLayout.setVerticalGroup(
		cardLayout.createSequentialGroup()
			.addComponent(jResult, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addComponent(jScroll, 98, 98, 98)
	);
}
 
Example 10
Source File: mxCellEditor.java    From blog-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
public mxCellEditor(mxGraphComponent graphComponent)
{
	this.graphComponent = graphComponent;

	// Creates the plain text editor
	textArea = new JTextArea();
	textArea.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
	textArea.setOpaque(false);

	// Creates the HTML editor
	editorPane = new JEditorPane();
	editorPane.setOpaque(false);
	editorPane.setBackground(new Color(0,0,0,0));
	editorPane.setContentType("text/html");

	// Workaround for inserted linefeeds in HTML markup with
	// lines that are longar than 80 chars
	editorPane.setEditorKit(new NoLinefeedHtmlEditorKit());

	// Creates the scollpane that contains the editor
	// FIXME: Cursor not visible when scrolling
	scrollPane = new JScrollPane();
	scrollPane.setBorder(BorderFactory.createEmptyBorder());
	scrollPane.getViewport().setOpaque(false);
	scrollPane.setVisible(false);
	scrollPane.setOpaque(false);

	// Installs custom actions
	editorPane.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
	textArea.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
	editorPane.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
	textArea.getActionMap().put(SUBMIT_TEXT, textSubmitAction);

	// Remembers the action map key for the enter keystroke
	editorEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
	textEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
}
 
Example 11
Source File: CodeChickenCorePlugin.java    From CodeChickenCore with MIT License 5 votes vote down vote up
public static void versionCheck(String reqVersion, String mod) {
    String mcVersion = (String) FMLInjectionData.data()[4];
    if (!VersionParser.parseRange(reqVersion).containsVersion(new DefaultArtifactVersion(mcVersion))) {
        String err = "This version of " + mod + " does not support minecraft version " + mcVersion;
        logger.error(err);

        JEditorPane ep = new JEditorPane("text/html",
                "<html>" +
                        err +
                        "<br>Remove it from your coremods folder and check <a href=\"http://www.minecraftforum.net/topic/909223-\">here</a> for updates" +
                        "</html>");

        ep.setEditable(false);
        ep.setOpaque(false);
        ep.addHyperlinkListener(new HyperlinkListener()
        {
            @Override
            public void hyperlinkUpdate(HyperlinkEvent event) {
                try {
                    if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
                        Desktop.getDesktop().browse(event.getURL().toURI());
                } catch (Exception ignored) {}
            }
        });

        JOptionPane.showMessageDialog(null, ep, "Fatal error", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }
}
 
Example 12
Source File: FileLock.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
private static JEditorPane getMessage(File file) {
	JLabel jLabel = new JLabel();
	JEditorPane jEditorPane = new JEditorPane("text/html", "");
	jEditorPane.setEditable(false);
	jEditorPane.setFocusable(false);
	jEditorPane.setOpaque(false);
	jEditorPane.setText("<html><body style=\"font-family: " + jLabel.getFont().getName() + "; font-size: " + jLabel.getFont().getSize() + "pt\">"
			+ General.get().fileLockMsg(file.getName())
			+ "</body></html>");
	jEditorPane.addHyperlinkListener(DesktopUtil.getHyperlinkListener(null));
	return jEditorPane;
}
 
Example 13
Source File: DemoPanel.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
private static JComponent createDescriptionArea(URL descriptionURL) {
    JEditorPane descriptionPane = new HTMLPanel();
    descriptionPane.setEditable(false);
    descriptionPane.setMargin(margin);
    descriptionPane.setOpaque(true);
    try {
        descriptionPane.setPage(descriptionURL);
    } catch (IOException e) {
        System.err.println("couldn't load description from URL:" + descriptionURL);
    }
    return descriptionPane;
}
 
Example 14
Source File: AccountImportDialog.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public ImportPanel() {
	JEditorPane jHelp = new JEditorPane("text/html", "<html><body style=\"font-family: " + getFont().getName() + "; font-size: " + getFont().getSize() + "pt\">"
		+ DialoguesAccount.get().shareImportHelp() + "</body></html>");
	((HTMLDocument) jHelp.getDocument()).getStyleSheet().addRule("body { font-family: " + getFont().getFamily() + "; " + "font-size: " + this.getFont().getSize() + "pt; }");
	jHelp.setFont(getFont());
	jHelp.setEditable(false);
	jHelp.setFocusable(false);
	jHelp.setOpaque(false);

	jImportClipboard = new JButton(DialoguesAccount.get().shareImportClipboard() , Images.EDIT_PASTE.getIcon());
	jImportClipboard.setActionCommand(AccountImportAction.SHARE_FROM_CLIPBOARD.name());
	jImportClipboard.addActionListener(listener);

	jImportFile= new JButton(DialoguesAccount.get().shareImportFile(), Images.FILTER_LOAD.getIcon());
	jImportFile.setActionCommand(AccountImportAction.SHARE_FROM_FILE.name());
	jImportFile.addActionListener(listener);

	jImport = new JTextArea();
	jImport.setFont(getFont());
	jImport.setEditable(true);
	jImport.setFocusable(true);
	jImport.setOpaque(true);
	jImport.setLineWrap(true);
	jImport.setWrapStyleWord(false);

	JScrollPane jScroll = new JScrollPane(jImport, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	jScroll.setBorder(BorderFactory.createLineBorder(this.getBackground().darker(), 1));

	cardLayout.setHorizontalGroup(
		cardLayout.createParallelGroup()
			.addComponent(jHelp)
			.addGroup(cardLayout.createSequentialGroup()
				.addComponent(jScroll)
				.addGroup(cardLayout.createParallelGroup()
					.addComponent(jImportClipboard, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
					.addComponent(jImportFile, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
				)
			)
	);
	cardLayout.setVerticalGroup(
		cardLayout.createSequentialGroup()
			.addComponent(jHelp)
			.addGroup(cardLayout.createParallelGroup()
				.addComponent(jScroll)
				.addGroup(cardLayout.createSequentialGroup()
					.addComponent(jImportClipboard, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
					.addComponent(jImportFile, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				)
			)
	);
}
 
Example 15
Source File: MultiSizeIssue.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
public static Product maybeResample(Product product) {
    String title = Dialogs.getDialogTitle("Resampling Required");
    final List<Resampler> availableResamplers = getAvailableResamplers(product);
    int optionType;
    int messageType;
    final StringBuilder msgTextBuilder = new StringBuilder("The functionality you have chosen is not supported for products with bands of different sizes.<br/>");
    if (availableResamplers.isEmpty()) {
        optionType = JOptionPane.OK_CANCEL_OPTION;
        messageType = JOptionPane.INFORMATION_MESSAGE;
    } else if (availableResamplers.size() == 1) {
        msgTextBuilder.append("You can use the ").append(availableResamplers.get(0).getName()).
                append(" to resample this product so that all bands have the same size, <br/>" +
                               "which will enable you to use this feature.<br/>" +
                               "Do you want to resample the product now?");
        optionType = JOptionPane.YES_NO_OPTION;
        messageType = JOptionPane.QUESTION_MESSAGE;
    } else {
        msgTextBuilder.append("You can use one of these resamplers to resample this product so that all bands have the same size, <br/>" +
                                      "which will enable you to use this feature.<br/>" +
                                      "Do you want to resample the product now?");
        optionType = JOptionPane.YES_NO_OPTION;
        messageType = JOptionPane.QUESTION_MESSAGE;
    }
    msgTextBuilder.append("<br/>" +
                                  "<br/>" +
                                  "More info about this issue and its status can be found in the " +
                                  "<a href=\"https://senbox.atlassian.net/browse/SNAP-1\">SNAP Issue Tracker</a>."
    );
    JPanel panel = new JPanel(new BorderLayout(4, 4));
    final JEditorPane textPane = new JEditorPane("text/html", msgTextBuilder.toString());
    setFont(textPane);
    textPane.setEditable(false);
    textPane.setOpaque(false);
    textPane.addHyperlinkListener(e -> {
        if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
            try {
                Desktop.getDesktop().browse(e.getURL().toURI());
            } catch (IOException | URISyntaxException e1) {
                Dialogs.showWarning("Could not open URL: " + e.getDescription());
            }
        }
    });
    panel.add(textPane, BorderLayout.CENTER);
    final JComboBox<Object> resamplerBox = new JComboBox<>();
    if (availableResamplers.size() > 1) {
        String[] resamplerNames = new String[availableResamplers.size()];
        for (int i = 0; i < availableResamplers.size(); i++) {
            resamplerNames[i] = availableResamplers.get(i).getName();
            resamplerBox.addItem(resamplerNames[i]);
        }
        panel.add(resamplerBox, BorderLayout.SOUTH);
    }
    NotifyDescriptor d = new NotifyDescriptor(panel, title, optionType, messageType, null, null);
    DialogDisplayer.getDefault().notify(d);
    if (d.getValue() == NotifyDescriptor.YES_OPTION) {
        Resampler selectedResampler;
        if (availableResamplers.size() == 1) {
            selectedResampler = availableResamplers.get(0);
        } else {
            selectedResampler = availableResamplers.get(resamplerBox.getSelectedIndex());
        }
        return selectedResampler.resample(product);
    }
    return null;
}
 
Example 16
Source File: AboutDialog.java    From RemoteSupportTool with Apache License 2.0 4 votes vote down vote up
public void createAndShow() {
    // init dialog
    setTitle(settings.getString("i18n.aboutTitle"));
    setPreferredSize(new Dimension(600, 350));
    setMinimumSize(new Dimension(400, 300));
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            setVisible(false);
            dispose();
        }
    });

    // sidebar
    SidebarPanel sidebarPanel = new SidebarPanel(
            ImageUtils.loadImage(this.sidebarImageUrl),
            ImageUtils.loadImage(brandingImageUrl)
    );

    // about section
    JEditorPane aboutPane = new JEditorPane();
    aboutPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
    aboutPane.setEditable(false);
    aboutPane.setOpaque(true);
    aboutPane.setBackground(Color.WHITE);
    aboutPane.setContentType("text/html");
    aboutPane.setText(replaceVariables(getAboutText()));
    aboutPane.setCaretPosition(0);
    aboutPane.addHyperlinkListener(e -> {
        //LOGGER.debug("hyperlink / " + e.getEventType() + " / " + e.getURL());
        if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType()))
            AppUtils.browse(e.getURL());
    });
    JScrollPane aboutScrollPane = new JScrollPane(aboutPane);
    aboutScrollPane.setOpaque(false);
    aboutScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));

    // close button
    JButton closeButton = new JButton();
    closeButton.setText(settings.getString("i18n.close"));
    closeButton.addActionListener(e -> {
        setVisible(false);
        dispose();
    });

    // website button
    JButton websiteButton = new JButton();
    websiteButton.setText(settings.getString("i18n.website"));
    websiteButton.addActionListener(e -> AppUtils.browse(this.settings.getString("website.author")));

    // github button
    JButton githubButton = new JButton();
    githubButton.setText(settings.getString("i18n.source"));
    githubButton.addActionListener(e -> AppUtils.browse(this.settings.getString("website.source")));

    // build bottom bar
    JPanel buttonBarLeft = new JPanel(new FlowLayout());
    buttonBarLeft.setOpaque(false);
    buttonBarLeft.add(websiteButton);
    buttonBarLeft.add(githubButton);

    JPanel buttonBarRight = new JPanel(new FlowLayout());
    buttonBarRight.setOpaque(false);
    buttonBarRight.add(closeButton);

    JPanel bottomBar = new JPanel(new BorderLayout());
    bottomBar.setOpaque(false);
    bottomBar.add(buttonBarLeft, BorderLayout.WEST);
    bottomBar.add(buttonBarRight, BorderLayout.EAST);

    // add components to the dialog
    getRootPane().setOpaque(true);
    getRootPane().setBackground(Color.WHITE);
    getRootPane().setLayout(new BorderLayout());
    getRootPane().add(sidebarPanel, BorderLayout.WEST);
    getRootPane().add(aboutScrollPane, BorderLayout.CENTER);
    getRootPane().add(bottomBar, BorderLayout.SOUTH);

    // show dialog
    pack();
    setLocationRelativeTo(this.getOwner());
    setVisible(true);
}
 
Example 17
Source File: MTGStoryListPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 4 votes vote down vote up
public MTGStoryListPanel(MTGStory value) {
	setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
	GridBagLayout gridBagLayout = new GridBagLayout();
	gridBagLayout.columnWidths = new int[] { 91, 55, 73, 0 };
	gridBagLayout.rowHeights = new int[] { 14, 0, 0, 0 };
	gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
	gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE };
	setLayout(gridBagLayout);

	lblicon = new JLabel();
	
	if(value.getIcon()!=null)
		lblicon.setIcon(new ImageIcon(value.getIcon()));
	
	GridBagConstraints gbclblicon = new GridBagConstraints();
	gbclblicon.gridheight = 3;
	gbclblicon.insets = new Insets(0, 0, 0, 5);
	gbclblicon.gridx = 0;
	gbclblicon.gridy = 0;
	add(lblicon, gbclblicon);

	JLabel lblTitle = new JLabel(value.getTitle());
	lblTitle.setFont(MTGControler.getInstance().getFont().deriveFont(Font.BOLD, 14));
	GridBagConstraints gbclblTitle = new GridBagConstraints();
	gbclblTitle.insets = new Insets(0, 0, 5, 5);
	gbclblTitle.anchor = GridBagConstraints.NORTHWEST;
	gbclblTitle.gridx = 1;
	gbclblTitle.gridy = 0;
	add(lblTitle, gbclblTitle);

	JLabel lblDate = new JLabel(value.getDate());
	lblDate.setFont(MTGControler.getInstance().getFont().deriveFont(Font.PLAIN, 11));
	GridBagConstraints gbclblDate = new GridBagConstraints();
	gbclblDate.anchor = GridBagConstraints.NORTH;
	gbclblDate.insets = new Insets(0, 0, 5, 0);
	gbclblDate.gridx = 2;
	gbclblDate.gridy = 0;
	add(lblDate, gbclblDate);

	JLabel lblAuthor = new JLabel(value.getAuthor());
	lblAuthor.setFont(MTGControler.getInstance().getFont().deriveFont( Font.ITALIC, 11));
	GridBagConstraints gbclblAuthor = new GridBagConstraints();
	gbclblAuthor.anchor = GridBagConstraints.WEST;
	gbclblAuthor.insets = new Insets(0, 0, 5, 5);
	gbclblAuthor.gridx = 1;
	gbclblAuthor.gridy = 1;
	add(lblAuthor, gbclblAuthor);

	JEditorPane editorPane = new JEditorPane();
	editorPane.setEditable(false);
	editorPane.setOpaque(false);
	editorPane.setText(value.getDescription());
	GridBagConstraints gbceditorPane = new GridBagConstraints();
	gbceditorPane.gridwidth = 2;
	gbceditorPane.insets = new Insets(0, 0, 0, 5);
	gbceditorPane.fill = GridBagConstraints.BOTH;
	gbceditorPane.gridx = 1;
	gbceditorPane.gridy = 2;
	add(editorPane, gbceditorPane);

}
 
Example 18
Source File: ArtARDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@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;
}
 
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;
}