コード例 #1
0
ファイル: HardcopyWriter.java プロジェクト: olexy/RealJava
 public static void main(String[] args) {
   try {
     if (args.length != 1) throw new IllegalArgumentException("Wrong number of arguments");
     FileReader in = new FileReader(args[0]);
     HardcopyWriter out = null;
     Frame f = new Frame("PrintFile: " + args[0]);
     f.setSize(200, 50);
     f.show();
     try {
       out = new HardcopyWriter(f, args[0], 10, .75, .75, .75, .75);
     } catch (HardcopyWriter.PrintCanceledException e) {
       System.exit(0);
     }
     f.setVisible(false);
     char[] buffer = new char[4096];
     int numchars;
     while ((numchars = in.read(buffer)) != -1) out.write(buffer, 0, numchars);
     out.close();
   } catch (Exception e) {
     System.err.println(e);
     System.err.println("Usage: java HardcopyWriter$PrintFile <filename>");
     System.exit(1);
   }
   System.exit(0);
 }
コード例 #2
0
ファイル: AwtApplication.java プロジェクト: Winnerhust/MyTool
 /**
  * Main entry point for the application
  *
  * @param args List of command line arguments passed to the app
  */
 public static void main(String args[]) {
   // create the main application window
   Frame appWindow = new $safeitemname$();
   // set the window properties
   appWindow.setTitle("$itemname$");
   appWindow.setSize(600, 400);
   appWindow.setBackground(new Color(215, 215, 215));
   appWindow.validate();
   // show the window
   appWindow.show();
 }
コード例 #3
0
ファイル: DynamicEvents.java プロジェクト: xjpsjtu/Tij
 public static void main(String[] args) {
   // TODO 自动生成的方法存根
   Frame f = new DynamicEvents();
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   f.setSize(300, 200);
   f.show();
 }
コード例 #4
0
ファイル: Animate.java プロジェクト: citrit/ECSE4750
  // This is where things get started
  public static void main(String args[]) {
    // Create a new frame to hold the canvas and put it up.
    Frame fm = new Frame();
    Animate b = new Animate();

    // Make it visible and set size
    b.setVisible(true);
    b.setSize(300, 300);
    System.out.println("Here we go");

    // Add the canvas to the frame and make it show
    fm.add("Center", b);
    fm.pack();
    fm.show();
  }
コード例 #5
0
  /** 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();
  }
コード例 #6
0
ファイル: HardcopyWriter.java プロジェクト: olexy/RealJava
 /** The main method of the program. Create a test window and display it */
 public static void main(String[] args) {
   Frame f = new Demo();
   f.show();
 }
コード例 #7
0
ファイル: LogonAppDemo.java プロジェクト: rortian/oldjava
 public synchronized void show() {
   move(50, 50);
   nameField.requestFocus();
   super.show();
 } // show
コード例 #8
0
 /**
  * Needed to avoid memory leak: we register this EmbeddedFrame as a listener with
  * KeyboardFocusManager of applet's AppContext. We don't want the KFM to keep reference to our
  * EmbeddedFrame forever if the Frame is no longer in use, so we add listeners in show() and
  * remove them in hide().
  */
 public void show() {
   if (appletKFM != null) {
     addTraversingOutListeners(appletKFM);
   }
   super.show();
 }
コード例 #9
0
ファイル: AllComponents.java プロジェクト: olexy/RealJava
 public static void main(String[] args) {
   Frame f = new AllComponents("AWT Demo");
   f.pack();
   f.show();
 }
コード例 #10
0
  /**
   *   Handles when aides cover each other. They must tell
   *   us who they're covering so that that poor person
   *   doesn't get a missed shift. This of course means i
   *   have to work on MyHours some more... If they select
   *   a valid userid to cover for makes the appropriate
   *   entry in AIDELOG.
   *
   *   @param An SaoWorker who is covering someone else
   */
  public void WhoRUCovering(final SaoWorker w)
  {
    int i = 0;
    int h = bd.getHours();
    int m = bd.getMinutes();
    if (((m >= 20) && (m < 30)) || ((m >= 50) && (m < 60)))
    {
      if (m < 30) { m = m + 10; }
      else { m = m + 10 - 60; h = h + 1; }      
    }
    int dopp = bd.getDoPP();
    if (dopp > 7) { dopp = dopp - 7; }
    String slotid = bd.getSlot(h, m, dopp);
    String q = "select * from AIDESCHED where " + slotid + "=1";
    final String[] userids = {"", "", "", "", "", "", "", "", "", ""};
    final BatSQL bSQL = new BatSQL();
    ResultSet rs = bSQL.query(q);
    
    try
    {
      boolean more = rs.next();
      if (more) //because there might be only one person for this slot
      {
        while (more)
        {
          userids[i] = rs.getString(1);
          i++;
          more = rs.next();
        }
      } //end of if more
    } //end of try
    catch (SQLException ex)
    {
      System.out.println("!*******SQLException caught*******!");
      System.out.println("WhoRUCovering");
      while (ex != null)
      {
        System.out.println ("SQLState: " + ex.getSQLState ());
        System.out.println ("Message:  " + ex.getMessage ());
        System.out.println ("Vendor:   " + ex.getErrorCode ());
        ex = ex.getNextException ();
        System.out.println ("");
      }
      System.exit(0);
    } //end catching SQLExceptions
    catch (java.lang.Exception ex)
    {
      System.out.println("!*******Exception caught*******!");
      System.out.println("WhoRUCovering");      
      System.exit(0);
    } //end catching other Exceptions
    
    final Frame coverF = new Frame("Covering?");
    final Panel     p  = new Panel();
    final Panel  btnP  = new Panel();
    final List  coverL = new List();
    Button    ok = new Button("Cover");
    Button   nok = new Button("Cancel");
    final int i2 = i;
    
    ok.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
        String id = coverL.getSelectedItem();
        BatSQL bS = new BatSQL();
        String a = "insert into aidelog values ('C', \"" + id + "\", \"" + bd.getDate() + "\", " + bd.getStringHours() + bd.getStringMinutes() + ", 'I')";
        bS.update(a);
        a = "update AIDEDIN set COVERING='" + id + "' where USERID='" + w.getUserID() + "'";
        bS.update(a);
        bS.disconnect();
        coverF.dispose();
      }
    });
    nok.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
        coverF.dispose();
      }
    });
    
    btnP.setLayout(new FlowLayout());
    btnP.add(ok);
    btnP.add(nok);
    
    p.setLayout(new BorderLayout());
    p.add(new Label("Who are you covering for?"), BorderLayout.NORTH);
    int j;
    for (j = 0; j <= i; j++)
    {
      coverL.add(userids[j]);
    }
    p.add(coverL, BorderLayout.CENTER);
    p.add(btnP, BorderLayout.SOUTH);
    
    coverL.select(0);
    
    coverF.setLayout(new FlowLayout());
    coverF.add(p);    
    coverF.pack();
    coverF.setLocation(200, 200);
    coverF.show();

  } //end of WhoRUCovering