Esempio n. 1
0
  /**
   * Centers a <code>JDialog</code> to the screen.
   *
   * @param dialog JDialog dialog to center
   */
  public static void centerDialog(JDialog dialog) {
    // since the Toolkit.getScreenSize() method is broken in the Linux implementation
    // of Java 5  (it returns double the screen size under xinerama), this method is
    // encapsulated to accomodate this with a hack.
    // TODO: remove the hack, once Java fixed this.
    // final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    final Rectangle screenSize =
        GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getDefaultScreenDevice()
            .getDefaultConfiguration()
            .getBounds();

    final Dimension dialogSize = dialog.getSize();

    if (dialogSize.height > screenSize.height) {
      dialogSize.height = screenSize.height;
    }

    if (dialogSize.width > screenSize.width) {
      dialogSize.width = screenSize.width;
    }

    dialog.setLocation(
        screenSize.x + (screenSize.width - dialogSize.width) / 2,
        screenSize.y + (screenSize.height - dialogSize.height) / 2);
    dialog.setSize(dialogSize);
  }
  /** Brings up a window with a scrolling text pane that display the help information. */
  private void showHelp() {
    JDialog dialog = new JDialog(this, resources.getString("dialog.help.title"));
    final JEditorPane helpText = new JEditorPane();
    try {
      URL url = getClass().getResource("GridWorldHelp.html");

      helpText.setPage(url);
    } catch (Exception e) {
      helpText.setText(resources.getString("dialog.help.error"));
    }
    helpText.setEditable(false);
    helpText.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent ev) {
            if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
              try {
                helpText.setPage(ev.getURL());
              } catch (Exception ex) {
              }
          }
        });
    JScrollPane sp = new JScrollPane(helpText);
    sp.setPreferredSize(new Dimension(650, 500));
    dialog.getContentPane().add(sp);
    dialog.setLocation(getX() + getWidth() - 200, getY() + 50);
    dialog.pack();
    dialog.setVisible(true);
  }
  protected JDialog buildCloneWindow() {

    try {
      JDialog cloneWindow = new JDialog(this.window, windowTitle() + " - Clone");
      cloneWindow.getContentPane().add(buildPane(), "Center");
      cloneWindow.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
      cloneWindow.setLocation(this.window.getWidth(), 0);
      cloneWindow.setModal(false);
      cloneWindow.setLocation(windowX + this.window.getWidth(), 0);
      cloneWindow.setSize(this.window.getWidth(), this.window.getHeight());
      return cloneWindow;
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
Esempio n. 4
0
 @Override
 public void actionPerformed(ActionEvent actionEvent) {
   Dimension all = parent.getSize();
   Dimension d = dialog.getSize();
   dialog.setLocation((all.width - d.width) / 2, (all.height - d.height) / 2);
   dialog.setVisible(true);
 }
Esempio n. 5
0
  private void warning(String msg) {
    final JDialog warn;
    JButton ok;
    JLabel message;

    warn = new JDialog();
    warn.setTitle(msg);

    message = new JLabel("CryoBay: " + msg);
    ok = new JButton("Ok");

    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            warn.dispose();
          }
        });

    warn.getContentPane().setLayout(new BorderLayout());
    warn.getContentPane().add(message, "North");
    warn.getContentPane().add(ok, "South");

    warn.setSize(200, 80);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    warn.setLocation(screenSize.width / 2 - 100, screenSize.height / 2 - 40);
    warn.setResizable(false);
    warn.show();
  }
Esempio n. 6
0
  // OutPutPanel의 버튼 이벤트 핸들러
  @Override
  public void actionPerformed(ActionEvent e) {
    JButton jb = (JButton) e.getSource(); // 이벤트가 발생한 객체를 받아온다.

    if (jb.getText().equals("그리기")) {

      repaint(); // 다시그린다.

    } else if (jb.getText().equals("리셋")) {
      try {

        FileWriter fw = new FileWriter("location.txt"); // 쓰기위한 메모장을 연다.
        String s = ""; // 빈 문장
        fw.write(s); // 빈 문장을 덮어 쓴다.
        fw.close(); // 닫는다.
        MainDrawPanel.count = 0;
        repaint();

      } catch (IOException ie) {
        System.out.println(ie);
      }

    } else if (jb.getText().equals("그린갯수")) {

      JDialog Msg = new JDialog(f, "Dialog", true); // 다이얼로그 객체 생성
      Msg.setSize(150, 100); // 다이얼로그 사이즈
      Msg.setLocation(800, 200); // 다이얼로그 생성 위치
      Msg.setLayout(new FlowLayout()); // 다이얼로그 레이아웃
      Msg.add(new JLabel("원을 총 " + MainDrawPanel.count + "개 그림.", JLabel.CENTER));
      Msg.setVisible(true); // 다이얼로그 화면 출력
    }
  }
  /**
   * @param editor
   * @param idDialog
   * @param dialog
   * @param title
   */
  public static void setDialogVisible(
      @Nullable Editor editor, String idDialog, JDialog dialog, String title) {
    Point location = null;

    if (editor != null) {
      Point caretLocation = editor.visualPositionToXY(editor.getCaretModel().getVisualPosition());
      SwingUtilities.convertPointToScreen(caretLocation, editor.getComponent());

      String[] position = UtilsPreferences.getDialogPosition(idDialog).split("x");
      if (!(position[0].equals("0") && position[1].equals("0"))) {
        location = new Point(Integer.parseInt(position[0]), Integer.parseInt(position[1]));
      }
    }

    if (location == null) {
      // Center to screen
      dialog.setLocationRelativeTo(null);
    } else {
      dialog.setLocation(location.x, location.y);
    }

    dialog.setTitle(title);
    dialog.pack();
    dialog.setVisible(true);
  }
 /** Show the filter dialog */
 public void showDialog() {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   include_panel =
       new ServiceFilterPanel("Include messages based on target service:", filter_include_list);
   exclude_panel =
       new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list);
   status_box = new JCheckBox("Filter messages based on status:");
   status_box.addActionListener(this);
   status_active = new JRadioButton("Active messages only");
   status_active.setSelected(true);
   status_active.setEnabled(false);
   status_complete = new JRadioButton("Complete messages only");
   status_complete.setEnabled(false);
   status_group = new ButtonGroup();
   status_group.add(status_active);
   status_group.add(status_complete);
   if (filter_active || filter_complete) {
     status_box.setSelected(true);
     status_active.setEnabled(true);
     status_complete.setEnabled(true);
     if (filter_complete) {
       status_complete.setSelected(true);
     }
   }
   status_options = new JPanel();
   status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS));
   status_options.add(status_active);
   status_options.add(status_complete);
   status_options.setBorder(indent_border);
   status_panel = new JPanel();
   status_panel.setLayout(new BorderLayout());
   status_panel.add(status_box, BorderLayout.NORTH);
   status_panel.add(status_options, BorderLayout.CENTER);
   status_panel.setBorder(empty_border);
   ok_button = new JButton("Ok");
   ok_button.addActionListener(this);
   cancel_button = new JButton("Cancel");
   cancel_button.addActionListener(this);
   buttons = new JPanel();
   buttons.setLayout(new FlowLayout());
   buttons.add(ok_button);
   buttons.add(cancel_button);
   panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
   panel.add(include_panel);
   panel.add(exclude_panel);
   panel.add(status_panel);
   panel.add(buttons);
   dialog = new JDialog();
   dialog.setTitle("SOAP Monitor Filter");
   dialog.setContentPane(panel);
   dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
   dialog.setModal(true);
   dialog.pack();
   Dimension d = dialog.getToolkit().getScreenSize();
   dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2);
   ok_pressed = false;
   dialog.show();
 }
 public TrafficD2CharChooseService() {
   jDialog = new JDialog(TrafficWindow.mainWindow, "二维图");
   jDialog.setSize(120, 100);
   jDialog.setLocation(
       (TrafficWindow.screensize.width - 120) / 2, (TrafficWindow.screensize.height - 100) / 2);
   setContent();
   jDialog.setVisible(true);
 }
Esempio n. 10
0
 public static void setPosition(javax.swing.JDialog dialog) {
   Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
   // calculate the new location of the window
   int w = dialog.getSize().width;
   int h = dialog.getSize().height;
   int x = (dim.width - w) / 2;
   int y = (dim.height - h) / 2;
   dialog.setLocation(x, y);
 }
Esempio n. 11
0
  public Object showWindow(final MkWindow macWindow, String title, boolean isModal) {
    listMkWindow.add(macWindow);
    if (isModal) {
      JDialog modalFrame = new JDialog(this, title, true);
      // macWindow.setJanela(modalFrame);
      final MkRun onCloseWindow = macWindow.onCloseWindow;
      modalFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
      modalFrame.addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              if (onCloseWindow != null) {
                onCloseWindow.execute();
              }
              disposeWindow(macWindow);
            }
          });
      modalFrame.setLayout(new BorderLayout());
      modalFrame.add(macWindow, BorderLayout.CENTER);
      modalFrame.pack();
      Dimension desktopSize = desktopPane.getSize();
      int x = (desktopSize.width - modalFrame.getWidth()) / 2;
      int y = (desktopSize.height - modalFrame.getHeight()) / 2;
      modalFrame.setLocation((x < 0 ? 0 : x), (y < 0 ? 0 : y));
      if (macWindow.panelButton != null) {
        modalFrame.getRootPane().setDefaultButton((JButton) macWindow.panelButton.getComponent(0));
      }
      modalFrame.setVisible(true);
      return modalFrame;
    } else {
      JInternalFrame internalFrame = new JInternalFrame(title, true, true, true, true);
      internalFrame.setContentPane(macWindow);
      internalFrame.pack();
      //            internalFrame.setBounds(internalFrame.getBounds()); //pq?
      desktopPane.add(internalFrame);

      internalFrame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
      final MkRun onCloseWindow = macWindow.onCloseWindow;
      if (onCloseWindow != null) {
        internalFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);

        internalFrame.addInternalFrameListener(
            new InternalFrameAdapter() {
              public void internalFrameClosing(InternalFrameEvent e) {
                onCloseWindow.execute();
              }
            });
      }

      Dimension desktopSize = desktopPane.getSize();
      int x = (desktopSize.width - internalFrame.getWidth()) / 2;
      int y = (desktopSize.height - internalFrame.getHeight()) / 2;
      internalFrame.setLocation((x < 0 ? 0 : x), (y < 0 ? 0 : y));
      internalFrame.setVisible(true);
      return internalFrame;
    }
  }
 public void start(Component c) {
   if (c != null) {
     Component p = c.getParent();
     int x = c.getX() + c.getWidth(), y = c.getY() + c.getHeight();
     while (p != null) {
       x += p.getX();
       y += p.getY();
       p = p.getParent();
     }
     // System.out.println("x="+x+ " y="+y);
     screen.setLocation(x, y);
   } else {
     Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
     screen.setLocation(
         (int) (dim.getWidth() - screen.getWidth()) / 2,
         (int) (dim.getHeight() - screen.getHeight()) / 2);
   }
   SwingUtilities.invokeLater(this);
 }
Esempio n. 13
0
 /**
  * Centers the dialog above the given frame
  *
  * @param frame to center the dialog above
  * @param dialog to center above the frame
  */
 public static void centerDialog(final JFrame frame, JDialog dialog) {
   int parWidth = frame.getWidth();
   int parHeight = frame.getHeight();
   int parX = frame.getLocation().x;
   int parY = frame.getLocation().y;
   Point loc =
       new Point(
           ((parWidth - dialog.getWidth()) / 2) + parX,
           ((parHeight - dialog.getHeight()) / 2) + parY);
   dialog.setLocation(loc);
 }
  /**
   * Create Message on GUI.
   *
   * @param msg
   */
  public void createMsg(String msg) {
    // System.out.println(msg);
    // String message = "<html><font name='sansserif' size='5'/>" + msg ;
    JOptionPane optionPane =
        new JOptionPane(
            msg, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, null, null);

    JDialog dialog = optionPane.createDialog(null, "SCENARIO");
    dialog.setLocation(900, 430);
    dialog.setVisible(true);
  }
Esempio n. 15
0
  public static void frameInit(JDialog frame) {
    Toolkit kit2 = Toolkit.getDefaultToolkit(); // 定义工具包
    Dimension screenSize = kit2.getScreenSize(); // 获取屏幕的尺寸

    //		kit2.
    frame.setUndecorated(true);
    int screenWidth = screenSize.width / 2; // 获取屏幕的宽
    int screenHeight = screenSize.height / 2; // 获取屏幕的高
    int height = frame.getHeight();
    int width = frame.getWidth();
    frame.setLocation(screenWidth - width / 2, screenHeight - height / 2);
  }
  public static void main(String[] args) {
    JDialog dlgVentana = new JDialog();
    dlgVentana.setResizable(false);

    GeopistaComparacionPanel iniciar = new GeopistaComparacionPanel();

    dlgVentana.getContentPane().add(iniciar);
    dlgVentana.setSize(750, 600);
    dlgVentana.setVisible(true);
    dlgVentana.setLocation(150, 90);
    dlgVentana.setTitle("Discrepancias de la Información");
    dlgVentana.setResizable(false);
  }
Esempio n. 17
0
  private void initGUI(String title, String version) {
    JLabel xenaLogoLabel = new JLabel(IconFactory.getIconByName("images/xena-icon.png"));
    xenaLogoLabel.setOpaque(false);
    JLabel headerLabel = new JLabel(IconFactory.getIconByName("images/naaheader-blue.png"));
    JLabel footerLabel = new JLabel(IconFactory.getIconByName("images/naafooter-blue.png"));

    logTextArea = new JTextArea(8, 10);
    logTextArea.setEditable(false);
    logTextArea.setBorder(new EmptyBorder(0, 0, 0, 0));
    logTextArea.setBackground(new Color(255, 255, 255));
    logTextArea.setWrapStyleWord(true);
    logTextArea.setLineWrap(true);
    JScrollPane logSP =
        new JScrollPane(
            logTextArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    logSP.setBorder(new EmptyBorder(0, 0, 0, 0));

    JLabel versionLabel = new JLabel(title + " " + version);
    versionLabel.setBackground(logTextArea.getBackground());
    versionLabel.setForeground(logTextArea.getForeground());
    versionLabel.setFont(versionLabel.getFont().deriveFont(Font.BOLD));
    versionLabel.setOpaque(true);

    JPanel textPanel = new JPanel(new BorderLayout());
    textPanel.add(versionLabel, BorderLayout.NORTH);
    textPanel.add(logSP, BorderLayout.CENTER);
    textPanel.setBorder(new LineBorder(logTextArea.getBackground(), 6));

    JPanel infoPanel = new JPanel(new BorderLayout());
    infoPanel.setOpaque(false);
    infoPanel.add(xenaLogoLabel, BorderLayout.WEST);
    infoPanel.add(textPanel, BorderLayout.CENTER);

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setBorder(new LineBorder(Color.BLACK));
    mainPanel.setBackground(logTextArea.getBackground());
    mainPanel.add(headerLabel, BorderLayout.NORTH);
    mainPanel.add(infoPanel, BorderLayout.CENTER);
    mainPanel.add(footerLabel, BorderLayout.SOUTH);

    splashDialog = new JDialog((Frame) null, "", false);
    splashDialog.setUndecorated(true);
    splashDialog.add(mainPanel, BorderLayout.CENTER);
    splashDialog.pack();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension splashSize = splashDialog.getSize();
    splashDialog.setLocation(
        (screenSize.width - splashSize.width) / 2, (screenSize.height - splashSize.height) / 2);
  }
Esempio n. 18
0
 public WindowConfigurationStorage decorateDialog(JDialog dialog, String propertyName) {
   String unmarshalled = getProperty(propertyName);
   if (unmarshalled != null) {
     WindowConfigurationStorage storage = (WindowConfigurationStorage) unMarshall(unmarshalled);
     if (storage != null) {
       dialog.setLocation(storage.getX(), storage.getY());
       dialog
           .getRootPane()
           .setPreferredSize(new Dimension(storage.getWidth(), storage.getHeight()));
     }
     return storage;
   }
   return null;
 }
Esempio n. 19
0
  private static void nastaveni() {
    OKbt.addActionListener(new ConfirmModifyForm());
    dialog.add(lbName);
    dialog.add(tfName);
    dialog.add(lbAutor);
    dialog.add(tfAutor);
    dialog.add(lbDate);
    dialog.add(tfDate);
    dialog.add(new JSeparator());
    dialog.add(OKbt);

    dialog.setLayout(new FlowLayout());
    dialog.setSize(200, 250);
    dialog.setLocation(frame.getLocation());
  }
Esempio n. 20
0
  /**
   * A very basic dialogue creator. This allows for greater customization like setting modality.
   *
   * @param owner The owner
   * @param minSize The minimum size
   * @param title The title
   * @param message The message to display
   * @param option The options - i.e. the buttons added defined by {@link JDialog} option types.
   *     Currently only {@link JOptionPane#OK_OPTION} is supported.
   * @param icon The icon to display
   * @param modalityType The modality type @see ModalityType
   */
  private void showDialouge(
      Window owner,
      Dimension minSize,
      String title,
      String message,
      int option,
      Icon icon,
      ModalityType modalityType) {
    final JDialog d = new JDialog(owner, title, modalityType);
    d.setLayout(new BorderLayout());
    d.setSize(minSize);
    d.setMinimumSize(minSize);
    // set the dialouge's location to be centred at the centre of it's owner
    d.setLocation(
        ((owner.getX() + owner.getWidth()) / 2) - d.getWidth() / 2,
        ((owner.getY() + owner.getHeight()) / 2) - d.getHeight() / 2);
    JLabel l = new JLabel(message, icon, SwingConstants.CENTER);
    // Add dialogue's text containing children for text recolouring
    l.setForeground(survivor.getCurrentColourScheme().getReadableText());
    complementaryAmenableForegroundColourableComponents.add(l);
    d.add(l, BorderLayout.CENTER);

    if (option == JOptionPane.OK_OPTION) {
      JButton ok = new JButton("OK");
      // make the button respond when ENTER is pressed
      ok.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "pressed");
      ok.getInputMap().put(KeyStroke.getKeyStroke("released ENTER"), "released");
      // Add dialogue's text containing children for text recolouring
      complementaryAmenableForegroundColourableComponents.add(ok);
      ok.setForeground(survivor.getCurrentColourScheme().getReadableText());
      ok.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
              d.dispose();
            }
          });

      d.add(ok, BorderLayout.PAGE_END);
    }

    //		d.setBackground(hangman.currentColourScheme.getC3());
    // The dialogue is included in the below sets for proper colouring
    backgroundColourableComponents.add(d);

    d.setVisible(true);
  }
Esempio n. 21
0
  public void runCalculatorDialog(MouseEvent e) {
    if (calculatorDialog == null) {
      JFrame frame = null;
      Container container = getTopLevelAncestor();

      if (container instanceof JFrame) {
        frame = (JFrame) container;
      }

      calculatorDialog = new JDialog(frame, "Rechner", true);
      calculator = new Calculator();
      calculator.getOKButton().addActionListener(this);
      calculatorDialog.getContentPane().add(calculator);
      calculatorDialog.pack();
    }

    // Set calculator's init value

    Money money = getValue();

    if (money != null) {
      calculator.setValue(money.getValue());
    } else {
      calculator.setValue(0.0);
    }

    // calculate POP (point of presentation)

    Point point = ((JComponent) e.getSource()).getLocationOnScreen();
    int x = point.x + e.getX();
    int y = point.y + e.getY();

    // ensure that it does not exceed the screen limits

    Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension dim = calculatorDialog.getPreferredSize();
    if (x + dim.width >= screenDim.width) {
      x = screenDim.width - dim.width - 1;
    }
    if (y + dim.height >= screenDim.height) {
      y = screenDim.height - dim.height - 1;
    }

    // make it visible at wanted location

    calculatorDialog.setLocation(x, y);
    calculatorDialog.show();
  }
Esempio n. 22
0
  /** Sets the location on the given dialog for the given index. */
  private void setLocation(JDialog dialog, int index) {
    Rectangle bounds = dialog.getBounds();
    JFrame frame = findOwner();
    Dimension dim;
    if (frame == null) {
      dim = Toolkit.getDefaultToolkit().getScreenSize();
    } else {
      dim = frame.getSize();
    }

    int x = (int) (150 * Math.cos(index * 15 * (Math.PI / 180)));
    int y = (int) (150 * Math.sin(index * 15 * (Math.PI / 180)));
    x += (dim.width - bounds.width) / 2;
    y += (dim.height - bounds.height) / 2;
    dialog.setLocation(x, y);
  }
  public Action queryUserForLabel(CCanvasLink link) {
    Rectangle windowBounds = CalicoDataStore.calicoObj.getBounds();
    Rectangle dialogBounds = dialog.getBounds();
    int x = windowBounds.x + ((windowBounds.width - dialogBounds.width) / 2);
    int y = windowBounds.y + ((windowBounds.height - dialogBounds.height) / 2);
    dialog.setLocation(x, y);

    action = Action.CANCEL;

    panel.entry.setText(link.getLabel());
    panel.entry.grabFocus();
    panel.entry.selectAll();
    dialog.setVisible(true);

    return action;
  }
Esempio n. 24
0
 /** Create and show the gui */
 public void showDialog() {
   if (dialog == null) {
     JFrame parentFrame = persistenceManager.getIdv().getIdvUIManager().getFrame();
     dialog = new JDialog(parentFrame, "Loading Bundle");
     if (dialogTitle != null) {
       dialog.setTitle("Loading Bundle: " + dialogTitle);
     }
     dialog.getContentPane().add(contents);
   }
   dialog.pack();
   Point center = GuiUtils.getLocation(null);
   if (persistenceManager.getIdv().okToShowWindows()) {
     dialog.setLocation(20, 20);
     dialog.setVisible(true);
   }
 }
Esempio n. 25
0
  /**
   * This should take its inspiration from {@link org.tigris.gef.base.CmdSpawn}.
   *
   * <p>The spawned/cloned tab will be a JFrame. Currently this feature is disabled for ArgoUML,
   * except for the find dialog. Code should behave though as if spawning might work at a later
   * stage.
   *
   * @return a copy of the frame or null if not clone-able.
   */
  public AbstractArgoJPanel spawn() {

    JDialog f = new JDialog(ArgoFrame.getInstance());
    f.getContentPane().setLayout(new BorderLayout());
    // TODO: Once we have fixed all subclasses the title will
    // always be localized so this localization can be removed.
    f.setTitle(Translator.localize(title));
    AbstractArgoJPanel newPanel = (AbstractArgoJPanel) clone();
    if (newPanel == null) {
      return null; // failed to clone
    }

    //        if (newPanel instanceof TabToDo) {
    //            TabToDo me = (TabToDo) this;
    //            TabToDo it = (TabToDo) newPanel;
    //            it.setTarget(me.getTarget());
    //        } else if (newPanel instanceof TabModelTarget) {
    //            TabModelTarget me = (TabModelTarget) this;
    //            TabModelTarget it = (TabModelTarget) newPanel;
    //            it.setTarget(me.getTarget());
    //        } else if (newPanel instanceof TabDiagram) {
    //            TabDiagram me = (TabDiagram) this;
    //            TabDiagram it = (TabDiagram) newPanel;
    //            it.setTarget(me.getTarget());
    //        }

    // TODO: Once we have fixed all subclasses the title will
    // always be localized so this localization can be removed.
    newPanel.setTitle(Translator.localize(title));

    f.getContentPane().add(newPanel, BorderLayout.CENTER);
    Rectangle bounds = getBounds();
    bounds.height += OVERLAPP * 2;
    f.setBounds(bounds);

    Point loc = new Point(0, 0);
    SwingUtilities.convertPointToScreen(loc, this);
    loc.y -= OVERLAPP;
    f.setLocation(loc);
    f.setVisible(true);

    if (tear && (getParent() instanceof JTabbedPane)) {
      ((JTabbedPane) getParent()).remove(this);
    }

    return newPanel;
  }
Esempio n. 26
0
  public void setPanel(Parameters pp, String s) {
    JPanel buttonsPanel = new JPanel();
    okButton = new JButton("确定");
    okButton.addActionListener(this);

    dialog = new JDialog(this, s + " 参数选择", true);

    Container contentPane = getContentPane();
    Container dialogContentPane = dialog.getContentPane();

    dialogContentPane.add(pp, BorderLayout.CENTER);
    dialogContentPane.add(buttonsPanel, BorderLayout.SOUTH);
    dialog.pack();
    buttonsPanel.add(okButton);
    dialog.setLocation(50, 330);
    dialog.show();
  }
Esempio n. 27
0
  /** Brings up a dialog that displays the license. */
  private void showLicense() {
    JDialog dialog = new JDialog(this, resources.getString("dialog.license.title"));
    final JEditorPane text = new JEditorPane();
    try {
      URL url = getClass().getResource("GNULicense.txt");

      text.setPage(url);
    } catch (Exception e) {
      text.setText(resources.getString("dialog.license.error"));
    }
    text.setEditable(false);
    JScrollPane sp = new JScrollPane(text);
    sp.setPreferredSize(new Dimension(650, 500));
    dialog.getContentPane().add(sp);
    dialog.setLocation(getX() + getWidth() - 200, getY() + 50);
    dialog.pack();
    dialog.setVisible(true);
  }
Esempio n. 28
0
  protected void centerDialogLocation(JDialog dialog) {
    Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
    GraphicsConfiguration configuration =
        GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getDefaultScreenDevice()
            .getDefaultConfiguration();
    Insets screen_insets = Toolkit.getDefaultToolkit().getScreenInsets(configuration);

    screen_size.width -= screen_insets.left;
    screen_size.width -= screen_insets.right;
    screen_size.height -= screen_insets.top;
    screen_size.height -= screen_insets.bottom;

    Dimension frame_size = dialog.getSize();
    dialog.setLocation(
        ((screen_size.width / 2) - (frame_size.width / 2)) + screen_insets.left,
        ((screen_size.height / 2) - (frame_size.height / 2)) + screen_insets.top);
  }
Esempio n. 29
0
  public CadastrarPessoa(final JFrame frame) {

    JPanel painel = new JPanel();

    Color cor = new Color(230, 232, 250);

    labelNome = new JLabel("Nome:");
    fieldNome = new JTextField(20);

    labelRG = new JLabel("RG:");
    fieldRG = new JTextField(20);

    botaoCadastrar = new JButton("Cadastrar");
    botaoCadastrar.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            cadastrarPessoa();
            frame.dispose();
            new SGBDE();
          }
        });

    janela = new JDialog(frame, "Cadastrar Pessoa", true);
    TitledBorder borda = BorderFactory.createTitledBorder("Cadastrar Pessoa");

    painel.setLayout(new MigLayout());
    painel.setBackground(cor);
    painel.setBorder(borda);

    painel.add(labelNome, "width :10:");
    painel.add(fieldNome, "width :100:, gapleft 30, wrap");
    painel.add(labelRG, "width :10:");
    painel.add(fieldRG, "width :100:, gapleft 30, wrap");
    painel.add(botaoCadastrar, "width 170:: , height :30:, span");

    janela.add(painel);
    janela.setSize(220, 180);
    janela.setLocation(530, 270);
    janela.setVisible(true);
    janela.setResizable(false);
    janela.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  }
Esempio n. 30
0
  @Override
  public void start(Question t, JButton sourceButton) {
    JDialog dialog = new JDialog(windowParent, "Question Editor");

    QuestionEditorPanel questionEditorPanel = new QuestionEditorPanel(t, dialog, sourceButton);
    dialog.add(questionEditorPanel);

    dialog.setModalityType(ModalityType.APPLICATION_MODAL);
    dialog.pack();

    // Centers inside the application frame
    int x = windowParent.getX() + (windowParent.getWidth() - dialog.getWidth()) / 2;
    int y = windowParent.getY() + (windowParent.getHeight() - dialog.getHeight()) / 2;
    dialog.setLocation(x, y);

    // Shows the modal dialog and waits
    dialog.setVisible(true);
    dialog.toFront();
  }