Changeset 46


Ignore:
Timestamp:
09/23/04 14:35:07 (15 years ago)
Author:
curtis
Message:

Add method to allow different default name for new display.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/visbio/view/DisplayManager.java

    r37 r46  
    4848  // -- Constants -- 
    4949 
     50  /** Maximum number of simultaneous displays. */ 
     51  public static final int MAX_DISPLAYS = 32; 
     52 
    5053  /** String for ImageJ quit warning. */ 
    5154  public static final String WARN_IMAGEJ = 
     
    7578  /** Pops up a dialog allowing the user to create a new display. */ 
    7679  public DisplayWindow createDisplay(boolean threeD) { 
     80    nextId++; 
     81    DisplayWindow window = createDisplay("display" + nextId, threeD); 
     82    if (window == null) nextId--; 
     83    return window; 
     84  } 
     85 
     86  /** 
     87   * Pops up a dialog allowing the user to create a new display, 
     88   * with the given default name. 
     89   */ 
     90  public DisplayWindow createDisplay(String defaultName, boolean threeD) { 
    7791    DisplayWindow window = null; 
    78     if (getDisplays().length < 32) { 
     92    if (getDisplays().length < MAX_DISPLAYS) { 
    7993      String name = (String) JOptionPane.showInputDialog(null, 
    8094        "Display name:", "Add display", JOptionPane.INFORMATION_MESSAGE, 
    81         null, null, "display" + ++nextId); 
     95        null, null, defaultName); 
    8296      if (name != null) { 
    8397        window = new DisplayWindow(this, name, threeD); 
     
    86100    } 
    87101    else { 
    88       JOptionPane.showMessageDialog(null, "Sorry, but there is a limit " + 
    89         "of 32 displays maximum.\nPlease reuse or delete one of your " + 
    90         "existing displays.", "Cannot create display", 
     102      JOptionPane.showMessageDialog(null, "Sorry, but there is a limit of " + 
     103        MAX_DISPLAYS + " displays maximum.\nPlease reuse or delete one of " + 
     104        "your existing displays.", "Cannot create display", 
    91105        JOptionPane.ERROR_MESSAGE); 
    92106    } 
Note: See TracChangeset for help on using the changeset viewer.