/** {@inheritDoc} */ public void setEnabled(boolean b) { if (b != isEnabled()) { super.setEnabled(b); if ((selectedComponents & DISPLAY_DATE) > 0) { yearDecrButton.setEnabled(b); monthDecrButton.setEnabled(b); monthYearLabel.setEnabled(b); monthIncrButton.setEnabled(b); yearIncrButton.setEnabled(b); for (int day = 0; day < 7; day++) { dayOfWeekLabels[day].setEnabled(b); } for (int row = 0; row < 6; row++) { for (int day = 0; day < 7; day++) { if (dayButtons[row][day].getText().length() > 0) { dayButtons[row][day].setEnabled(b); } } } } if ((selectedComponents & DISPLAY_TIME) > 0) { spinner.setEnabled(b); } } }
private void setComponentsEnabled(boolean enabled) { list.setEnabled(enabled); process.setEnabled(enabled); remove.setEnabled(enabled); xres.setEnabled(enabled); yres.setEnabled(enabled); aspect.setEnabled(enabled); boolean b = aspect.isSelected() && enabled; colorLabel.setEnabled(b); colorBox.setEnabled(b); redLabel.setEnabled(b); red.setEnabled(b); redValue.setEnabled(b); greenLabel.setEnabled(b); green.setEnabled(b); greenValue.setEnabled(b); blueLabel.setEnabled(b); blue.setEnabled(b); blueValue.setEnabled(b); format.setEnabled(enabled); algorithm.setEnabled(enabled); prepend.setEnabled(enabled); append.setEnabled(enabled); output.setEnabled(enabled); }
public void setEnabled(boolean enabled) { super.setEnabled(enabled); if (myToggleHistoryLabel != null) { final Color bg = enabled ? UIUtil.getTextFieldBackground() : UIUtil.getPanelBackground(); myToggleHistoryLabel.setBackground(bg); myClearFieldLabel.setBackground(bg); } }
/** * Enable or disable the JCalendar. * * @param enabled the new enabled value */ public void setEnabled(boolean enabled) { super.setEnabled(enabled); if (dayChooser != null) { dayChooser.setEnabled(enabled); monthChooser.setEnabled(enabled); yearChooser.setEnabled(enabled); } }
/** * As per the JPanle superclass setEnabled method. Also calls the setEnabled method of the text * area, load button, clear button and organize button on this panel. * * @param enable Whether to enable or disable this panel and its components. */ public void setEnabled(boolean enable) { super.setEnabled(enable); text_area.setEnabled(enable); load_button.setEnabled(enable); save_button.setEnabled(enable); clear_button.setEnabled(enable); organize_button.setEnabled(enable); }
public void setEnabled(boolean enabled) { super.setEnabled(enabled); myTable.setRowSelectionAllowed(enabled); myTableModel.fireTableDataChanged(); }
/** * Does Nothing * * @param selected, true to enable, false to disable. */ public void setNodeOrLinkSelected(boolean selected) { if (tbrToolBar != null) { UIViewFrame frame = ProjectCompendium.APP.getCurrentFrame(); if (selected && frame instanceof UIMapViewFrame) { UIMapViewFrame oMapFrame = (UIMapViewFrame) frame; UIViewPane pane = oMapFrame.getViewPane(); int nLinkCount = pane.getNumberOfSelectedLinks(); if (nLinkCount == 0) return; bJustSetting = true; int i = 0; UILink link = null; LinkProperties linkProps = null; boolean bDefaultLinkStyle = false; boolean bDefaultLinkDashed = false; boolean bDefaultLinkWeight = false; boolean bDefaultLinkColour = false; boolean bDefaultArrowType = false; LinkProperties defaultprops = UIUtilities.getLinkProperties(""); int linkstyle = defaultprops.getLinkStyle(); int linkdashed = defaultprops.getLinkDashed(); int linkweight = defaultprops.getLinkWeight(); int linkcolour = defaultprops.getLinkColour(); int arrowtype = defaultprops.getArrowType(); for (Enumeration e = pane.getSelectedLinks(); e.hasMoreElements(); ) { link = (UILink) e.nextElement(); linkProps = link.getLinkProperties(); if (i == 0) { linkstyle = linkProps.getLinkStyle(); linkdashed = linkProps.getLinkDashed(); linkweight = linkProps.getLinkWeight(); linkcolour = linkProps.getLinkColour(); arrowtype = linkProps.getArrowType(); i++; } else { if (arrowtype != linkProps.getArrowType()) { bDefaultArrowType = true; } if (linkstyle != linkProps.getLinkStyle()) { bDefaultLinkStyle = true; } if (linkdashed != linkProps.getLinkDashed()) { bDefaultLinkDashed = true; } if (linkweight != linkProps.getLinkWeight()) { bDefaultLinkWeight = true; } if (linkcolour != linkProps.getLinkColour()) { bDefaultLinkColour = true; } } } tbrToolBar.setEnabled(true); if (bDefaultLinkColour) { selectedLinkColour = new Color(defaultprops.getLinkColour()); } else { selectedLinkColour = new Color(linkcolour); } linkColourPanel.setEnabled(true); txtLinkColour.setEnabled(true); cbLineWeight.setEnabled(true); if (bDefaultLinkWeight) { cbLineWeight.setSelectedIndex(defaultprops.getLinkWeight() - 1); } else { cbLineWeight.setSelectedIndex(linkweight - 1); } cbArrows.setEnabled(true); if (bDefaultArrowType) { cbArrows.setSelectedIndex(defaultprops.getArrowType()); } else { cbArrows.setSelectedIndex(arrowtype); } cbLinkStyle.setEnabled(true); if (bDefaultLinkStyle) { cbLinkStyle.setSelectedIndex(defaultprops.getLinkStyle()); } else { cbLinkStyle.setSelectedIndex(linkstyle); } cbLinkDashed.setEnabled(true); if (bDefaultLinkDashed) { cbLinkDashed.setSelectedIndex(defaultprops.getLinkDashed()); } else { cbLinkDashed.setSelectedIndex(linkdashed); } bJustSetting = false; } else if (!selected) { bJustSetting = true; linkColourPanel.setEnabled(false); txtLinkColour.setEnabled(false); tbrToolBar.setEnabled(false); cbArrows.setEnabled(false); cbLineWeight.setEnabled(false); cbLinkStyle.setEnabled(false); cbLinkDashed.setEnabled(false); bJustSetting = false; } } }
public void setEnabled(boolean enabled) { super.setEnabled(enabled); setButtonEnabled(ADD, enabled); // disable all the buttons ??? }
public ODEWizardScalaSci() { editingClassName = "Lorenz"; systemOrder = 3; // the order of ODE system copyTemplateButton = new JButton("1. Copy and Edit Template", new ImageIcon("/scalaLab.jar/yellow-ball.gif")); generateEditingButton = new JButton("2. Generate Java Class", new ImageIcon("./blue-ball.gif")); saveJavaClassButton = new JButton("3. Save Java Class", new ImageIcon("scalaLab.jar/red-ball.gif")); compileJavaClassButton = new JButton("4.a. Java Compile - External Compiler", new ImageIcon("blue-ball.gif")); compileJavaInternalCompilerButton = new JButton("4.b. Java Compile - Internal Compiler", new ImageIcon("blue-ball.gif")); generateScriptCodeButton = new JButton("Generate scalaSci Script", new ImageIcon("red-ball.gif")); ODEWizardFrame = new JFrame("ODE Wizard for scalaSci with Java implementation of. ODEs"); editPanel = new JPanel(); editPanel.setLayout(new GridLayout(1, 2)); paramPanel = new JPanel(new GridLayout(1, 4)); availODEMethods.add("ODErke"); availODEMethods.add("ODEmultistep"); availODEMethods.add("ODEdiffsys"); ODEselectMethodLabel = new JLabel("ODE method: "); ODEselectMethodComboBox = new JComboBox(availODEMethods); ODEselectMethodComboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ODESolveMethod = ODEselectMethodComboBox.getSelectedIndex(); updateTemplateText(); templateTextArea.setText(templateText); currentlySelectedLabel.setText( "Selected Method: " + (String) availODEMethods.get(ODESolveMethod)); } }); JLabel javaFileTextLabel = new JLabel("Java File Name: "); javaFileTextBox = new JTextField(editingClassName); javaFileTextBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { editingClassName = javaFileTextBox.getText(); String updatedStatusText = prepareStatusText(); statusAreaTop.setText(updatedStatusText); } }); JLabel systemOrderLabel = new JLabel("System order: "); systemOrderText = new JTextField(String.valueOf(systemOrder)); systemOrderText.addActionListener(new editSystemOrder()); JPanel javaFilePanel = new JPanel(); javaFilePanel.add(javaFileTextLabel); javaFilePanel.add(javaFileTextBox); JPanel systemOrderPanel = new JPanel(); systemOrderPanel.add(systemOrderLabel); systemOrderPanel.add(systemOrderText); paramMethodPanel = new JPanel(); paramMethodPanel.add(ODEselectMethodLabel); paramMethodPanel.add(ODEselectMethodComboBox); paramPanel.add(paramMethodPanel); paramPanel.add(javaFilePanel); paramPanel.add(systemOrderPanel); currentlySelectedLabel = new JLabel("Selected Method: " + (String) availODEMethods.get(ODESolveMethod)); paramPanel.add(currentlySelectedLabel); statusPanel = new JPanel(new GridLayout(2, 1)); statusAreaTop = new JTextArea(); statusAreaTop.setFont(new Font("Arial", Font.BOLD, 16)); String statusText = prepareStatusText(); statusAreaTop.setText(statusText); statusAreaBottom = new JTextArea(); statusAreaBottom.setText( "Step1: Copy and edit the template ODE (implements the famous Lorenz chaotic system),\n" + "Then set the name of your Java Class (instead of \"Lorenz\"), without the extension .java\n" + "Also set the proper order (i.e. number of equations and variables) of your system. "); statusPanel.add(statusAreaTop); statusPanel.add(statusAreaBottom); templateTextArea = new JTextArea(); updateTemplateText(); templateTextArea.setFont(new Font("Arial", Font.ITALIC, 12)); templateTextArea.setText(templateText); templateScrollPane = new JScrollPane(); templateViewPort = templateScrollPane.getViewport(); templateViewPort.add(templateTextArea); ODEWizardTextArea = new JTextArea(); ODEWizardText = ""; ODEWizardTextArea.setText(ODEWizardText); ODEWizardTextArea.setFont(new Font("Arial", Font.BOLD, 12)); ODEWizardScrollPane = new JScrollPane(); wizardViewPort = ODEWizardScrollPane.getViewport(); wizardViewPort.add(ODEWizardTextArea); editPanel.add(ODEWizardScrollPane); editPanel.add(templateScrollPane); // Step 1: copy template of ODE implementation from the // templateTextArea to ODEWizardTextArea copyTemplateButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ODEWizardTextArea.setText(templateTextArea.getText()); generateEditingButton.setEnabled(true); statusAreaBottom.setText( "Step2: If you have implemented correctly your ODE, the wizard completes the ready to compile Java class"); } }); // Step 2: generate Java Class from template JPanel buttonPanel = new JPanel(); generateEditingButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String editingODE = ODEWizardTextArea.getText(); String classImplementationString = // "package javaPluggins; \n"+ "import numal.*; \n\n" + "public class " + editingClassName + " extends Object \n implements " + implementingInterfaces[ODESolveMethod] + " \n \n " + "{ \n"; classImplementationString += (editingODE + "}\n"); ODEWizardTextArea.setText(classImplementationString); saveJavaClassButton.setEnabled(true); statusAreaBottom.setText( "Step3: The generated Java source is ready, you can check it, and then proceed to save."); } }); // Step 3: save generated Java Class on disk saveJavaClassButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String currentWorkingDirectory = Directory.Current().get().path(); JFileChooser chooser = new JFileChooser(currentWorkingDirectory); chooser.setSelectedFile(new File(editingClassName + ".java")); int ret = chooser.showSaveDialog(ODEWizardFrame); if (ret != JFileChooser.APPROVE_OPTION) { return; } File f = chooser.getSelectedFile(); try { PrintWriter out = new PrintWriter(f); String javaCodeText = ODEWizardTextArea.getText(); out.write(javaCodeText); out.close(); // update the notion of the working directory String fullPathOfSavedFile = f.getAbsolutePath(); GlobalValues.workingDir = fullPathOfSavedFile.substring( 0, fullPathOfSavedFile.lastIndexOf(File.separatorChar) + 1); compileJavaClassButton.setEnabled(true); compileJavaInternalCompilerButton.setEnabled(true); statusAreaBottom.setText( "Step4: The Java source file was saved to disk, \n " + "you can proceed to compile and load the corresponding class file"); } catch (java.io.FileNotFoundException enf) { System.out.println("File " + f.getName() + " not found"); enf.printStackTrace(); } catch (Exception eOther) { System.out.println("Exception trying to create PrintWriter"); eOther.printStackTrace(); } } }); // Step 4: Compile the generated Java class compileJavaClassButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String currentWorkingDirectory = GlobalValues.workingDir; JFileChooser chooser = new JFileChooser(currentWorkingDirectory); int ret = chooser.showOpenDialog(ODEWizardFrame); if (ret != JFileChooser.APPROVE_OPTION) { return; } File f = chooser.getSelectedFile(); String javaFile = null; try { javaFile = f.getCanonicalPath(); } catch (IOException ex) { System.out.println("I/O Exception in getCanonicalPath"); ex.printStackTrace(); } // extract the path specification of the generated Java class that implements the ODE // solution method, // in order to update the ScalaSci class path String SelectedFileWithPath = f.getAbsolutePath(); String SelectedFilePathOnly = SelectedFileWithPath.substring( 0, SelectedFileWithPath.lastIndexOf(File.separatorChar)); if (GlobalValues.ScalaSciClassPath.length() == 0) GlobalValues.ScalaSciClassPath = "."; if (GlobalValues.ScalaSciClassPath.indexOf(SelectedFilePathOnly) == -1) { GlobalValues.ScalaSciClassPathComponents.add(0, SelectedFilePathOnly); GlobalValues.ScalaSciClassPath = GlobalValues.ScalaSciClassPath + File.pathSeparator + SelectedFilePathOnly; } // update also the ScalaSciClassPath property StringBuilder fileStr = new StringBuilder(); Enumeration enumDirs = GlobalValues.ScalaSciClassPathComponents.elements(); while (enumDirs.hasMoreElements()) { Object ce = enumDirs.nextElement(); fileStr.append(File.pathSeparator + (String) ce); } GlobalValues.settings.setProperty("ScalaSciClassPath", fileStr.toString()); ClassLoader parentClassLoader = getClass().getClassLoader(); GlobalValues.extensionClassLoader = new ExtensionClassLoader(GlobalValues.ScalaSciClassPath, parentClassLoader); // update GUI components to account for the updated ScalaSci classpath scalaExec.scalaLab.scalaLab.updateTree(); boolean compilationSucccess = true; String tempFileName = ""; tempFileName = javaFile + ".java"; // public classes and Java files should have the same name String[] command = new String[6]; command[0] = "javac"; command[1] = "-cp"; command[2] = GlobalValues.jarFilePath + File.pathSeparator + GlobalValues.homeDir; command[3] = "-d"; // where to place output class files command[4] = SelectedFilePathOnly; // the path to save the compiled class files command[5] = javaFile; // full filename to compile String compileCommandString = command[0] + " " + command[1] + " " + command[2] + " " + command[3] + " " + command[4] + " " + command[5]; System.out.println("compileCommand Java= " + compileCommandString); try { Runtime rt = Runtime.getRuntime(); Process javaProcess = rt.exec(command); // an error message? StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR"); // any output? StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT"); // kick them off errorGobbler.start(); outputGobbler.start(); // any error??? javaProcess.waitFor(); int rv = javaProcess.exitValue(); String commandString = command[0] + " " + command[1] + " " + command[2]; if (rv == 0) { System.out.println("Process: " + commandString + " exited successfully "); generateScriptCodeButton.setEnabled(true); statusAreaBottom.setText( "Step5: You can proceed now to create a draft script that utilizes your Java-based ODE integrator"); } else System.out.println( "Process: " + commandString + " exited with error, error value = " + rv); } catch (IOException exio) { System.out.println("IOException trying to executing " + command); exio.printStackTrace(); } catch (InterruptedException ie) { System.out.println("Interrupted Exception trying to executing " + command); ie.printStackTrace(); } } }); // Compile with the internal compiler compileJavaInternalCompilerButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String currentWorkingDirectory = GlobalValues.workingDir; JFileChooser chooser = new JFileChooser(currentWorkingDirectory); int ret = chooser.showOpenDialog(ODEWizardFrame); if (ret != JFileChooser.APPROVE_OPTION) { return; } File f = chooser.getSelectedFile(); String javaFile = null; try { javaFile = f.getCanonicalPath(); } catch (IOException ex) { System.out.println("I/O Exception in getCanonicalPath"); ex.printStackTrace(); } // extract the path specification of the generated Java class that implements the ODE // solution method, // in order to update the ScalaSci class path String SelectedFileWithPath = f.getAbsolutePath(); String SelectedFilePathOnly = SelectedFileWithPath.substring( 0, SelectedFileWithPath.lastIndexOf(File.separatorChar)); if (GlobalValues.ScalaSciClassPath.length() == 0) GlobalValues.ScalaSciClassPath = "."; if (GlobalValues.ScalaSciClassPath.indexOf(SelectedFilePathOnly) == -1) { GlobalValues.ScalaSciClassPathComponents.add(0, SelectedFilePathOnly); GlobalValues.ScalaSciClassPath = GlobalValues.ScalaSciClassPath + File.pathSeparator + SelectedFilePathOnly; } // update also the ScalaSciClassPath property StringBuilder fileStr = new StringBuilder(); Enumeration enumDirs = GlobalValues.ScalaSciClassPathComponents.elements(); while (enumDirs.hasMoreElements()) { Object ce = enumDirs.nextElement(); fileStr.append(File.pathSeparator + (String) ce); } GlobalValues.settings.setProperty("ScalaSciClassPath", fileStr.toString()); ClassLoader parentClassLoader = getClass().getClassLoader(); GlobalValues.extensionClassLoader = new ExtensionClassLoader(GlobalValues.ScalaSciClassPath, parentClassLoader); // update GUI components to account for the updated ScalaSci classpath scalaExec.scalaLab.scalaLab.updateTree(); String[] command = new String[11]; String toolboxes = ""; for (int k = 0; k < GlobalValues.ScalaSciClassPathComponents.size(); k++) toolboxes = toolboxes + File.pathSeparator + GlobalValues.ScalaSciClassPathComponents.elementAt(k); // compile the temporary file command[0] = "java"; command[1] = "-classpath"; command[2] = "." + File.pathSeparator + GlobalValues.jarFilePath + File.pathSeparator + toolboxes + File.pathSeparator + SelectedFilePathOnly; command[3] = "com.sun.tools.javac.Main"; // the name of the Java compiler class command[4] = "-classpath"; command[5] = command[2]; command[6] = "-sourcepath"; command[7] = command[2]; command[8] = "-d"; // where to place output class files command[9] = SelectedFilePathOnly; command[10] = SelectedFileWithPath; String compileCommandString = command[0] + " " + command[1] + " " + command[2] + " " + command[3] + " " + command[4] + " " + command[5] + " " + command[6] + " " + command[7] + " " + command[8] + " " + command[9] + " " + command[10]; System.out.println("compileCommand Java= " + compileCommandString); try { Runtime rt = Runtime.getRuntime(); Process javaProcess = rt.exec(command); // an error message? StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR"); // any output? StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT"); // kick them off errorGobbler.start(); outputGobbler.start(); // any error??? javaProcess.waitFor(); int rv = javaProcess.exitValue(); if (rv == 0) { System.out.println("Process: exited successfully "); JavaCompile javaCompileObj = null; try { javaCompileObj = new JavaCompile(); } catch (Exception ex) { JOptionPane.showMessageDialog( null, "Unable to compile. Please check if your system's PATH variable includes the path to your javac compiler", "Cannot compile - Check PATH", JOptionPane.INFORMATION_MESSAGE); ex.printStackTrace(); } generateScriptCodeButton.setEnabled(true); statusAreaBottom.setText( "Step5: You can proceed now to create a draft ScalaSci-Script that utilizes your Java-based ODE integrator"); } else System.out.println("Process: exited with error, error value = " + rv); } catch (IOException exio) { System.out.println("IOException trying to executing " + command); exio.printStackTrace(); } catch (InterruptedException ie) { System.out.println("Interrupted Exception trying to executing " + command); ie.printStackTrace(); } } }); // Step 5: Generate Script Code generateScriptCodeButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new scriptCodeGenerationFrame("ODE Script code", editingClassName, systemOrder); } }); buttonPanel.add(copyTemplateButton); // Step 1 buttonPanel.setEnabled(true); buttonPanel.add(generateEditingButton); // Step 2 generateEditingButton.setEnabled(false); buttonPanel.add(saveJavaClassButton); // Step 3 saveJavaClassButton.setEnabled(false); buttonPanel.add(compileJavaClassButton); // Step 4 buttonPanel.add(compileJavaInternalCompilerButton); compileJavaClassButton.setEnabled(false); compileJavaInternalCompilerButton.setEnabled(false); buttonPanel.add(generateScriptCodeButton); // Step 5 generateScriptCodeButton.setEnabled(false); ODEWizardFrame.add(buttonPanel, BorderLayout.NORTH); ODEWizardFrame.add(editPanel, BorderLayout.CENTER); JPanel bottomPanel = new JPanel(new GridLayout(2, 1)); bottomPanel.add(paramPanel); bottomPanel.add(statusPanel); ODEWizardFrame.add(bottomPanel, BorderLayout.SOUTH); ODEWizardFrame.setLocation(100, 100); ODEWizardFrame.setSize(1400, 800); ODEWizardFrame.setVisible(true); }
public void setActive(boolean _active) { activeEditor = _active; changed = true; firstButtonPanel.setEnabled(_active); firstButton.setEnabled(_active); }
private void setupUI() { JPanel batchInputPanel = new JPanel(); batchInputPanel.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1)); batchInputPanel.setEnabled(true); this.add( batchInputPanel, new GridConstraints( 2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); batchInputPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null)); final Spacer spacer3 = new Spacer(); batchInputPanel.add( spacer3, new GridConstraints( 6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(195, 14), null, 0, false)); dpiXLabel = new JLabel("DPI X: "); batchInputPanel.add( dpiXLabel, new GridConstraints( 2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(195, 16), null, 0, false)); dpiYLabel = new JLabel("DPI Y: "); batchInputPanel.add( dpiYLabel, new GridConstraints( 3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(195, 16), null, 0, false)); startDepthLabel = new JLabel("Start Depth (meter): "); batchInputPanel.add( startDepthLabel, new GridConstraints( 4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(195, 16), null, 0, false)); depthIncLabel = new JLabel("Depth Increment (meter): "); batchInputPanel.add( depthIncLabel, new GridConstraints( 5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(195, 16), null, 0, false)); dpiXField = new JTextField(); dpiXField.setEnabled(false); dpiXField.setHorizontalAlignment(11); dpiYField = new JTextField(); dpiYField.setEnabled(false); dpiYField.setHorizontalAlignment(11); batchInputPanel.add( dpiXField, new GridConstraints( 2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); batchInputPanel.add( dpiYField, new GridConstraints( 3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); startDepthField = new JTextField(); startDepthField.setEnabled(false); startDepthField.setHorizontalAlignment(11); batchInputPanel.add( startDepthField, new GridConstraints( 4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); depthIncField = new JTextField(); depthIncField.setEnabled(false); depthIncField.setHorizontalAlignment(11); batchInputPanel.add( depthIncField, new GridConstraints( 5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); final JPanel applyPanel = new JPanel(); applyPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); batchInputPanel.add( applyPanel, new GridConstraints( 6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); applyToAllButton = new JButton("Apply to All Rows"); applyToAllButton.setEnabled(false); applyPanel.add( applyToAllButton, new GridConstraints( 0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); applyToSelectedButton = new JButton("Apply to Selected Rows"); applyToSelectedButton.setEnabled(false); applyPanel.add( applyToSelectedButton, new GridConstraints( 0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); // final Spacer spacer4 = new Spacer(); // applyPanel.add(spacer4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, // GridConstraints.FILL_HORIZONTAL, // GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); orientationComboBox = new JComboBox(); orientationComboBox.setEnabled(false); final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); defaultComboBoxModel1.addElement("Horizontal"); defaultComboBoxModel1.addElement("Vertical"); defaultComboBoxModel1.addElement("[Blank]"); orientationComboBox.setModel(defaultComboBoxModel1); orientationComboBox.setSelectedIndex(2); // [Blank] batchInputPanel.add( orientationComboBox, new GridConstraints( 0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); lengthLabel = new JLabel("Length (meter): "); batchInputPanel.add( lengthLabel, new GridConstraints( 1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); lengthField = new JTextField(); lengthField.setEnabled(false); lengthField.setHorizontalAlignment(11); batchInputPanel.add( lengthField, new GridConstraints( 1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); orientationLabel = new JLabel("Orientation: "); batchInputPanel.add( orientationLabel, new GridConstraints( 0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(195, 16), null, 0, false)); useBatchInputCheckbox = new JCheckBox(); useBatchInputCheckbox.setText("Batch input: blank fields will not be applied"); this.add( useBatchInputCheckbox, new GridConstraints( 1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); onBatch(); }
public void setEnabled(boolean enabled) { super.setEnabled(enabled); positionChrTop.setEnabled(enabled); positionChrLeft.setEnabled(enabled); goButton.setEnabled(enabled); }
/** Called for button presses and checkbox toggles. */ public void actionPerformed(ActionEvent e) { Object src = e.getSource(); // the source of the event is the add files button // so we need to let the user add some files! if (src == addFiles) { // create an appropriate file chooser JFileChooser myTempFileChooser = new JFileChooser((new File("")).getAbsolutePath()); myTempFileChooser.setMultiSelectionEnabled(true); myTempFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); myTempFileChooser.setDialogType(JFileChooser.OPEN_DIALOG); myTempFileChooser.setFileHidingEnabled(true); // open the file chooser and get the user's selctions int returnCode = myTempFileChooser.showOpenDialog(this); // use the return info to add files if the // user selected any in the file chooser if (returnCode == JFileChooser.APPROVE_OPTION) { // grab the files the user selected File[] selectedFiles = myTempFileChooser.getSelectedFiles(); // pull the files into the list changeFilesInList.importFileData(list, selectedFiles); } } // the source of the event was the process button else if (src == process) { if (((DefaultListModel) list.getModel()).size() == 0) return; setComponentsEnabled(false); final ThumbMaker tm = this; Thread t = new Thread( new Runnable() { public void run() { tm.process(); setComponentsEnabled(true); } }); t.start(); // because we can't do it on quit, we are going to save // all the preference values when the user processes a set // of images savePreferences(); } // the source of the event was the remove button else if (src == remove) { DefaultListModel model = (DefaultListModel) list.getModel(); while (true) { int ndx = list.getSelectedIndex(); if (ndx < 0) break; model.removeElementAt(ndx); } } // the source of the event was the preserve aspect check box else if (src == aspect) { boolean b = aspect.isSelected(); colorLabel.setEnabled(b); colorBox.setEnabled(b); redLabel.setEnabled(b); red.setEnabled(b); redValue.setEnabled(b); greenLabel.setEnabled(b); green.setEnabled(b); greenValue.setEnabled(b); blueLabel.setEnabled(b); blue.setEnabled(b); blueValue.setEnabled(b); } // the source of the event is the "..." button, // we need to let the user select a destination file else if (src == dotDotDot) { // create an appropriate file chooser JFileChooser myTempFileChooser = new JFileChooser(new File(output.getText()).getAbsolutePath()); myTempFileChooser.setMultiSelectionEnabled(false); myTempFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); myTempFileChooser.setDialogType(JFileChooser.OPEN_DIALOG); myTempFileChooser.setFileHidingEnabled(true); // open the file chooser and get the user's selctions int returnCode = myTempFileChooser.showOpenDialog(this); // use the return info to set the directory if the // user selected one in the file chooser if (returnCode == JFileChooser.APPROVE_OPTION) { // grab the file the user selected File selectedFile = myTempFileChooser.getSelectedFile(); // stuff the file path into the text field output.setText(selectedFile.getAbsolutePath()); } } }
public void setEnabled(boolean enabled) { myTable.setEnabled(enabled); super.setEnabled(enabled); }
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); }
@Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); this.setEnabledRecursive(this, enabled); }