private static JEditorPane createEditorPane() { JEditorPane editorPane = new JEditorPane(); editorPane.setEditable(false); System.setProperty("http.proxyHost", "cache.univ-lille1.fr"); System.setProperty("http.proxyPort", "3128"); editorPane.setPreferredSize(new Dimension(300, 200)); java.net.URL lille1URL = null; try { lille1URL = new java.net.URL("http://www.google.com"); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (lille1URL != null) { try { editorPane.setPage(lille1URL); } catch (IOException e) { System.err.println("Attempted to read a bad URL: " + lille1URL); } } else { System.err.println("Couldn't find file: http://www.google.com"); } return editorPane; }
/** Methode wird im Konstruktor aufgerufen um den Browser zu generieren */ public void createBrowser(String page) { File localFile = new File(page); try { browser = new JEditorPane(localFile.toURI().toURL()); browser.setEditable(false); } catch (IOException e) { e.printStackTrace(); } browser.setPreferredSize(new Dimension(600, 400)); sp.setPreferredSize(new Dimension(600, 400)); sp.setViewportView(browser); this.add(sp); }
/** Construct a this GUI object's contents. */ private void initComponents() { htmlWindow = new JEditorPane(); htmlWindow.setPreferredSize(new Dimension(500, 500)); htmlWindow.setEditable(false); htmlWindow.setContentType("text/html"); scrollPane = new JScrollPane( htmlWindow, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setPreferredSize(new Dimension(500, 500)); try { htmlWindow.setPage("file:./html-docs/index.html"); } catch (IOException ioe) { System.err.println(ioe); } htmlWindow.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { htmlWindow.setPage(e.getURL()); // ????? } catch (IOException ioe) { System.err.println(ioe); } } } }); JButton exitButton = new JButton("Close Help Window"); exitButton.addActionListener(this); mainPanel = new JPanel(new BorderLayout()); mainPanel.add(exitButton, "North"); mainPanel.add(scrollPane, "Center"); getContentPane().add(mainPanel); }
/** Construct a new "about…" dialog */ public DialogAbout(MDIManager mdimgr) { buttonOk = new JButton(localize("button.OK")); buttonOk.addActionListener(this); JPanel buttonPanel = new JPanel(new FlowLayout(), false); buttonPanel.add(buttonOk); JPanel logoPanel = new JPanel(new FlowLayout(), false); logoPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); logoPanel.add(PEToolKit.createJLabel("Frankenstein")); JPanel infoPanel = new JPanel(new GridLayout(9, 1, 5, 5), true); infoPanel.setBorder(new EmptyBorder(10, 60, 10, 10)); infoPanel.add( new JLabel("jPicEdt " + Version.getVersion() + " Built " + Version.getBuildDate())); infoPanel.add(new JLabel(localize("about.APictureEditorFor"))); final String[] addressLines = { "(c) Sylvain Reynal", "É.N.S.É.A. - Dept. of Physics", "6, avenue du Ponceau", "F-95014 CERGY Cedex", "Fax: +33 (0) 130 736 667", "*****@*****.**", "http://www.jpicedt.org" }; for (String addressLine : addressLines) infoPanel.add(new JLabel(addressLine)); JTabbedPane caveatPanel = new JTabbedPane(); String[] tabKeys = {"license.lines", "license.thirdparty.lines"}; for (String tabKey : tabKeys) { JEditorPane caveatTA = new JEditorPane(); caveatTA.setContentType("text/html; charset=" + localize(tabKey + ".encoding")); caveatTA.setEditable(false); caveatTA.setPreferredSize(new Dimension(485, 300)); JScrollPane scrollCaveat = new JScrollPane(caveatTA); caveatTA.setText(localize(tabKey)); caveatPanel.addTab(localize(tabKey + ".tabname"), null, scrollCaveat, null); } caveatPanel.setBorder(BorderFactory.createEtchedBorder()); JPanel upperPanel = new JPanel(new BorderLayout(), false); upperPanel.add(logoPanel, BorderLayout.WEST); upperPanel.add(infoPanel, BorderLayout.CENTER); upperPanel.add(caveatPanel, BorderLayout.SOUTH); upperPanel.setBorder(BorderFactory.createEtchedBorder()); JPanel contentPane = new JPanel(new BorderLayout(5, 5)); contentPane.add(upperPanel, BorderLayout.NORTH); contentPane.add(buttonPanel, BorderLayout.SOUTH); String title = localize("about.AboutPicEdt") + " " + Version.getVersion(); boolean modal = true; frame = mdimgr.createDialog(title, modal, contentPane); frame.setResizable(true); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); Dimension dlgSize = frame.getPreferredSize(); frame.setSize(dlgSize); // this.pack(); frame.setVisible(true); }
public DetectedPluginsPanel() { super(PluginDownloader.class); final JTable entryTable = getEntryTable(); myHeader = new PluginHeaderPanel(null, entryTable); entryTable.setTableHeader(null); entryTable.setDefaultRenderer( PluginDownloader.class, new ColoredTableCellRenderer() { protected void customizeCellRenderer( final JTable table, final Object value, final boolean selected, final boolean hasFocus, final int row, final int column) { setBorder(null); final PluginDownloader downloader = (PluginDownloader) value; if (downloader != null) { final String pluginName = downloader.getPluginName(); append(pluginName, SimpleTextAttributes.REGULAR_ATTRIBUTES); final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(PluginId.getId(downloader.getPluginId())); if (ideaPluginDescriptor != null) { final String oldPluginName = ideaPluginDescriptor.getName(); if (!Comparing.strEqual(pluginName, oldPluginName)) { append(" - " + oldPluginName, SimpleTextAttributes.REGULAR_ATTRIBUTES); } } final String loadedVersion = downloader.getPluginVersion(); if (loadedVersion != null || (ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null)) { final String installedVersion = ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null ? "v. " + ideaPluginDescriptor.getVersion() + (loadedVersion != null ? " -> " : "") : ""; final String availableVersion = loadedVersion != null ? loadedVersion : ""; append( " (" + installedVersion + availableVersion + ")", SimpleTextAttributes.GRAY_ATTRIBUTES); } } } }); entryTable .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { final int selectedRow = entryTable.getSelectedRow(); if (selectedRow != -1) { final PluginDownloader selection = getValueAt(selectedRow); final IdeaPluginDescriptor descriptor = selection.getDescriptor(); if (descriptor != null) { PluginManagerMain.pluginInfoUpdate( descriptor, null, myDescriptionPanel, myHeader, null); } } } }); setCheckboxColumnName(""); myDescriptionPanel.setPreferredSize(new Dimension(400, -1)); myDescriptionPanel.setEditable(false); myDescriptionPanel.setContentType(UIUtil.HTML_MIME); myDescriptionPanel.addHyperlinkListener(new PluginManagerMain.MyHyperlinkListener()); removeAll(); final Splitter splitter = new Splitter(false); splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(entryTable)); splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(myDescriptionPanel)); add(splitter, BorderLayout.CENTER); }
/** * Builds the chat window by adding all fields and buttons as well as making the window visible. * It also adds listeners to all the buttons and a listener so that the default close operation * becomes a method call. */ private void buildChatWindow() { Dimension chatWindowDimension = new Dimension(500, 400); Dimension writeAreDimensions = new Dimension(0, 83); JPanel mainPanel = new JPanel(new GridBagLayout()); JPanel extrasPanel = new JPanel(); JScrollPane scrollDisplayArea = new JScrollPane(); displayArea = new JTextPane(); JEditorPane writeMessageArea = new JEditorPane(); JButton sendTextButton = new JButton("Send"); JButton sendFileButton = new JButton("Send file"); displayTextDocument = displayArea.getDocument(); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); c.fill = GridBagConstraints.BOTH; c.gridwidth = 2; c.weightx = 1; c.weighty = 1; c.gridx = 0; c.gridy = 0; scrollDisplayArea.add(displayArea); scrollDisplayArea.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollDisplayArea.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); mainPanel.add(scrollDisplayArea, c); c.gridwidth = 1; c.weightx = 0; c.weighty = 0; c.gridx = 0; c.gridy = 1; extrasPanel.setBackground(new Color(96, 92, 95)); mainPanel.add(extrasPanel, c); c.gridx = 1; c.gridy = 1; mainPanel.add(sendFileButton, c); c.weightx = 1; c.weighty = 0; c.gridx = 0; c.gridy = 2; writeMessageArea.setPreferredSize(writeAreDimensions); mainPanel.add(writeMessageArea, c); c.weightx = 0; c.weighty = 0; c.gridx = 1; c.gridy = 2; mainPanel.add(sendTextButton, c); setPreferredSize(chatWindowDimension); add(mainPanel); pack(); setVisible(true); sendTextButton.addActionListener( e -> { // TODO add XML colors and shit System.out.println("ChatGUI: Sending message: " + writeMessageArea.getText()); chat.sendMessage(writeMessageArea.getText()); writeMessageArea.setText(""); }); sendFileButton.addActionListener( e -> { // TODO send a file System.out.println("ChatGUI: Is supposed to send a file"); }); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { closeChatWindowOperation(); } }); }
public void initializeMainView( final SuperAdapter superAdapter, Container contentPane, Dimension bigPanelDim, Dimension panelDim) { contentPane.setLayout(new BorderLayout()); final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); contentPane.add(mainPanel, BorderLayout.CENTER); mainPanel.setBackground(Color.white); final JPanel toolbarPanel = new JPanel(); toolbarPanel.setBorder(null); toolbarPanel.setLayout(new GridBagLayout()); mainPanel.add(toolbarPanel, BorderLayout.NORTH); JPanel bigPanel = new JPanel(); bigPanel.setLayout(new BorderLayout()); bigPanel.setBackground(Color.white); bigPanel.setPreferredSize(new Dimension(bigPanelDim)); bigPanel.setMaximumSize(new Dimension(bigPanelDim)); bigPanel.setMinimumSize(new Dimension(bigPanelDim)); JPanel bottomPanel = new JPanel(); bottomPanel.setBackground(Color.white); JMenuBar menuBar = null; try { menuBar = superAdapter.createMenuBar(); } catch (Exception e) { e.printStackTrace(); } assert menuBar != null; contentPane.add(menuBar, BorderLayout.NORTH); GridBagConstraints toolbarConstraints = new GridBagConstraints(); toolbarConstraints.anchor = GridBagConstraints.LINE_START; toolbarConstraints.fill = GridBagConstraints.HORIZONTAL; toolbarConstraints.gridx = 0; toolbarConstraints.gridy = 0; toolbarConstraints.weightx = 0.1; // --- Chromosome panel --- JPanel chrSelectionPanel = new JPanel(); toolbarPanel.add(chrSelectionPanel, toolbarConstraints); chrSelectionPanel.setBorder(LineBorder.createGrayLineBorder()); chrSelectionPanel.setLayout(new BorderLayout()); JPanel chrLabelPanel = new JPanel(); JLabel chrLabel = new JLabel("Chromosomes"); chrLabel.setHorizontalAlignment(SwingConstants.CENTER); chrLabelPanel.setBackground(HiCGlobals.backgroundColor); chrLabelPanel.setLayout(new BorderLayout()); chrLabelPanel.add(chrLabel, BorderLayout.CENTER); chrSelectionPanel.add(chrLabelPanel, BorderLayout.PAGE_START); JPanel chrButtonPanel = new JPanel(); chrButtonPanel.setBackground(new Color(238, 238, 238)); chrButtonPanel.setLayout(new BoxLayout(chrButtonPanel, BoxLayout.X_AXIS)); // ---- chrBox1 ---- chrBox1 = new JComboBox<Chromosome>(); chrBox1.setModel( new DefaultComboBoxModel<Chromosome>(new Chromosome[] {new Chromosome(0, "All", 0)})); chrBox1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { chrBox1ActionPerformed(e); } }); chrBox1.setPreferredSize(new Dimension(95, 70)); chrButtonPanel.add(chrBox1); // ---- chrBox2 ---- chrBox2 = new JComboBox<Chromosome>(); chrBox2.setModel( new DefaultComboBoxModel<Chromosome>(new Chromosome[] {new Chromosome(0, "All", 0)})); chrBox2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { chrBox2ActionPerformed(e); } }); chrBox2.setPreferredSize(new Dimension(95, 70)); chrButtonPanel.add(chrBox2); // ---- refreshButton ---- refreshButton = new JideButton(); refreshButton.setIcon( new ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Refresh24.gif"))); refreshButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { superAdapter.safeRefreshButtonActionPerformed(); } }); refreshButton.setPreferredSize(new Dimension(24, 24)); chrButtonPanel.add(refreshButton); chrBox1.setEnabled(false); chrBox2.setEnabled(false); refreshButton.setEnabled(false); chrSelectionPanel.add(chrButtonPanel, BorderLayout.CENTER); chrSelectionPanel.setMinimumSize(new Dimension(200, 70)); chrSelectionPanel.setPreferredSize(new Dimension(210, 70)); // ======== Display Option Panel ======== JPanel displayOptionPanel = new JPanel(); displayOptionPanel.setBackground(new Color(238, 238, 238)); displayOptionPanel.setBorder(LineBorder.createGrayLineBorder()); displayOptionPanel.setLayout(new BorderLayout()); JPanel displayOptionLabelPanel = new JPanel(); displayOptionLabelPanel.setBackground(HiCGlobals.backgroundColor); displayOptionLabelPanel.setLayout(new BorderLayout()); JLabel displayOptionLabel = new JLabel("Show"); displayOptionLabel.setHorizontalAlignment(SwingConstants.CENTER); displayOptionLabelPanel.add(displayOptionLabel, BorderLayout.CENTER); displayOptionPanel.add(displayOptionLabelPanel, BorderLayout.PAGE_START); JPanel displayOptionButtonPanel = new JPanel(); displayOptionButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 10)); displayOptionButtonPanel.setLayout(new GridLayout(1, 0, 20, 0)); displayOptionComboBox = new JComboBox<MatrixType>(); displayOptionComboBox.setModel( new DefaultComboBoxModel<MatrixType>(new MatrixType[] {MatrixType.OBSERVED})); displayOptionComboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { superAdapter.safeDisplayOptionComboBoxActionPerformed(); normalizationComboBox.setEnabled(!isWholeGenome()); } }); displayOptionButtonPanel.add(displayOptionComboBox); displayOptionPanel.add(displayOptionButtonPanel, BorderLayout.CENTER); displayOptionPanel.setMinimumSize(new Dimension(140, 70)); displayOptionPanel.setPreferredSize(new Dimension(140, 70)); displayOptionPanel.setMaximumSize(new Dimension(140, 70)); toolbarConstraints.gridx = 1; toolbarConstraints.weightx = 0.1; toolbarPanel.add(displayOptionPanel, toolbarConstraints); displayOptionComboBox.setEnabled(false); // ======== Normalization Panel ======== JPanel normalizationPanel = new JPanel(); normalizationPanel.setBackground(new Color(238, 238, 238)); normalizationPanel.setBorder(LineBorder.createGrayLineBorder()); normalizationPanel.setLayout(new BorderLayout()); JPanel normalizationLabelPanel = new JPanel(); normalizationLabelPanel.setBackground(HiCGlobals.backgroundColor); normalizationLabelPanel.setLayout(new BorderLayout()); JLabel normalizationLabel = new JLabel("Normalization"); normalizationLabel.setHorizontalAlignment(SwingConstants.CENTER); normalizationLabelPanel.add(normalizationLabel, BorderLayout.CENTER); normalizationPanel.add(normalizationLabelPanel, BorderLayout.PAGE_START); JPanel normalizationButtonPanel = new JPanel(); normalizationButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 10)); normalizationButtonPanel.setLayout(new GridLayout(1, 0, 20, 0)); normalizationComboBox = new JComboBox<String>(); normalizationComboBox.setModel( new DefaultComboBoxModel<String>(new String[] {NormalizationType.NONE.getLabel()})); normalizationComboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { superAdapter.safeNormalizationComboBoxActionPerformed(e); } }); normalizationButtonPanel.add(normalizationComboBox); normalizationPanel.add(normalizationButtonPanel, BorderLayout.CENTER); normalizationPanel.setPreferredSize(new Dimension(180, 70)); normalizationPanel.setMinimumSize(new Dimension(140, 70)); toolbarConstraints.gridx = 2; toolbarConstraints.weightx = 0.1; toolbarPanel.add(normalizationPanel, toolbarConstraints); normalizationComboBox.setEnabled(false); // ======== Resolution Panel ======== hiCPanel = new JPanel(); hiCPanel.setBackground(Color.white); hiCPanel.setLayout(new HiCLayout()); bigPanel.add(hiCPanel, BorderLayout.CENTER); JPanel wrapGapPanel = new JPanel(); wrapGapPanel.setBackground(Color.white); wrapGapPanel.setMaximumSize(new Dimension(5, 5)); wrapGapPanel.setMinimumSize(new Dimension(5, 5)); wrapGapPanel.setPreferredSize(new Dimension(5, 5)); wrapGapPanel.setBorder(LineBorder.createBlackLineBorder()); bigPanel.add(wrapGapPanel, BorderLayout.EAST); // splitPanel.insertPane(hiCPanel, 0); // splitPanel.setBackground(Color.white); // ---- rulerPanel2 ---- JPanel topPanel = new JPanel(); topPanel.setBackground(Color.green); topPanel.setLayout(new BorderLayout()); hiCPanel.add(topPanel, BorderLayout.NORTH); trackLabelPanel = new TrackLabelPanel(superAdapter.getHiC()); trackLabelPanel.setBackground(Color.white); hiCPanel.add(trackLabelPanel, HiCLayout.NORTH_WEST); trackPanelX = new TrackPanel(superAdapter, superAdapter.getHiC(), TrackPanel.Orientation.X); trackPanelX.setMaximumSize(new Dimension(4000, 50)); trackPanelX.setPreferredSize(new Dimension(1, 50)); trackPanelX.setMinimumSize(new Dimension(1, 50)); trackPanelX.setVisible(false); topPanel.add(trackPanelX, BorderLayout.NORTH); rulerPanelX = new HiCRulerPanel(superAdapter.getHiC()); rulerPanelX.setMaximumSize(new Dimension(4000, 50)); rulerPanelX.setMinimumSize(new Dimension(1, 50)); rulerPanelX.setPreferredSize(new Dimension(1, 50)); rulerPanelX.setBorder(null); topPanel.add(rulerPanelX, BorderLayout.SOUTH); // ---- rulerPanel1 ---- JPanel leftPanel = new JPanel(); leftPanel.setBackground(Color.white); leftPanel.setLayout(new BorderLayout()); hiCPanel.add(leftPanel, BorderLayout.WEST); trackPanelY = new TrackPanel(superAdapter, superAdapter.getHiC(), TrackPanel.Orientation.Y); trackPanelY.setMaximumSize(new Dimension(50, 4000)); trackPanelY.setPreferredSize(new Dimension(50, 1)); trackPanelY.setMinimumSize(new Dimension(50, 1)); trackPanelY.setVisible(false); leftPanel.add(trackPanelY, BorderLayout.WEST); rulerPanelY = new HiCRulerPanel(superAdapter.getHiC()); rulerPanelY.setMaximumSize(new Dimension(50, 4000)); rulerPanelY.setPreferredSize(new Dimension(50, 800)); rulerPanelY.setBorder(null); rulerPanelY.setMinimumSize(new Dimension(50, 1)); leftPanel.add(rulerPanelY, BorderLayout.EAST); // ---- heatmapPanel ---- // Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); // int panelSize = screenDimension.height - 210; int panelWidth = (int) panelDim.getWidth(); int panelHeight = (int) panelDim.getHeight(); System.err.println("Window W: " + panelWidth + " H" + panelHeight); JPanel wrapHeatmapPanel = new JPanel(new BorderLayout()); wrapHeatmapPanel.setMaximumSize(new Dimension(panelDim)); wrapHeatmapPanel.setMinimumSize(new Dimension(panelDim)); wrapHeatmapPanel.setPreferredSize(new Dimension(panelDim)); wrapHeatmapPanel.setBackground(Color.BLUE); wrapHeatmapPanel.setVisible(true); heatmapPanel = new HeatmapPanel(superAdapter); heatmapPanel.setMaximumSize(new Dimension(panelWidth - 5, panelHeight - 5)); heatmapPanel.setMinimumSize(new Dimension(panelWidth - 5, panelHeight - 5)); heatmapPanel.setPreferredSize(new Dimension(panelWidth - 5, panelHeight - 5)); heatmapPanel.setBackground(Color.white); wrapHeatmapPanel.add(heatmapPanel, BorderLayout.CENTER); // hiCPanel.setMaximumSize(new Dimension(panelWidth, panelHeight)); // hiCPanel.setMinimumSize(new Dimension(panelWidth, panelHeight)); // hiCPanel.setPreferredSize(new Dimension(panelWidth, panelHeight)); hiCPanel.add(wrapHeatmapPanel, BorderLayout.CENTER); // ======== Resolution Slider Panel ======== // Resolution panel resolutionSlider = new ResolutionControl(superAdapter); resolutionSlider.setPreferredSize(new Dimension(200, 70)); resolutionSlider.setMinimumSize(new Dimension(150, 70)); toolbarConstraints.gridx = 3; toolbarConstraints.weightx = 0.1; toolbarPanel.add(resolutionSlider, toolbarConstraints); // ======== Color Range Panel ======== colorRangePanel = new JColorRangePanel(superAdapter, heatmapPanel, preDefMapColor); toolbarConstraints.gridx = 4; toolbarConstraints.weightx = 0.5; toolbarPanel.add(colorRangePanel, toolbarConstraints); goPanel = new GoToPanel(superAdapter); toolbarConstraints.gridx = 5; toolbarConstraints.weightx = 0.25; toolbarPanel.add(goPanel, toolbarConstraints); // not sure this is working // toolbarPanel.setPreferredSize(new Dimension(panelHeight,100)); toolbarPanel.setEnabled(false); // ======== Right side panel ======== JPanel rightSidePanel = new JPanel(new BorderLayout()); // (new BorderLayout()); rightSidePanel.setBackground(Color.white); rightSidePanel.setPreferredSize(new Dimension(210, 1000)); rightSidePanel.setMaximumSize(new Dimension(10000, 10000)); // ======== Bird's view mini map ======== JPanel thumbPanel = new JPanel(); thumbPanel.setLayout(new BorderLayout()); // ---- thumbnailPanel ---- thumbnailPanel = new ThumbnailPanel(superAdapter); thumbnailPanel.setBackground(Color.white); thumbnailPanel.setMaximumSize(new Dimension(210, 210)); thumbnailPanel.setMinimumSize(new Dimension(210, 210)); thumbnailPanel.setPreferredSize(new Dimension(210, 210)); // JPanel gapPanel = new JPanel(); // gapPanel.setMaximumSize(new Dimension(1, 1)); // rightSidePanel.add(gapPanel,BorderLayout.WEST); thumbPanel.add(thumbnailPanel, BorderLayout.CENTER); thumbPanel.setBackground(Color.white); rightSidePanel.add(thumbPanel, BorderLayout.NORTH); // ========= mouse hover text ====== JPanel tooltipPanel = new JPanel(new BorderLayout()); tooltipPanel.setBackground(Color.white); tooltipPanel.setPreferredSize(new Dimension(210, 490)); mouseHoverTextPanel = new JEditorPane(); mouseHoverTextPanel.setEditable(false); mouseHoverTextPanel.setContentType("text/html"); mouseHoverTextPanel.setFont(new Font("sans-serif", 0, 20)); mouseHoverTextPanel.setBackground(Color.white); mouseHoverTextPanel.setBorder(null); int mouseTextY = rightSidePanel.getBounds().y + rightSidePanel.getBounds().height; // *Dimension prefSize = new Dimension(210, 490); Dimension prefSize = new Dimension(210, 390); mouseHoverTextPanel.setPreferredSize(prefSize); JScrollPane tooltipScroller = new JScrollPane(mouseHoverTextPanel); tooltipScroller.setBackground(Color.white); tooltipScroller.setBorder(null); tooltipPanel.setPreferredSize(new Dimension(210, 500)); tooltipPanel.add(tooltipScroller); tooltipPanel.setBounds(new Rectangle(new Point(0, mouseTextY), prefSize)); tooltipPanel.setBackground(Color.white); tooltipPanel.setBorder(null); rightSidePanel.add(tooltipPanel, BorderLayout.CENTER); // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < rightSidePanel.getComponentCount(); i++) { Rectangle bounds = rightSidePanel.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = rightSidePanel.getInsets(); preferredSize.width += insets.right + 20; preferredSize.height += insets.bottom; rightSidePanel.setMinimumSize(preferredSize); rightSidePanel.setPreferredSize(preferredSize); mainPanel.add(bigPanel, BorderLayout.CENTER); mainPanel.add(rightSidePanel, BorderLayout.EAST); }
/** Construct a new Help panel */ public HelpPanel() { // Try to build our help tree, keeping an eye out for malformed URLs try { // root node top = new DefaultMutableTreeNode(new HelpItem("MIDIMatrix", "top")); // matrices node category = new DefaultMutableTreeNode(new HelpItem("Matrices", "matrices")); top.add(category); category.add(new DefaultMutableTreeNode(new HelpItem("Note Entry", "matrices-noteentry"))); category.add( new DefaultMutableTreeNode( new HelpItem("Pitches, volume, and instruments", "matrices-metadata"))); category.add(new DefaultMutableTreeNode(new HelpItem("Playback", "matrices-playback"))); // sequences node category = new DefaultMutableTreeNode(new HelpItem("Sequences", "sequences")); top.add(category); category.add( new DefaultMutableTreeNode(new HelpItem("Parts of a sequence", "sequences-parts"))); category.add( new DefaultMutableTreeNode( new HelpItem("Constructing a sequence", "sequences-construction"))); category.add(new DefaultMutableTreeNode(new HelpItem("Playback", "sequences-playback"))); // controls node category = new DefaultMutableTreeNode(new HelpItem("Controls", "controls")); top.add(category); category.add( new DefaultMutableTreeNode(new HelpItem("MIDI devices", "controls-mididevices"))); category.add(new DefaultMutableTreeNode(new HelpItem("Saving", "controls-saving"))); // about node category = new DefaultMutableTreeNode(new HelpItem("About", "about")); top.add(category); category.add(new DefaultMutableTreeNode(new HelpItem("Author", "about-author"))); category.add(new DefaultMutableTreeNode(new HelpItem("License", "about-license"))); // javadoc node // category = new DefaultMutableTreeNode(new HelpItem("JavaDoc", base + "javadoc/")); // top.add(category); } catch (MalformedURLException e) { top = new DefaultMutableTreeNode("ERROR"); } helpTree = new JTree(top); helpTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); helpTree.addTreeSelectionListener( new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) helpTree.getLastSelectedPathComponent(); if (node == null) { return; } // try { helpPane.scrollToReference(((HelpItem) node.getUserObject()).getHash()); /*} catch (IOException exc) { JOptionPane.showMessageDialog( null, "There was a problem fetching the help page " + exc.getMessage() + "\n" + "Make sure you're connected to the internet before continuing", "Help Oops!", JOptionPane.ERROR_MESSAGE, null); }*/ } }); treePane = new JScrollPane(helpTree); treePane.setPreferredSize(new Dimension(200, 750)); helpPane = new JEditorPane(); scroller = new JScrollPane(helpPane); helpPane.setEditable(false); helpPane.setPreferredSize(new Dimension(550, 750)); helpPane.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane pane = (JEditorPane) e.getSource(); if (e instanceof HTMLFrameHyperlinkEvent) { HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e; HTMLDocument doc = (HTMLDocument) pane.getDocument(); doc.processHTMLFrameHyperlinkEvent(evt); if (e.getDescription().indexOf("#") != -1) { System.err.println("Found anchor"); pane.scrollToReference( e.getDescription().substring(e.getDescription().indexOf("#"))); } } else { try { pane.setPage(e.getURL()); } catch (Throwable t) { t.printStackTrace(); } } } } }); try { helpPane.setPage(HelpPanel.class.getResource("help.xhtml")); } catch (IOException e) { helpPane.setText("Couldn't fetch help page, sorry! " + e.getMessage()); } content = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); content.add(treePane); content.add(scroller); add(content); }