Exemplo n.º 1
0
 // set the frame on the center of bildschirm
 private static void setFrameCenter(Frame f, boolean flag) {
   // f.getToolkit();
   //	Dimension screen=f.getToolkit().getDefaultToolkit().getScreenSize();//获取屏幕尺寸对象
   Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸对象
   Dimension myframe = f.getSize(); // 获取当前窗体的尺寸对象
   int w = (screen.width - myframe.width) / 2; // 水平位置
   int h = (screen.height - myframe.width) / 2; // 垂直位置
   f.setLocation(w, h);
   f.setResizable(flag);
 }
Exemplo n.º 2
0
 void saveWindowLocations() {
   Frame frame = WindowManager.getFrame("B&C");
   if (frame != null) Prefs.saveLocation(ContrastAdjuster.LOC_KEY, frame.getLocation());
   frame = WindowManager.getFrame("Threshold");
   if (frame != null) Prefs.saveLocation(ThresholdAdjuster.LOC_KEY, frame.getLocation());
   frame = WindowManager.getFrame("Results");
   if (frame != null) {
     Prefs.saveLocation(TextWindow.LOC_KEY, frame.getLocation());
     Dimension d = frame.getSize();
     Prefs.set(TextWindow.WIDTH_KEY, d.width);
     Prefs.set(TextWindow.HEIGHT_KEY, d.height);
   }
   frame = WindowManager.getFrame("Log");
   if (frame != null) {
     Prefs.saveLocation(TextWindow.LOG_LOC_KEY, frame.getLocation());
     Dimension d = frame.getSize();
     Prefs.set(TextWindow.LOG_WIDTH_KEY, d.width);
     Prefs.set(TextWindow.LOG_HEIGHT_KEY, d.height);
   }
 }
Exemplo n.º 3
0
 /**
  * Centre the dialog box in the frame. This must be called after the size has been established,
  * i.e. after the buttons etc. are arranged and pack() is called
  */
 public void centreInFrame() {
   Dimension frame_size = parent.getSize();
   Point frame_location = parent.getLocation();
   int centre_x = frame_location.x + frame_size.width / 2;
   int centre_y = frame_location.y + frame_size.height / 2;
   ;
   int xloc = centre_x - this.getSize().width / 2;
   int yloc = centre_y - this.getSize().height / 2;
   this.setLocation(new Point(xloc, yloc));
   this.requestFocus();
 }
  /** Method declaration */
  void main() {

    fMain = new Frame("HSQL Database Manager");
    imgEmpty = createImage(new MemoryImageSource(2, 2, new int[4 * 4], 2, 2));

    fMain.setIconImage(imgEmpty);
    fMain.addWindowListener(this);

    MenuBar bar = new MenuBar();

    // used shortcuts: CERGTSIUDOLM
    String fitems[] = {
      "-Connect...", "--", "-Open Script...", "-Save Script...", "-Save Result...", "--", "-Exit"
    };

    addMenu(bar, "File", fitems);

    String vitems[] = {
      "RRefresh Tree", "--", "GResults in Grid", "TResults in Text",
      "--", "1Shrink Tree", "2Enlarge Tree", "3Shrink Command",
      "4Enlarge Command"
    };

    addMenu(bar, "View", vitems);

    String sitems[] = {
      "SSELECT",
      "IINSERT",
      "UUPDATE",
      "DDELETE",
      "--",
      "-CREATE TABLE",
      "-DROP TABLE",
      "-CREATE INDEX",
      "-DROP INDEX",
      "--",
      "-CHECKPOINT",
      "-SCRIPT",
      "-SET",
      "-SHUTDOWN",
      "--",
      "-Test Script"
    };

    addMenu(bar, "Command", sitems);

    Menu recent = new Menu("Recent");

    mRecent = new Menu("Recent");

    bar.add(mRecent);

    String soptions[] = {
      "-AutoCommit on",
      "-AutoCommit off",
      "OCommit",
      "LRollback",
      "--",
      "-Disable MaxRows",
      "-Set MaxRows to 100",
      "--",
      "-Logging on",
      "-Logging off",
      "--",
      "-Insert test data"
    };

    addMenu(bar, "Options", soptions);

    /* NB - 26052002 Restore is not implemented yet in the transfer tool */
    String stools[] = {"-Dump", /*"-Restore",*/ "-Transfer"};

    addMenu(bar, "Tools", stools);
    fMain.setMenuBar(bar);
    fMain.setSize(640, 480);
    fMain.add("Center", this);
    initGUI();

    sRecent = new String[iMaxRecent];

    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension size = fMain.getSize();

    // (ulrivo): full size on screen with less than 640 width
    if (d.width >= 640) {
      fMain.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
    } else {
      fMain.setLocation(0, 0);
      fMain.setSize(d);
    }

    fMain.show();

    // (ulrivo): load query from command line
    if (defScript != null) {
      if (defDirectory != null) {
        defScript = defDirectory + File.separator + defScript;
      }

      txtCommand.setText(DatabaseManagerCommon.readFile(defScript));
    }

    txtCommand.requestFocus();
  }