示例#1
0
  class plzwai extends JFrame {
    Toolkit tk = Toolkit.getDefaultToolkit();
    int w = (int) tk.getScreenSize().getWidth();
    int h = (int) tk.getScreenSize().getHeight();

    plzwai() {
      LookAndFeel lf = UIManager.getLookAndFeel();
      try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        // UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
      } catch (Exception e) {
      }
      fplz = new JFrame("Sending The Pay Slip. Please Wait....");
      fplz.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      final JProgressBar aJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL);
      // aJProgressBar.setStringPainted(true);
      aJProgressBar.setIndeterminate(true);
      fplz.add(new JPanel(), BorderLayout.NORTH);
      fplz.setIconImage(Toolkit.getDefaultToolkit().getImage("Bin\\img\\airindia.jpg"));
      fplz.add(new JPanel(), BorderLayout.WEST);
      fplz.add(new JPanel(), BorderLayout.EAST);
      fplz.add(new JPanel(), BorderLayout.SOUTH);
      fplz.add(aJProgressBar, BorderLayout.CENTER);
      fplz.setResizable(false);
      fplz.setLocation(h / 3, w / 4);
      fplz.setSize(700, 100);
      fplz.setVisible(true);
    }
  }
示例#2
0
 /** * Creates a Simple Neon Hex Frame Application * @throws IOException */
 public Main() throws IOException {
   super("Hex");
   setIconImage(Toolkit.getDefaultToolkit().getImage("images\\s1.png"));
   // Add in a menu
   JMenuBar menuBar = new JMenuBar();
   JMenu gameMenu = new JMenu("Game");
   gameMenu.setMnemonic('G');
   newMenuItem = new JMenuItem("New Game");
   newMenuItem.addActionListener(this);
   quitMenuItem = new JMenuItem("Exit");
   quitMenuItem.addActionListener(this);
   gameMenu.add(newMenuItem);
   gameMenu.addSeparator();
   gameMenu.add(quitMenuItem);
   menuBar.add(gameMenu);
   JMenu helpMenu = new JMenu("Help");
   helpMenu.setMnemonic('H');
   aboutMenuItem = new JMenuItem("About...");
   aboutMenuItem.addActionListener(this);
   helpMenu.add(aboutMenuItem);
   menuBar.add(helpMenu);
   setJMenuBar(menuBar);
   // Set up the layout
   // Centre the frame in the middle (almost) of the screen
   setLayout(new BorderLayout());
   tableArea = new Board();
   add(tableArea, BorderLayout.CENTER);
   Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
   setLocation((screen.width - Board.WIDTH) / 2, (screen.height - Board.HEIGHT) / 2 - 52);
   setResizable(false);
 }
  public TaskbarPositionTest() {
    super("Use CTRL-down to show a JPopupMenu");
    setContentPane(panel = createContentPane());
    setJMenuBar(createMenuBar("1 - First Menu", true));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // CTRL-down will show the popup.
    panel
        .getInputMap()
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP");
    panel.getActionMap().put("OPEN_POPUP", new PopupHandler());

    pack();

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    fullScreenBounds = new Rectangle(new Point(), toolkit.getScreenSize());
    screenBounds = new Rectangle(new Point(), toolkit.getScreenSize());

    // Place the frame near the bottom. This is a pretty wild guess.
    this.setLocation(0, (int) screenBounds.getHeight() - 2 * this.getHeight());

    // Reduce the screen bounds by the insets.
    GraphicsConfiguration gc = this.getGraphicsConfiguration();
    if (gc != null) {
      Insets screenInsets = toolkit.getScreenInsets(gc);
      screenBounds = gc.getBounds();
      screenBounds.width -= (screenInsets.left + screenInsets.right);
      screenBounds.height -= (screenInsets.top + screenInsets.bottom);
      screenBounds.x += screenInsets.left;
      screenBounds.y += screenInsets.top;
    }

    setVisible(true);
  }
示例#4
0
 @Override
 public void actionPerformed(ActionEvent ev) {
   Component component = (Component) ev.getSource();
   final String componentName = component.getName();
   switch (componentName) {
     case SAVE_MENU_ITEM_NAME:
     case SAVE_AS_MENU_ITEM_NAME:
       boolean mustChooseFile = SAVE_AS_MENU_ITEM_NAME.equals(componentName);
       saveToDisk(mustChooseFile);
       break;
     case NEW_MENU_ITEM_NAME:
     case OPEN_MENU_ITEM_NAME:
       showSaveConfirmationIfNecessaryAndRun(
           "You have changes on your current document. Save before continuing?",
           componentName,
           new Runnable() {
             @Override
             public void run() {
               if (NEW_MENU_ITEM_NAME.equals(componentName)) {
                 setSpreadsheet(new Spreadsheet());
                 setCurrentFile(null);
               } else { // open
                 Path chosenFile = chooseFile(JFileChooser.OPEN_DIALOG);
                 openSpreadsheet(chosenFile);
               }
             }
           });
       break;
     case COPY_MENU_ITEM_NAME:
       Object displayValue =
           mCellDisplayValueManager.getDisplayValueOfCellAt(getSelectedCellLocation());
       if (!"".equals(displayValue)) {
         Transferable contents = new StringSelection(displayValue.toString());
         Toolkit.getDefaultToolkit().getSystemClipboard().setContents(contents, null);
       }
       break;
     case COPY_FORMULA_MENU_ITEM_NAME:
       String cellContent = mSpreadsheet.getCellContentAt(getSelectedCellLocation());
       if (cellContent != null) {
         Transferable contents = new StringSelection(cellContent);
         Toolkit.getDefaultToolkit().getSystemClipboard().setContents(contents, null);
       }
       break;
     case PASTE_MENU_ITEM_NAME:
       Transferable clipboard =
           Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
       CellLocation selectedLocation = getSelectedCellLocation();
       try {
         Object transferData = clipboard.getTransferData(DataFlavor.stringFlavor);
         mTableModel.setValueAt(
             transferData.toString(), selectedLocation.getRow(), selectedLocation.getColumn());
       } catch (UnsupportedFlavorException | IOException ex) {
         // we can only use the string flavor anyway, nothing we can do here
       }
       break;
   }
 }
示例#5
0
  public hostelStatus() {
    setTitle("Hostel");
    connect();
    updateRecord();

    JFrame fr = new JFrame();
    Toolkit tkt = fr.getToolkit();
    Dimension frsize = tkt.getScreenSize();
    setBounds(frsize.width / 4, frsize.height / 12, frsize.width / 2, frsize.height / 8);
    setLayout(null);

    cn = getContentPane();
    cn.setBackground(new Color(190, 180, 170));

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    tl = new JLabel("Current Hostels Status");
    tl.setFont(new Font("Engravers MT", 1, 25));
    tl.setForeground(new Color(247, 251, 249));

    p1 = new JPanel();
    p1.setBounds(0, 0, 600, 50);
    p1.add(tl);
    p1.setBackground(new Color(31, 88, 166));
    cn.add(p1);

    b1 = new JButton("LOAD");
    b1.setMnemonic('L');
    b1.addActionListener(new dispListener());
    b1.setBounds(230, 320, 120, 30);

    b2 = new JButton("EXIT");
    b2.setMnemonic('X');
    b2.addActionListener(new exitListener());
    b2.setBounds(350, 320, 100, 30);

    cn.add(b1);
    cn.add(b2);

    table = new JTable(data, col);
    table.setFont(new Font("Serif", Font.BOLD, 16));
    table.setBackground(new Color(250, 250, 250));
    table.setEnabled(false);

    JScrollPane jsp = new JScrollPane(table);
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setBounds(5, 100, 590, 200);
    cn.add(jsp);

    screensize = Toolkit.getDefaultToolkit().getScreenSize();

    setSize(600, 400);
    setVisible(true);
    setVisible(true);
    setResizable(true);
    connect();
  }
示例#6
0
 public username() {
   setLayout(new BorderLayout());
   setVisible(true);
   setResizable(false);
   int width = Toolkit.getDefaultToolkit().getScreenSize().width;
   int hight = Toolkit.getDefaultToolkit().getScreenSize().height;
   setBounds(300, 0, width - 600, hight);
   add(BorderLayout.CENTER, new p3());
 }
 public static void setCursor(client client, int id) {
   Toolkit toolkit = Toolkit.getDefaultToolkit();
   Cursor cursor =
       toolkit.createCustomCursor(
           toolkit.getImage("C:/.hack3rClient/Sprites/Cursors/Cursor " + id + ".PNG"),
           new Point(0, 0),
           "C:/.hack3rClient/Sprites/Cursors/Cursor " + id + ".PNG");
   // Cursor cursor = toolkit.createCustomCursor(toolkit.getImage("Cursors/Cursor "+id+".PNG"), new
   // Point(0,0), ".Cursor/Cursor "+id+".PNG");
   frame.setCursor(cursor);
   //	client.gameFrame.setCursor(cursor);
 }
示例#8
0
  /**
   * Returns an point which has been adjusted to take into account of the desktop bounds, taskbar
   * and multi-monitor configuration.
   *
   * <p>This adustment may be cancelled by invoking the application with
   * -Djavax.swing.adjustPopupLocationToFit=false
   */
  Point adjustPopupLocationToFitScreen(int xPosition, int yPosition) {
    Point popupLocation = new Point(xPosition, yPosition);

    if (popupPostionFixDisabled == true || GraphicsEnvironment.isHeadless()) {
      return popupLocation;
    }

    // Get screen bounds
    Rectangle scrBounds;
    GraphicsConfiguration gc = getCurrentGraphicsConfiguration(popupLocation);
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (gc != null) {
      // If we have GraphicsConfiguration use it to get screen bounds
      scrBounds = gc.getBounds();
    } else {
      // If we don't have GraphicsConfiguration use primary screen
      scrBounds = new Rectangle(toolkit.getScreenSize());
    }

    // Calculate the screen size that popup should fit
    Dimension popupSize = JPopupMenu.this.getPreferredSize();
    long popupRightX = (long) popupLocation.x + (long) popupSize.width;
    long popupBottomY = (long) popupLocation.y + (long) popupSize.height;
    int scrWidth = scrBounds.width;
    int scrHeight = scrBounds.height;
    if (!canPopupOverlapTaskBar()) {
      // Insets include the task bar. Take them into account.
      Insets scrInsets = toolkit.getScreenInsets(gc);
      scrBounds.x += scrInsets.left;
      scrBounds.y += scrInsets.top;
      scrWidth -= scrInsets.left + scrInsets.right;
      scrHeight -= scrInsets.top + scrInsets.bottom;
    }
    int scrRightX = scrBounds.x + scrWidth;
    int scrBottomY = scrBounds.y + scrHeight;

    // Ensure that popup menu fits the screen
    if (popupRightX > (long) scrRightX) {
      popupLocation.x = scrRightX - popupSize.width;
      if (popupLocation.x < scrBounds.x) {
        popupLocation.x = scrBounds.x;
      }
    }
    if (popupBottomY > (long) scrBottomY) {
      popupLocation.y = scrBottomY - popupSize.height;
      if (popupLocation.y < scrBounds.y) {
        popupLocation.y = scrBounds.y;
      }
    }

    return popupLocation;
  }
示例#9
0
 /** 开启游戏 */
 public void startGame(MyIO io) {
   if (io.isApplet() == false) {
     try {
       setCursor(
           Toolkit.getDefaultToolkit()
               .createCustomCursor(
                   Toolkit.getDefaultToolkit().getImage(""), new Point(0, 0), "invisible"));
     } catch (Exception e) {
     }
   }
   m_game = new GameWorld(this, io);
   m_game.start();
 }
示例#10
0
  public AppFrame() {
    super();
    GlobalData.oFrame = this;
    this.setSize(this.width, this.height);
    this.toolkit = Toolkit.getDefaultToolkit();

    Dimension w = toolkit.getScreenSize();
    int fx = (int) w.getWidth();
    int fy = (int) w.getHeight();

    int wx = (fx - this.width) / 2;
    int wy = (fy - this.getHeight()) / 2;

    setLocation(wx, wy);

    this.tracker = new MediaTracker(this);
    String sHost = "";
    try {

      localAddr = InetAddress.getLocalHost();
      if (localAddr.isLoopbackAddress()) {
        localAddr = LinuxInetAddress.getLocalHost();
      }
      sHost = localAddr.getHostAddress();
    } catch (UnknownHostException ex) {
      sHost = "你的IP地址错误";
    }
    //
    this.textLines[0] = "服务器正在运行.";
    this.textLines[1] = "";
    this.textLines[2] = "你的IP地址: " + sHost;
    this.textLines[3] = "";
    this.textLines[4] = "请打开你的手机客户端";
    this.textLines[5] = "";
    this.textLines[6] = "输入屏幕上显示的IP地址.";
    //
    try {
      URL fileURL = this.getClass().getProtectionDomain().getCodeSource().getLocation();
      String sBase = fileURL.toString();
      if ("jar".equals(sBase.substring(sBase.length() - 3, sBase.length()))) {
        jar = new JarFile(new File(fileURL.toURI()));

      } else {
        basePath = System.getProperty("user.dir") + "\\res\\";
      }
    } catch (Exception ex) {
      this.textLines[1] = "exception: " + ex.toString();
    }
  }
示例#11
0
  public ArenaFrame(String title, Arena arena, String background, String battleBG, String cardBG) {
    setTitle(title);
    this.arena = arena;
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    width = (int) screenSize.getWidth();
    height = (int) screenSize.getHeight();
    posX = (width - Constant.BATTLEFIELD_WIDTH) / 2;
    posY = (height - Constant.BATTLEFIELD_HEIGHT - Constant.CARDPANEL_HEIGHT) / 2;
    skill_id = 0;
    addKeyListener(this);
    addMouseListener(this);
    addMouseMotionListener(this);

    setUndecorated(true);
    setExtendedState(JFrame.MAXIMIZED_BOTH);
    c = getContentPane();
    c.setPreferredSize(new Dimension(width, height));
    c.setLayout(null);

    battle_field =
        new BattleFieldPanel(Constant.BATTLEFIELD_WIDTH, Constant.BATTLEFIELD_HEIGHT, arena);
    battle_field.setBounds(posX, posY, Constant.BATTLEFIELD_WIDTH, Constant.BATTLEFIELD_HEIGHT);
    battle_field.setOpaque(false);
    c.add(battle_field);

    card_panel = new CardPanel(Constant.CARDPANEL_WIDTH, Constant.CARDPANEL_HEIGHT, arena);
    card_panel.setBounds(
        posX,
        posY + Constant.BATTLEFIELD_HEIGHT,
        Constant.CARDPANEL_WIDTH,
        Constant.CARDPANEL_HEIGHT);
    card_panel.setOpaque(false);
    c.add(card_panel);

    setSize(width, height);

    setBackground(background);
    setBattleFieldBackground(battleBG);
    setCardPanelBackground(cardBG);

    setResizable(false);
    setLocationRelativeTo(null);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    setVisible(true);
    setFocusable(true);
  }
示例#12
0
 private void loadCursors() {
   Toolkit toolkit = Toolkit.getDefaultToolkit();
   String path = Prefs.getImageJDir() + "images/crosshair-cursor.gif";
   File f = new File(path);
   if (!f.exists()) return;
   // Image image = toolkit.getImage(path);
   ImageIcon icon = new ImageIcon(path);
   Image image = icon.getImage();
   if (image == null) return;
   int width = icon.getIconWidth();
   int height = icon.getIconHeight();
   Point hotSpot = new Point(width / 2, height / 2);
   Cursor crosshairCursor = toolkit.createCustomCursor(image, hotSpot, "crosshair-cursor.gif");
   ImageCanvas.setCursor(crosshairCursor, 0);
 }
示例#13
0
 /** Apply the Y-Axis tick spacing */
 protected void applyYAxisMajorTicks() {
   try {
     String text = yAxisDivisionsField.getText();
     int numTicks = Integer.parseInt(text) + 1;
     // don't change the value unless the user does to avoid inadvertantly
     // changing from autoscale
     if (numTicks < 2) {
       Toolkit.getDefaultToolkit().beep();
     } else if (numTicks != chartAdaptor.getYNumMajorTicks()) {
       chartAdaptor.setYNumMajorTicks(numTicks);
     }
   } catch (NumberFormatException excpt) {
     Toolkit.getDefaultToolkit().beep();
   }
 }
  void jButtonWeights_actionPerformed(ActionEvent e) {
    NumberGeneratorDialog dlg =
        new NumberGeneratorDialog(
            (Frame) null,
            "Weights",
            "Weight of synaptic connections",
            mySynProps.getWeightsGenerator(),
            true);

    // Center the window
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = dlg.getSize();
    if (frameSize.height > screenSize.height) {
      frameSize.height = screenSize.height;
    }
    if (frameSize.width > screenSize.width) {
      frameSize.width = screenSize.width;
    }
    dlg.setLocation(
        (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    dlg.setVisible(true);

    jTextFieldWeights.setText(mySynProps.getWeightsGenerator().toShortString());

    // mySynProps.setWeightsGenerator(dlg.getFinalNumGen());
  }
示例#15
0
  public APCircleWindow() {
    super("AP Circles");
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    String startDirectoryName = System.getProperty("user.dir");
    startDirectory = new File(startDirectoryName);
    // this for convenience, as the program normally starts in graph/display
    //		startDirectory = startDirectory.getParentFile();

    gw = this;

    generalXML = new GeneralXML(graph);

    gp = new APCirclePanel(this);
    getContentPane().add(gp);

    graph = gp.getGraph();

    initView();
    initExperiment();
    initUtility();
    initLayout();
    initMenu();

    setSize(width, height);

    Dimension frameDim = Toolkit.getDefaultToolkit().getScreenSize();
    int posX = (frameDim.width - getSize().width) / 2;
    int posY = (frameDim.height - getSize().height) / 2;
    setLocation(posX, posY);

    setVisible(true);

    gp.requestFocus();
  }
示例#16
0
    /*
     * Executed in event dispatching thread
     */
    @Override
    public void done() {

      try {

        String value = get();
        myMessage.messageChanged(value);

      } catch (InterruptedException e) {
        e.printStackTrace();
      } catch (ExecutionException e) {
        e.printStackTrace();
      } catch (CancellationException e) {
        myMessage.messageChanged("Operation Cancelled");
      } catch (Exception e) {
        e.printStackTrace();
      }

      Toolkit.getDefaultToolkit().beep();
      // startButton.setEnabled(true);
      // cancelButton.setEnabled(false);
      setCursor(null); // turn off the wait cursor
      StartButton.setEnabled(true);
      cancelButton.setEnabled(false);
      taskOutput.append("Done!\n");
    }
示例#17
0
  /** Flashes the visual bell. This class has no other public API. */
  public void flash() {
    if (GuiUtilities.isMacOs()) {
      // Mac OS has a system-wide "visual bell" that looks much better than ours.
      // You can turn this on in the Universal Access preference pane, by checking "Flash the screen
      // when an alert sound occurs".
      // We can take advantage of Apple's hard work if the user has this turned on by "actually"
      // ringing the bell.
      // This doesn't change our "no noise pollution" policy, if you ignore the very unlikely race
      // condition.
      ArrayList<String> result = new ArrayList<String>();
      ArrayList<String> errors = new ArrayList<String>();
      int status =
          ProcessUtilities.backQuote(
              null,
              new String[] {
                "defaults",
                "-currentHost",
                "read",
                "Apple Global Domain",
                "com.apple.sound.beep.flash"
              },
              result,
              errors);
      if (status == 0 && errors.size() == 0 && result.size() == 1 && result.get(0).equals("1")) {
        Toolkit.getDefaultToolkit().beep();
        return;
      }
    }

    setBellVisibility(true);
    timer.restart();
  }
  private void initComponents() {
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

    messagePane.setBackground(contentPane.getBackground());
    messagePane.setEditorKit(new HTMLEditorKit());
    messagePane.setForeground(contentPane.getForeground());

    setSize(450, 360);

    // center the window
    int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth()) / 2;
    int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - getHeight()) / 2;
    setLocation(x, y);

    okButton.addActionListener(this);
  }
示例#19
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();
  }
  private void addMenuItems(JMenu f, String m[]) {

    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

    for (int i = 0; i < m.length; i++) {
      if (m[i].equals("--")) {
        f.addSeparator();
      } else if (m[i].equals("---")) {

        // (ulrivo): full size on screen with less than 640 width
        if (d.width >= 640) {
          f.addSeparator();
        } else {
          return;
        }
      } else {
        JMenuItem item = new JMenuItem(m[i].substring(1));
        char c = m[i].charAt(0);

        if (c != '-') {
          item.setMnemonic(c);
        }

        item.addActionListener(this);
        f.add(item);
      }
    }
  }
示例#21
0
  public static void main(String[] args) throws Exception {
    UIManager.setLookAndFeel(new NimbusLookAndFeel());

    Robot robot = new Robot();
    robot.setAutoDelay(50);

    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();

    SwingUtilities.invokeAndWait(
        new Runnable() {
          public void run() {
            createAndShowGUI();
          }
        });

    toolkit.realSync();

    SwingUtilities.invokeAndWait(
        new Runnable() {
          public void run() {
            Component previewPanel =
                Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
            point = previewPanel.getLocationOnScreen();
          }
        });

    point.translate(5, 5);

    robot.mouseMove(point.x, point.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
  }
示例#22
0
  public introduction(String s) {

    super(s);
    Toolkit tool = this.getToolkit();
    Image image = tool.getImage("login.png");
    this.setIconImage(image);
    // Toolkit tool=this.getToolkit();
    // Image image=tool.getImage("¼ÆËãÆ÷.jpg");
    this.setIconImage(image);
    Icon icon = new ImageIcon("src//ѧÉú½éÉÜ.jpg");
    lab = new JLabel(icon);

    add(lab, BorderLayout.CENTER);
    setVisible(true);
    setBounds(450, 200, 420, 400);
  }
    // Required by ActionListener.
    public void actionPerformed(ActionEvent e) {
      String name = employeeName.getText();

      // User didn't type in a unique name...
      if (name.equals("") || alreadyInList(name)) {
        Toolkit.getDefaultToolkit().beep();
        employeeName.requestFocusInWindow();
        employeeName.selectAll();
        return;
      }

      int index = list.getSelectedIndex(); // get selected index
      if (index == -1) { // no selection, so insert at beginning
        index = 0;
      } else { // add after the selected item
        index++;
      }

      listModel.insertElementAt(employeeName.getText(), index);
      // If we just wanted to add to the end, we'd do this:
      // listModel.addElement(employeeName.getText());

      // Reset the text field.
      employeeName.requestFocusInWindow();
      employeeName.setText("");

      // Select the new item and make it visible.
      list.setSelectedIndex(index);
      list.ensureIndexIsVisible(index);
    }
示例#24
0
  /** Is called when the applet wants to be resized. */
  @Override
  public void appletResize(int width, int height) {
    currentAppletSize.width = width;
    currentAppletSize.height = height;
    final Dimension currentSize = new Dimension(currentAppletSize.width, currentAppletSize.height);

    if (loader != null) {
      AppContext appCtxt = loader.getAppContext();
      if (appCtxt != null) appEvtQ = (java.awt.EventQueue) appCtxt.get(AppContext.EVENT_QUEUE_KEY);
    }

    final AppletPanel ap = this;
    if (appEvtQ != null) {
      appEvtQ.postEvent(
          new InvocationEvent(
              Toolkit.getDefaultToolkit(),
              new Runnable() {
                @Override
                public void run() {
                  if (ap != null) {
                    ap.dispatchAppletEvent(APPLET_RESIZE, currentSize);
                  }
                }
              }));
    }
  }
示例#25
0
 static {
   /* ensure that the necessary native libraries are loaded */
   Toolkit.loadLibraries();
   if (!GraphicsEnvironment.isHeadless()) {
     initIDs();
   }
 }
示例#26
0
  public CALCView() {
    Toolkit.getDefaultToolkit();

    Constants.Get_Splash().Show_Splash_Not_Valid();

    new CALCViewFrame();
  }
示例#27
0
 public MyPanel() {
   // 在我的panel里构造一个坦克
   hero = new Hero(100, 100);
   for (int i = 0; i < enemySize; i++) {
     //			创建敌人的坦克,并加入到敌人坦克集合中。
     EnemyTank et = new EnemyTank((i + 1) * 50, 0);
     et.setColor(0);
     et.setDirection(2);
     Thread t = new Thread(et);
     t.start();
     ets.addElement(et);
   }
   image1 = Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("/bomb_1.gif"));
   image2 = Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("/bomb_2.gif"));
   image3 = Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("/bomb_3.gif"));
 }
示例#28
0
 @Override
 public void done() {
   Toolkit.getDefaultToolkit().beep();
   startButton.setEnabled(true);
   setCursor(null);
   EpubUtils.outputMessage(taskOutput, "Done");
 }
 static {
   Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
   scalex = d.width / 1920.0;
   scaley = d.height / 1080.0;
   if (scalex > 1) scalex = 1;
   if (scaley > 1) scaley = 1;
 }
示例#30
0
  public void drawScreen() {
    Graphics2D g = (Graphics2D) this.getGraphics();

    g.drawImage(buffer, 0, 0, this);
    Toolkit.getDefaultToolkit().sync();
    g.dispose();
  }