MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / init

Method init

ij/src/main/java/ij/gui/HTMLDialog.java:38–95  ·  view source on GitHub ↗
(String message)

Source from the content-addressed store, hash-verified

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 }

Callers 1

HTMLDialogMethod · 0.95

Calls 15

getLookAndFeelMethod · 0.95
setSystemLookAndFeelMethod · 0.95
getScreenSizeMethod · 0.95
centerOnImageJScreenMethod · 0.95
addWindowMethod · 0.95
setLookAndFeelMethod · 0.95
addActionListenerMethod · 0.80
addMethod · 0.65
getSizeMethod · 0.65
getTitleMethod · 0.65
setTextMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected