(String message)
| 36 | } |
| 37 | |
| 38 | private void init(String message) { |
| 39 | LookAndFeel saveLookAndFeel = Java2.getLookAndFeel(); |
| 40 | Java2.setSystemLookAndFeel(); |
| 41 | Container container = getContentPane(); |
| 42 | container.setLayout(new BorderLayout()); |
| 43 | if (message==null) message = ""; |
| 44 | editorPane = new JEditorPane("text/html",""); |
| 45 | editorPane.setEditable(false); |
| 46 | HTMLEditorKit kit = new HTMLEditorKit(); |
| 47 | editorPane.setEditorKit(kit); |
| 48 | StyleSheet styleSheet = kit.getStyleSheet(); |
| 49 | styleSheet.addRule("body{font-family:Verdana,sans-serif; font-size:11.5pt; margin:5px 10px 5px 10px;}"); //top right bottom left |
| 50 | styleSheet.addRule("h1{font-size:18pt;}"); |
| 51 | styleSheet.addRule("h2{font-size:15pt;}"); |
| 52 | styleSheet.addRule("dl dt{font-face:bold;}"); |
| 53 | editorPane.setText(message); //display the html text with the above style |
| 54 | editorPane.getActionMap().put("insert-break", new AbstractAction(){ |
| 55 | public void actionPerformed(ActionEvent e) {} |
| 56 | }); //suppress beep on <ENTER> key |
| 57 | JScrollPane scrollPane = new JScrollPane(editorPane); |
| 58 | container.add(scrollPane); |
| 59 | JButton button = new JButton("OK"); |
| 60 | button.addActionListener(this); |
| 61 | button.addKeyListener(this); |
| 62 | editorPane.addKeyListener(this); |
| 63 | editorPane.addHyperlinkListener(this); |
| 64 | JPanel panel = new JPanel(); |
| 65 | panel.add(button); |
| 66 | container.add(panel, "South"); |
| 67 | setForeground(Color.black); |
| 68 | addWindowListener(this); |
| 69 | pack(); |
| 70 | Dimension screenD = IJ.getScreenSize(); |
| 71 | Dimension dialogD = getSize(); |
| 72 | int maxWidth = (int)(Math.min(0.70*screenD.width, 800)); //max 70% of screen width, but not more than 800 pxl |
| 73 | if (maxWidth>400 && dialogD.width>maxWidth) |
| 74 | dialogD.width = maxWidth; |
| 75 | if ("Channels".equals(getTitle())) |
| 76 | dialogD.height = 1000; |
| 77 | if (dialogD.height>0.80*screenD.height && screenD.height>400) //max 80% of screen height |
| 78 | dialogD.height = (int)(0.80*screenD.height); |
| 79 | setSize(dialogD); |
| 80 | GUI.centerOnImageJScreen(this); |
| 81 | if (!modal) { |
| 82 | WindowManager.addWindow(this); |
| 83 | show(); |
| 84 | } |
| 85 | final JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar(); |
| 86 | if (verticalScrollBar!=null) { |
| 87 | EventQueue.invokeLater(new Runnable() { |
| 88 | public void run() { |
| 89 | verticalScrollBar.setValue(verticalScrollBar.getMinimum()); //start scrollbar at top |
| 90 | } |
| 91 | }); |
| 92 | } |
| 93 | if (modal) show(); |
| 94 | Java2.setLookAndFeel(saveLookAndFeel); |
| 95 | } |
no test coverage detected