List of usage examples for javax.swing JEditorPane HONOR_DISPLAY_PROPERTIES
String HONOR_DISPLAY_PROPERTIES
To view the source code for javax.swing JEditorPane HONOR_DISPLAY_PROPERTIES.
Click Source Link
From source file:Main.java
/** * Enforces JEditorPane font.// w w w. ja v a 2 s . c o m * Once the content type of a JEditorPane is set to text/html the font on the Pane starts to be managed by Swing. * This method forces using provided font. */ public static void enforceJEditorPaneFont(JEditorPane jEditorPane, Font font) { jEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); jEditorPane.setFont(font); }
From source file:com.android.tools.swing.ui.NavigationComponent.java
public NavigationComponent() { setEditable(false);//from w w w. j av a2 s.c om setContentType(ContentType.TEXT_HTML.getMimeType()); putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); // Disable links decoration. ((HTMLDocument) getDocument()).getStyleSheet().addRule("a { text-decoration:none; }"); addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) { return; } int idx = Integer.parseInt(e.getDescription()); final T item = myItemStack.get(idx); for (final ItemListener<T> listener : myItemListeners) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { listener.itemSelected(item); } }); } } }); }
From source file:net.sf.keystore_explorer.gui.dialogs.extensions.DViewExtensions.java
private void initComponents() { ExtensionsTableModel extensionsTableModel = new ExtensionsTableModel(); jtExtensions = new JKseTable(extensionsTableModel); TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(extensionsTableModel); sorter.setComparator(2, new ObjectIdComparator()); jtExtensions.setRowSorter(sorter);/*from ww w. j a v a2 s.c om*/ jtExtensions.setShowGrid(false); jtExtensions.setRowMargin(0); jtExtensions.getColumnModel().setColumnMargin(0); jtExtensions.getTableHeader().setReorderingAllowed(false); jtExtensions.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS); jtExtensions.setRowHeight(Math.max(18, jtExtensions.getRowHeight())); for (int i = 0; i < jtExtensions.getColumnCount(); i++) { TableColumn column = jtExtensions.getColumnModel().getColumn(i); column.setHeaderRenderer( new ExtensionsTableHeadRend(jtExtensions.getTableHeader().getDefaultRenderer())); column.setCellRenderer(new ExtensionsTableCellRend()); } TableColumn criticalCol = jtExtensions.getColumnModel().getColumn(0); criticalCol.setResizable(false); criticalCol.setMinWidth(28); criticalCol.setMaxWidth(28); criticalCol.setPreferredWidth(28); ListSelectionModel selectionModel = jtExtensions.getSelectionModel(); selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { try { CursorUtil.setCursorBusy(DViewExtensions.this); updateExtensionValue(); } finally { CursorUtil.setCursorFree(DViewExtensions.this); } } } }); jspExtensionsTable = PlatformUtil.createScrollPane(jtExtensions, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jspExtensionsTable.getViewport().setBackground(jtExtensions.getBackground()); jpExtensionsTable = new JPanel(new BorderLayout(5, 5)); jpExtensionsTable.setPreferredSize(new Dimension(500, 200)); jpExtensionsTable.add(jspExtensionsTable, BorderLayout.CENTER); jpExtensionValue = new JPanel(new BorderLayout(5, 5)); jlExtensionValue = new JLabel(res.getString("DViewExtensions.jlExtensionValue.text")); jpExtensionValue.add(jlExtensionValue, BorderLayout.NORTH); jepExtensionValue = new JEditorPane(); jepExtensionValue.setFont(new Font(Font.MONOSPACED, Font.PLAIN, LnfUtil.getDefaultFontSize())); jepExtensionValue.setEditable(false); jepExtensionValue.setToolTipText(res.getString("DViewExtensions.jtaExtensionValue.tooltip")); // JGoodies - keep uneditable color same as editable jepExtensionValue.putClientProperty("JTextArea.infoBackground", Boolean.TRUE); // for displaying URLs in extensions as clickable links jepExtensionValue.setContentType("text/html"); jepExtensionValue.addHyperlinkListener(this); // use default font and foreground color from the component jepExtensionValue.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); jspExtensionValue = PlatformUtil.createScrollPane(jepExtensionValue, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); jpExtensionValueTextArea = new JPanel(new BorderLayout(5, 5)); jpExtensionValueTextArea.setPreferredSize(new Dimension(500, 200)); jpExtensionValueTextArea.add(jspExtensionValue, BorderLayout.CENTER); jpExtensionValue.add(jpExtensionValueTextArea, BorderLayout.CENTER); jbAsn1 = new JButton(res.getString("DViewExtensions.jbAsn1.text")); PlatformUtil.setMnemonic(jbAsn1, res.getString("DViewExtensions.jbAsn1.mnemonic").charAt(0)); jbAsn1.setToolTipText(res.getString("DViewExtensions.jbAsn1.tooltip")); jbAsn1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DViewExtensions.this); asn1DumpPressed(); } finally { CursorUtil.setCursorFree(DViewExtensions.this); } } }); jpExtensionValueAsn1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); jpExtensionValueAsn1.add(jbAsn1); jpExtensionValue.add(jpExtensionValueAsn1, BorderLayout.SOUTH); jpExtensions = new JPanel(new GridLayout(2, 1, 5, 5)); jpExtensions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5)))); jpExtensions.add(jpExtensionsTable); jpExtensions.add(jpExtensionValue); jbOK = new JButton(res.getString("DViewExtensions.jbOK.text")); jbOK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { okPressed(); } }); jpOK = PlatformUtil.createDialogButtonPanel(jbOK, false); extensionsTableModel.load(extensions); if (extensionsTableModel.getRowCount() > 0) { jtExtensions.changeSelection(0, 0, false, false); } getContentPane().add(jpExtensions, BorderLayout.CENTER); getContentPane().add(jpOK, BorderLayout.SOUTH); setResizable(false); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { closeDialog(); } }); getRootPane().setDefaultButton(jbOK); pack(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jbOK.requestFocus(); } }); }
From source file:dk.dma.epd.common.prototype.gui.notification.MsiNmNotificationPanel.java
/** * {@inheritDoc}//from w w w . j a v a2s . c om */ @Override protected void buildGUI() { setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); contentPane.setEditable(false); contentPane.setOpaque(false); contentPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); contentPane.addHyperlinkListener(this); StyleSheet styleSheet = ((HTMLEditorKit) contentPane.getEditorKit()).getStyleSheet(); styleSheet.addRule("a {color: #8888FF;}"); styleSheet.addRule(".title {font-size: 14px;}"); add(scrollPane, BorderLayout.CENTER); }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatConversationPanel.java
/** * Creates an instance of <tt>ChatConversationPanel</tt>. * * @param chatContainer The parent <tt>ChatConversationContainer</tt>. *//*from w ww. j av a 2 s . c o m*/ public ChatConversationPanel(ChatConversationContainer chatContainer) { editorKit = new ChatConversationEditorKit(this); this.chatContainer = chatContainer; isHistory = (chatContainer instanceof HistoryWindow); this.rightButtonMenu = new ChatRightButtonMenu(this); this.document = (HTMLDocument) editorKit.createDefaultDocument(); this.document.addDocumentListener(editorKit); this.chatTextPane.setEditorKitForContentType("text/html", editorKit); this.chatTextPane.setEditorKit(editorKit); this.chatTextPane.setEditable(false); this.chatTextPane.setDocument(document); this.chatTextPane.setDragEnabled(true); chatTextPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); Constants.loadSimpleStyle(document.getStyleSheet(), chatTextPane.getFont()); this.chatTextPane.addHyperlinkListener(this); this.chatTextPane.addMouseListener(this); this.chatTextPane.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); this.addChatLinkClickedListener(showPreview); this.setWheelScrollingEnabled(true); this.setViewportView(chatTextPane); this.setBorder(null); this.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); ToolTipManager.sharedInstance().registerComponent(chatTextPane); String copyLinkString = GuiActivator.getResources().getI18NString("service.gui.COPY_LINK"); copyLinkItem = new JMenuItem(copyLinkString, new ImageIcon(ImageLoader.getImage(ImageLoader.COPY_ICON))); copyLinkItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { StringSelection stringSelection = new StringSelection(currentHref); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection, ChatConversationPanel.this); } }); String openLinkString = GuiActivator.getResources().getI18NString("service.gui.OPEN_IN_BROWSER"); openLinkItem = new JMenuItem(openLinkString, new ImageIcon(ImageLoader.getImage(ImageLoader.BROWSER_ICON))); openLinkItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { GuiActivator.getBrowserLauncher().openURL(currentHref); // after opening the link remove the currentHref to avoid // clicking on the window to gain focus to open the link again ChatConversationPanel.this.currentHref = ""; } }); openLinkItem.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OPEN_IN_BROWSER")); copyLinkItem.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.COPY_LINK")); configureReplacementItem = new JMenuItem( GuiActivator.getResources().getI18NString("plugin.chatconfig.replacement.CONFIGURE_REPLACEMENT"), GuiActivator.getResources().getImage("service.gui.icons.CONFIGURE_ICON")); configureReplacementItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final ConfigurationContainer configContainer = GuiActivator.getUIService() .getConfigurationContainer(); ConfigurationForm chatConfigForm = getChatConfigForm(); if (chatConfigForm != null) { configContainer.setSelected(chatConfigForm); configContainer.setVisible(true); } } }); this.isSimpleTheme = ConfigurationUtils.isChatSimpleThemeEnabled(); /* * When we append a new message (regardless of whether it is a string or * an UI component), we want to make it visible in the viewport of this * JScrollPane so that the user can see it. */ ComponentListener componentListener = new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { synchronized (scrollToBottomRunnable) { if (!scrollToBottomIsPending) return; scrollToBottomIsPending = false; /* * Yana Stamcheva, pointed out that Java 5 (on Linux only?) * needs invokeLater for JScrollBar. */ SwingUtilities.invokeLater(scrollToBottomRunnable); } } }; chatTextPane.addComponentListener(componentListener); getViewport().addComponentListener(componentListener); }
From source file:com.ficeto.esp.EspExceptionDecoder.java
private void createAndUpload() { if (!PreferencesData.get("target_platform").contentEquals("esp8266") && !PreferencesData.get("target_platform").contentEquals("esp32") && !PreferencesData.get("target_platform").contentEquals("ESP31B")) { System.err.println();//from w ww . ja v a2 s . com editor.statusError("Not Supported on " + PreferencesData.get("target_platform")); return; } String tc = "esp32"; if (PreferencesData.get("target_platform").contentEquals("esp8266")) { tc = "lx106"; } TargetPlatform platform = BaseNoGui.getTargetPlatform(); String gccPath = PreferencesData.get("runtime.tools.xtensa-" + tc + "-elf-gcc.path"); if (gccPath == null) { gccPath = platform.getFolder() + "/tools/xtensa-" + tc + "-elf"; } String addr2line; if (PreferencesData.get("runtime.os").contentEquals("windows")) addr2line = "xtensa-" + tc + "-elf-addr2line.exe"; else addr2line = "xtensa-" + tc + "-elf-addr2line"; tool = new File(gccPath + "/bin", addr2line); if (!tool.exists() || !tool.isFile()) { System.err.println(); editor.statusError("ERROR: " + addr2line + " not found!"); return; } elf = new File(getBuildFolderPath(editor.getSketch()), editor.getSketch().getName() + ".ino.elf"); if (!elf.exists() || !elf.isFile()) { elf = new File(getBuildFolderPath(editor.getSketch()), editor.getSketch().getName() + ".cpp.elf"); if (!elf.exists() || !elf.isFile()) { //lets give the user a chance to select the elf final JFileChooser fc = new JFileChooser(); fc.addChoosableFileFilter(new ElfFilter()); fc.setAcceptAllFileFilterUsed(false); int returnVal = fc.showDialog(editor, "Select ELF"); if (returnVal == JFileChooser.APPROVE_OPTION) { elf = fc.getSelectedFile(); } else { editor.statusError("ERROR: elf was not found!"); System.err.println("Open command cancelled by user."); return; } } } JFrame.setDefaultLookAndFeelDecorated(true); frame = new JFrame("Exception Decoder"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); inputArea = new JTextArea("Paste your stack trace here", 16, 60); inputArea.setLineWrap(true); inputArea.setWrapStyleWord(true); inputArea.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "commit"); inputArea.getActionMap().put("commit", new CommitAction()); inputArea.getDocument().addDocumentListener(this); frame.getContentPane().add(new JScrollPane(inputArea), BorderLayout.PAGE_START); outputText = ""; outputArea = new JTextPane(); outputArea.setContentType("text/html"); outputArea.setEditable(false); outputArea.setBackground(null); outputArea.setBorder(null); outputArea.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true); outputArea.setText(outputText); JScrollPane outputScrollPane = new JScrollPane(outputArea); outputScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); outputScrollPane.setPreferredSize(new Dimension(640, 200)); outputScrollPane.setMinimumSize(new Dimension(10, 10)); frame.getContentPane().add(outputScrollPane, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java
private void initTextArea(JPanel centerPanel) { GridBagConstraints constraints = new GridBagConstraints(); editorPane.setContentType("text/html"); editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); editorPane.setCaretPosition(0);//from w w w . j av a 2 s . c om editorPane.setEditorKit(new SIPCommHTMLEditorKit(this)); editorPane.getDocument().addUndoableEditListener(this); editorPane.getDocument().addDocumentListener(this); editorPane.addKeyListener(this); editorPane.addMouseListener(this); editorPane.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); editorPane.setDragEnabled(true); editorPane.setTransferHandler(new ChatTransferHandler(chatPanel)); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setOpaque(false); scrollPane.getViewport().setOpaque(false); scrollPane.setBorder(null); scrollPane.setViewportView(editorPane); constraints.anchor = GridBagConstraints.NORTHWEST; constraints.fill = GridBagConstraints.BOTH; constraints.gridx = 2; constraints.gridy = 0; constraints.weightx = 1f; constraints.weighty = 1f; constraints.gridheight = 1; constraints.gridwidth = 1; constraints.insets = new Insets(0, 0, 0, 0); centerPanel.add(scrollPane, constraints); }
From source file:net.pms.newgui.LanguageSelection.java
private JComponent buildComponent() { // UIManager manages to get the background color wrong for text // components on OS X, so we apply the color manually Color backgroundColor = UIManager.getColor("Panel.background"); rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.PAGE_AXIS)); // It needs to be something in the title text, or the size calculation for the border will be wrong. selectionPanelBorder.setTitle(" "); selectionPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5), BorderFactory.createCompoundBorder(selectionPanelBorder, BorderFactory.createEmptyBorder(10, 5, 10, 5)))); selectionPanel.setLayout(new BoxLayout(selectionPanel, BoxLayout.PAGE_AXIS)); descriptionText.setEditable(false);//from ww w . ja v a 2s. c om descriptionText.setBackground(backgroundColor); descriptionText.setFocusable(false); descriptionText.setLineWrap(true); descriptionText.setWrapStyleWord(true); descriptionText.setBorder(BorderFactory.createEmptyBorder(5, 15, 10, 15)); selectionPanel.add(descriptionText); jLanguage = new JComboBox<>(keyedModel); jLanguage.setEditable(false); jLanguage.setPreferredSize(new Dimension(50, jLanguage.getPreferredSize().height)); jLanguage.addActionListener(new LanguageComboBoxActionListener()); languagePanel.setLayout(new BoxLayout(languagePanel, BoxLayout.PAGE_AXIS)); languagePanel.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15)); languagePanel.add(jLanguage); selectionPanel.add(languagePanel); warningText.setEditable(false); warningText.setFocusable(false); warningText.setBackground(backgroundColor); warningText.setFont(warningText.getFont().deriveFont(Font.BOLD)); warningText.setLineWrap(true); warningText.setWrapStyleWord(true); warningText.setBorder(BorderFactory.createEmptyBorder(5, 15, 0, 15)); selectionPanel.add(warningText); // It needs to be something in the title text, or the size calculation for the border will be wrong. infoTextBorder.setTitle(" "); infoText.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5), BorderFactory .createCompoundBorder(infoTextBorder, BorderFactory.createEmptyBorder(15, 20, 20, 20)))); infoText.setEditable(false); infoText.setFocusable(false); infoText.setBackground(backgroundColor); infoText.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); // This exercise is to avoid using the default shared StyleSheet with padding CustomHTMLEditorKit editorKit = new CustomHTMLEditorKit(); StyleSheet styleSheet = new StyleSheet(); styleSheet.addRule("a { color: #0000EE; text-decoration:underline; }"); editorKit.setStyleSheet(styleSheet); infoText.setEditorKit(editorKit); infoText.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { boolean error = false; if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI(e.getDescription())); } catch (IOException | URISyntaxException ex) { LOGGER.error("Language selection failed to open translation page hyperlink: ", ex.getMessage()); LOGGER.trace("", ex); error = true; } } else { LOGGER.warn("Desktop is not supported, the clicked translation page link can't be opened"); error = true; } if (error) { JOptionPane.showOptionDialog(dialog, String.format(buildString("LanguageSelection.6", true), PMS.CROWDIN_LINK), buildString("Dialog.Error"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null); } } } }); rootPanel.add(selectionPanel); rootPanel.add(infoText); applyButton.addActionListener(new ApplyButtonActionListener()); applyButton.setActionCommand("apply"); selectButton.addActionListener(new SelectButtonActionListener()); selectButton.setActionCommand("select"); return rootPanel; }
From source file:pl.kotcrab.arget.gui.MainWindow.java
private void createAndShowGUI() { setTitle(App.APP_NAME);/*from w ww.ja v a 2 s . c o m*/ setBounds(100, 100, 800, 700); setMinimumSize(new Dimension(500, 250)); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setIconImage(App.loadImage("/data/icon/icon.png")); sessionWindowManager = new SessionWindowManager(this); if (profile.mainWindowBounds != null && GraphicsUtils.isRectangleDisplayableOnScreen(profile.mainWindowBounds)) setBounds(profile.mainWindowBounds); createMenuBars(); contactsPanel = new ContactsPanel(profile, this); statusPane = new JTextPane(); statusPane.setBorder(new EmptyBorder(1, 3, 2, 0)); statusPane.setContentType("text/html"); statusPane.setBackground(null); statusPane.setHighlighter(null); statusPane.setEditable(false); statusPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true); statusPane.setFont(new Font("Tahoma", Font.PLAIN, 13)); statusPane.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { String desc = e.getDescription(); if (desc.startsWith("version-mismatch")) { desc = desc.substring(desc.indexOf("://") + 3); String[] versionInfo = desc.split("!"); new VersionMismatchDialog(MainWindow.instance, versionInfo[0], Integer.valueOf(versionInfo[1])); } } } }); JPanel bottomPanel = new JPanel(new BorderLayout(0, 0)); getContentPane().add(bottomPanel, BorderLayout.SOUTH); scrollLockToggle = new WebToggleButton(); scrollLockToggle.setToolTipText("Scroll lock"); scrollLockToggle.setRolloverDecoratedOnly(true); scrollLockToggle.setDrawFocus(false); scrollLockToggle.setIcon(App.loadImageIcon("/data/scrolllock.png")); scrollLockToggle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { postScrollLockUpdate(); } }); bottomPanel.add(statusPane); bottomPanel.add(scrollLockToggle, BorderLayout.EAST); splitPane = new JSplitPane(); splitPane.setBorder(new BottomSplitPaneBorder()); splitPane.setResizeWeight(0); splitPane.setContinuousLayout(true); splitPane.setOneTouchExpandable(true); getContentPane().add(splitPane, BorderLayout.CENTER); homePanel = new HomePanel(profile.fileName); logPanel = new LoggerPanel(); errorStatusPanel = new ErrorStatusPanel(); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.add(contactsPanel, BorderLayout.CENTER); leftPanel.add(errorStatusPanel, BorderLayout.SOUTH); splitPane.setLeftComponent(leftPanel); splitPane.setRightComponent(null); setCenterScreenTo(homePanel); addWindowFocusListener(new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { instance.validate(); instance.revalidate(); instance.repaint(); getCenterScreen().onShow(); } @Override public void windowLostFocus(WindowEvent e) { getCenterScreen().onHide(); } }); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { ExitCleaner.forceExit(); } }); setVisible(true); }
From source file:pl.kotcrab.arget.gui.session.msg.TextMessage.java
public TextMessage(MsgType type, String text, boolean markAsRead) { super(type);//from ww w .j ava 2 s . com textPane = new JTextPane(); textPane.setAlignmentX(Component.LEFT_ALIGNMENT); textPane.setEditorKit(new WrapHTMLEditorKit()); textPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true); textPane.setEditable(false); textPane.setBackground(null); textPane.setBorder(new EmptyBorder(3, 3, 0, 0)); textPane.setFont(textFont); textPane.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent hle) { if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) { if (DesktopUtils.openWebsite(hle.getURL()) == false) JOptionPane.showMessageDialog(null, "Invalid URL: " + hle.getURL(), "Error", JOptionPane.ERROR_MESSAGE); } } }); setText(text); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); add(textPane); DateFormat dateFormat = new SimpleDateFormat("[HH:mm] "); Date date = new Date(); String textToShow = dateFormat.format(date); if (markAsRead == false) textToShow += "*"; timeLabel = new JLabel(textToShow); timeLabel.setBorder(new EmptyBorder(0, 3, 3, 0)); timeLabel.setForeground(Color.GRAY); timeLabel.setFont(smallTextFont); add(timeLabel); }