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

The following examples show how to use javax.swing.JTextPane#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: ShowNotifications.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static JTextPane createInfoPanel(String notification) {
    JTextPane balloon = new JTextPane();
    balloon.setContentType("text/html");
    String text = getDetails(notification).replaceAll("(\r\n|\n|\r)", "<br>");
    balloon.setText(text);
    balloon.setOpaque(false);
    balloon.setEditable(false);
    balloon.setBorder(new EmptyBorder(0, 0, 0, 0));


    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) {
        //#134837
        //http://forums.java.net/jive/thread.jspa?messageID=283882
        balloon.setBackground(new Color(0, 0, 0, 0));
    }

    balloon.addHyperlinkListener(new HyperlinkListener() {

        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                URLDisplayer.getDefault().showURL(e.getURL());
            }
        }
    });
    return balloon;
}
 
Example 2
Source File: InformationPanel.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a new InformationPanel.
 */
InformationPanel() {
	setLayout(new OverlayLayout(this));
	JComponent container = SBoxLayout.createContainer(SBoxLayout.VERTICAL);
	glassPane = new JComponent(){};
	add(glassPane);
	add(container);

	// ** Zone name **
	nameField = new JTextPane();
	StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
	nameField.setAlignmentX(CENTER_ALIGNMENT);
	nameField.setOpaque(true);
	nameField.setBackground(getBackground());
	nameField.setForeground(Color.WHITE);
	nameField.setFocusable(false);
	nameField.setEditable(false);
	container.add(nameField, SLayout.EXPAND_X);

	// ** Danger display **
	dangerIndicator = new DangerIndicator(MAX_SKULLS);
	dangerIndicator.setAlignmentX(CENTER_ALIGNMENT);
	container.add(dangerIndicator);
	// Default to safe, so that we always have a tooltip
	describeDanger(0);
}
 
Example 3
Source File: OperationPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JComponent getElementsComponent (String msg) {
    JTextPane area = new JTextPane ();
    area.setEditable (false);
    area.setContentType ("text/html"); // NOI18N
    area.setText (msg);
    area.setOpaque (false);
    area.setBackground(new Color(0, 0, 0, 0));
    area.putClientProperty( JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE );
    return area;
}
 
Example 4
Source File: NetworkErrorPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    infoScrollPane = new JScrollPane();
    infoTextPane = new JTextPane();

    infoScrollPane.setBorder(null);

    infoTextPane.setEditable(false);
    infoTextPane.setBorder(null);
    infoTextPane.setContentType("text/html"); // NOI18N
    infoTextPane.setText(NbBundle.getMessage(NetworkErrorPanel.class, "NetworkErrorPanel.infoTextPane.text")); // NOI18N
    infoTextPane.setOpaque(false);
    infoScrollPane.setViewportView(infoTextPane);

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(infoScrollPane)
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(infoScrollPane)
            .addContainerGap())
    );
}
 
Example 5
Source File: VCSNotificationDisplayer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JTextPane getPane(File[] files, File projectDir, String url, String revision) {
    JTextPane bubble = new JTextPane();
    bubble.setOpaque(false);
    bubble.setEditable(false);

    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) {                   //NOI18N
        //#134837
        //http://forums.java.net/jive/thread.jspa?messageID=283882
        bubble.setBackground(new Color(0, 0, 0, 0));
    }

    bubble.setContentType("text/html");                                          //NOI18N
    setupPane(bubble, files, projectDir, url, revision);
    return bubble;
}
 
Example 6
Source File: RevisionItemCell.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initTextPane (JTextPane pane) {
    pane.setBorder(null);
    pane.setLayout(null);
    //fix for nimbus laf
    pane.setOpaque(false);
    pane.setBackground(new Color(0, 0, 0, 0));
}
 
Example 7
Source File: UpdateFrame.java    From GIFKR with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void initializeComponents() {
	infoPane		= new JTextPane();
	infoPane.setText("You are using version "+version+" but the current version is " +CalebKussmaul.getLatestVersion(p)+". It is strongly reccomended that you update to take advantage of the latest additions and fixes.");
	
	StyledDocument doc = infoPane.getStyledDocument();
	SimpleAttributeSet center = new SimpleAttributeSet();
	StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
	doc.setParagraphAttributes(0, doc.getLength(), center, false);
	
	infoPane.setEditable(false);
	infoPane.setOpaque(false);
	updateButton 	= new JButton("Download update...");
}
 
Example 8
Source File: Utility.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a {@code JTextPane} with default styles.
 *
 * @return The default {@code JTextPane} to use.
 */
public static JTextPane getDefaultTextPane() {
    DefaultStyledDocument document
        = new DefaultStyledDocument(STYLE_CONTEXT);

    JTextPane textPane = new JTextPane(document);
    textPane.setOpaque(false);
    textPane.setEditable(false);
    textPane.setLogicalStyle(STYLE_CONTEXT.getStyle("regular"));
    return textPane;
}
 
Example 9
Source File: AppUtils.java    From RemoteSupportTool with Apache License 2.0 5 votes vote down vote up
public static Boolean askQuestion(Component parent, String message, String title) {
    JTextPane content = new JTextPane();
    content.setEditable(false);
    content.setOpaque(false);
    content.setText(message);

    int response = JOptionPane.showConfirmDialog(
            parent, content, title, JOptionPane.YES_NO_OPTION);

    if (response == JOptionPane.OK_OPTION)
        return true;
    if (response == JOptionPane.NO_OPTION)
        return false;
    return null;
}
 
Example 10
Source File: AppUtils.java    From RemoteSupportTool with Apache License 2.0 5 votes vote down vote up
public static void showMessage(Component parent, String message, String title, int type) {
    JTextPane content = new JTextPane();
    content.setEditable(false);
    content.setOpaque(false);
    content.setText(message);
    JOptionPane.showMessageDialog(parent, content, title, type);
}
 
Example 11
Source File: ModuleLifecycleManager.java    From netbeans with Apache License 2.0 4 votes vote down vote up
void disableOtherModules () {
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            boolean notify = false;
            outter: for (int i = 0; i < otherGitModules.length; i++) {
                FileLock lock = null;
                OutputStream os = null;
                try {
                    String newModule = otherGitModules[i];
                    String newModuleXML = "Modules/" + newModule.replace('.', '-') + ".xml"; // NOI18N
                    FileObject fo = FileUtil.getConfigFile(newModuleXML);
                    if (fo == null) continue;
                    Document document = readModuleDocument(fo);

                    NodeList list = document.getDocumentElement().getElementsByTagName("param"); // NOI18N
                    int n = list.getLength();
                    for (int j = 0; j < n; j++) {
                        Element node = (Element) list.item(j);
                        if ("enabled".equals(node.getAttribute("name"))) { // NOI18N
                            Text text = (Text) node.getChildNodes().item(0);
                            String value = text.getNodeValue();
                            if ("true".equals(value)) { // NOI18N
                                text.setNodeValue("false"); // NOI18N
                                break;
                            } else {
                                continue outter;
                            }
                        }
                    }
                    notify = true;                            
                    lock = fo.lock();
                    os = fo.getOutputStream(lock);
                    
                    XMLUtil.write(document, os, "UTF-8"); // NOI18N
                } catch (Exception e) {
                    Git.LOG.log(Level.WARNING, null, e);
                } finally {
                    if (os != null) try { os.close(); } catch (IOException ex) {}
                    if (lock != null) lock.releaseLock();
                }
            }
            if(notify) {
                JTextPane ballonDetails = getPane(NbBundle.getBundle(ModuleLifecycleManager.class).getString("MSG_Install_Warning")); // using the same pane causes the balloon popup
                JTextPane popupDetails = getPane(NbBundle.getBundle(ModuleLifecycleManager.class).getString("MSG_Install_Warning"));  // to trim the text to the first line
                NotificationDisplayer.getDefault().notify(
                        NbBundle.getMessage(ModuleLifecycleManager.class, "MSG_Install_Warning_Title"), //NOI18N
                        ImageUtilities.loadImageIcon("org/netbeans/modules/git/resources/icons/info.png", false),
                        ballonDetails, popupDetails, NotificationDisplayer.Priority.NORMAL, NotificationDisplayer.Category.WARNING);
            }
        }
                    
        private JTextPane getPane(String txt) {
            JTextPane bubble = new JTextPane();
            bubble.setOpaque(false);
            bubble.setEditable(false);
            if (UIManager.getLookAndFeel().getID().equals("Nimbus")) {                   //NOI18N
                //#134837
                //http://forums.java.net/jive/thread.jspa?messageID=283882
                bubble.setBackground(new Color(0, 0, 0, 0));
            }
            bubble.setContentType("text/html");                                          //NOI18N
            bubble.setText(txt);
            return bubble;
        }             
    };
    RequestProcessor.getDefault().post(runnable);
}
 
Example 12
Source File: CreditsFrame.java    From GIFKR with GNU Lesser General Public License v3.0 4 votes vote down vote up
public CreditsFrame() {
	super("Credits");
	setLayout(new GridBagLayout());
	GridBagConstraints gbc = ViewUtils.createGBC();
	gbc.fill = GridBagConstraints.HORIZONTAL;
	gbc.weighty=1;
	gbc.insets = new Insets(0, 10, 10, 10);
	
	JLabel logoLabel = new JLabel(new ImageIcon(ImageTools.scaleToHeight(ImageTools.getResourceImage("icon.png"), 100, false)));
	logoLabel.setText("<HTML>GIFKR &copy; 2017 Caleb Kussmaul");
	logoLabel.setHorizontalTextPosition(JLabel.CENTER);
	logoLabel.setVerticalTextPosition(JLabel.BOTTOM);
	
	add(logoLabel, gbc);
	
	gbc.gridy++;
	gbc.weighty=0;
	
	JTextPane dedicationPane = new JTextPane();
	
	dedicationPane.setText("Dedicated to my dad, Wes Kussmaul, for inspiring my passion for programming, creativity, and entrepreneurship.");
	dedicationPane.setOpaque(false);
	dedicationPane.setEditable(false);
	ViewUtils.centerText(dedicationPane);
	
	add(dedicationPane, gbc);
	gbc.gridy++;
	
	JTextPane copyrightPane = new JTextPane();
	copyrightPane.setText("Referenced libraries:\nOpen-Imaging under Apache 2.0\nJavaCV under Apache 2.0\nFFmpeg under LGPL 2.1");
	add(copyrightPane, gbc);
	gbc.gridy++;
	gbc.fill = GridBagConstraints.NONE;
	gbc.anchor = GridBagConstraints.CENTER;
	
	
	JCheckBox doNotShowBox = new JCheckBox("Do not show again", !GIFKRPrefs.showCreditsFrame());
	doNotShowBox.addChangeListener(ce -> {
		GIFKRPrefs.setShowCreditsFrame(!doNotShowBox.isSelected());
	});
	
	add(doNotShowBox, gbc);
	
	setSize(500, 350);
	setLocationRelativeTo(null);
	setAlwaysOnTop(true);
}
 
Example 13
Source File: PlayerChunkViewer.java    From ChickenChunks with MIT License 4 votes vote down vote up
public TicketInfoDialog(LinkedList<TicketInfo> tickets)
{
    super(PlayerChunkViewer.this);
    setModalityType(ModalityType.DOCUMENT_MODAL);
    this.tickets = tickets;

    infoPane = new JTextPane();
    infoPane.setEditable(false);
    infoPane.setOpaque(false);
    infoPane.setContentType("text/html");
    
    infoScrollPane = new JScrollPane(infoPane);
    infoScrollPane.setOpaque(false);
    add(infoScrollPane);
    
    chunkPane = new JTextPane();
    chunkPane.setEditable(false);
    chunkPane.setOpaque(false);
    chunkPane.setContentType("text/html");
    
    chunkScrollPane = new JScrollPane(chunkPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    add(chunkScrollPane);

    ticketComboBox = new JComboBox<String>();
    for(TicketInfo ticket : tickets)
    {
        String ident = ticket.modId;
        if(ticket.player != null)
            ident += ", " + ticket.player;
        ident += " #" + ticket.ID;
        ticketComboBox.addItem(ident);
    }
    add(ticketComboBox);

    addWindowListener(new WindowAdapter()
    {
        @Override
        public void windowClosing(WindowEvent e)
        {
            dialog = null;
        }
    });

    setLayout(this);
    setSize(getPreferredSize());
    setLocationRelativeTo(null);
    pack();

    dialog = this;

    setVisible(true);
}
 
Example 14
Source File: BreakpointConsoleUI.java    From whyline with MIT License 3 votes vote down vote up
public BreakpointConsoleUI(WhylineUI whylineUI) {
	
	this.whylineUI = whylineUI;

	setBorder(new WhylineControlBorder());

	console = new JTextPane() {
		public boolean getScrollableTracksViewportWidth() { return false; }
	};
	console.setBackground(UI.getConsoleBackColor());
	console.setForeground(UI.getConsoleTextColor());
	console.setFont(UI.getFixedFont());
	console.setEditable(false);
	
	console.setBackground(UI.getControlBackColor());
	console.setOpaque(true);

	debugAttributes = new SimpleAttributeSet();
	StyleConstants.setItalic(debugAttributes, false);
	StyleConstants.setForeground(debugAttributes, UI.getConsoleTextColor());

	regularAttributes = new SimpleAttributeSet();
	StyleConstants.setItalic(regularAttributes, false);
	StyleConstants.setForeground(regularAttributes, UI.getConsoleTextColor());

	setLayout(new BorderLayout(0, UI.getPanelPadding()));

	add(new WhylineScrollPane(console), BorderLayout.CENTER);

	setPreferredSize(new Dimension(0, UI.getDefaultInfoPaneHeight(whylineUI)));
	
	clear();
	
}