Esempio n. 1
0
 /** Displays the inventory window */
 public void inventoryWindow() {
   if (inventoryWin != null) {
     inventoryWin.dispose();
   }
   inventoryWin = new JFrame("Inventory");
   inventoryWin.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   Inventory inv = player.getInventory();
   int y = inv.getSize();
   if (y == 0) {
     displayMessage("Inventory is empty");
     return;
   }
   int cols = 2;
   int rows = (y - y % cols) / cols;
   if (y % cols != 0) rows = rows + 1;
   inventoryWin.setLayout(new GridLayout(0, cols * 2));
   for (int i = 0; i < y; i++) {
     JButton b = new JButton(inv.getItem(i).getName());
     inventoryWin.add(b);
     b.addActionListener(this);
     JButton d = new JButton("drop " + inv.getItem(i).getName());
     inventoryWin.add(d);
     d.addActionListener(this);
   }
   // inventoryWin.setBounds(350, 0, 300, 80*rows);
   inventoryWin.setLocation(mainWindow.getX(), mainWindow.getY() + mainWindow.getHeight());
   inventoryWin.pack();
   inventoryWin.setVisible(true);
 }
 private void setMiddle() {
   Point point = owner.getLocationOnScreen();
   int x = point.x;
   int y = point.y;
   int width = (int) ((owner.getWidth() - this.getWidth()) / 2);
   int height = (int) ((owner.getHeight() - this.getHeight()) / 2);
   this.setLocation(x + width, y + height);
 }
Esempio n. 3
0
 public static void setFrameCenter(JFrame jf) {
   // ЙМол
   Toolkit toolkit = Toolkit.getDefaultToolkit();
   Dimension screen = toolkit.getScreenSize();
   int x = (screen.width - jf.getWidth()) >> 1;
   int y = (screen.height - jf.getHeight() >> 1) - 32;
   jf.setLocation(x, y);
 }
 // Paints JPanel in the center of the screen
 private void paintPanel() {
   // center the dialog
   panel1.setLocation(
       (screen.getWidth() - panel1.getWidth()) / 2, (screen.getHeight() - panel1.getHeight()) / 2);
   // add the dialog to the "modal dialog" layer of the
   // screen's layered pane.
   Container contentPane = screen.getContentPane();
   contentPane.add(panel1);
 }
Esempio n. 5
0
 public static void main(String[] args) {
   JFrame frame = new JFrame("Exercise01");
   JApplet applet = new Exercise01();
   frame.add(applet);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setSize(640, 480);
   frame.setMinimumSize(new Dimension(frame.getWidth(), frame.getHeight()));
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
Esempio n. 6
0
    public void componentResized(ComponentEvent e) {
      Component c = e.getComponent();
      if (c == mainFrame) {
        JFrame theMainFrame = (JFrame) c;
        // update the range of samples to visualize
        //
        //
        //
        //				int newSampleCount = (int)Math.round((theMainFrame.getWidth() - frameWidth) *
        // samplePerPixel / 2);
        //
        //				Selection currSel = zoomStack.get(zoomStack.size() - 1);
        //				int newLeftSamples = Math.min(currSel.beginSelInSamples, newSampleCount);
        //				int leftRemainder = newSampleCount - newLeftSamples;
        //				int newRightSamples = Math.min(myHelper.getLengthInFrames() - currSel.endSelInSamples
        // +1 , newSampleCount);
        //				int rightRemainder = newSampleCount - newRightSamples;
        //				currSel.beginSelInSamples -= newLeftSamples;
        //				currSel.endSelInSamples += newRightSamples;
        //
        //
        //				if (leftRemainder > 0  && rightRemainder == 0) {
        //					newRightSamples = Math.min(myHelper.getLengthInFrames() - currSel.endSelInSamples +
        // 1, leftRemainder);
        //					currSel.endSelInSamples += newRightSamples;
        //				} else if (leftRemainder == 0 && rightRemainder > 0) {
        //					newLeftSamples = Math.min(currSel.beginSelInSamples, rightRemainder);
        //					currSel.beginSelInSamples -= newLeftSamples;
        //				}
        //
        //				System.err.println(currSel.beginSelInSamples + " " + currSel.endSelInSamples);
        //				selBeginSample = currSel.beginSelInSamples;
        //				selEndSample = currSel.endSelInSamples;

        // update the visualization area
        frameHeight = theMainFrame.getHeight();
        frameWidth = theMainFrame.getWidth();
        // his.overViewHeight = frameHeight / 10;
        waveHeight = frameHeight - overViewHeight - controlHeight;
        controlLocY = waveHeight + overViewHeight;
        zoomThresh = frameWidth / 20;
        stemThresh = frameWidth / 8;
        wavePanel.setSize(frameWidth, waveHeight);
        controlPanel.setBounds(0, controlLocY, frameWidth, controlHeight);
        overViewPanel.setSize(frameWidth, overViewHeight);
        wavePanel.refresh(
            false); // just refresh the view. wait till user calls refresh explicitly to update data
        overViewPanel.refresh();

        // samplePerPixel = (selEndSample - selBeginSample + 1) /frameWidth;

        mainFrame.validate();
      }
    }
Esempio n. 7
0
 /** The main routine simply opens a window that shows a PaintWithOffScreenCanvas panel. */
 public static void main(String[] args) {
   JFrame window = new JFrame("PaintWithOffScreenCanvas");
   AdvancedGUIEX1 content = new AdvancedGUIEX1();
   window.setContentPane(content);
   window.setJMenuBar(content.getMenuBar());
   window.pack();
   window.setResizable(false);
   Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
   window.setLocation(
       (screenSize.width - window.getWidth()) / 2, (screenSize.height - window.getHeight()) / 2);
   window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   window.setVisible(true);
 }
Esempio n. 8
0
  @Override
  public void actionPerformed(ActionEvent e) {
    // TODO Auto-generated method stub

    width = frame.getWidth();
    height = frame.getHeight();
    sizeControl.width = width;
    sizeControl.height = height;

    if (info.pressed == true && !showGuide) {
      showGuide = true;
    }

    if (back.pressed == true && showGuide) {
      showGuide = false;
    }

    go.x = width / 2;
    go.y = height / 2;
    info.x = width / 2;
    info.y = height / 2 + 150;
    back.x = 3 * width / 4;
    back.y = height / 2 + 150;

    for (int i = 0; i < boomList.size(); i++) {
      boomList.get(i).updatePosition();
      if (Integer.parseInt(boomList.get(i).toString()) <= 0) {
        boomList.remove(i);
      } else {
        for (int ii = 0; ii < gravList.size(); ii++) {
          gravList.get(ii).pull(boomList.get(i));
          if (boomList.get(i).collide(gravList.get(ii))) {
            boomList.remove(i);
          }
        }
      }
    }

    count--;
    if (count <= 0) {

      double rand1 = Math.random();
      double rand2 = Math.random();
      for (int ii = 0; ii < num; ii++) {
        boomList.add(new boom(rand1 * width, rand2 * height));
      }
      count = delay;
    }

    repaint();
  }
Esempio n. 9
0
  static void GoEnd(JFrame frame, int i) {
    Image background = new ImageIcon("image/final_" + i + ".png").getImage();
    background =
        background.getScaledInstance(frame.getWidth(), frame.getHeight(), Image.SCALE_DEFAULT);
    JLabel back = new JLabel();
    back.setBounds(0, 0, frame.getWidth(), frame.getHeight());
    back.setIcon(new ImageIcon(background));
    frame.add(back, 1);
    frame.validate();
    frame.repaint();
    if (i == 1) { // 烤好
      Talk.say("你成功的通過了這學期", 1);
      Talk.say("這次經驗也讓你對學習產生濃烈的興趣", 1);
      Talk.say("讓你大四成為了神,進而順利畢業", 1);

    } else if (i == 2) { // 系館
      Talk.say("經由你的捐贈", 1);
      Talk.say("資訊系逐漸自成一個校區", 1);
      Talk.say("而在原系館中庭擺放了一個十倍放大的銅像", 1);
      Talk.say("用來紀念資訊系傑出校友─大恩碩像", 1);

    } else if (i == 3) { // 出國
      Talk.say("你放棄了學業,踏上了桌球國手之路", 1);
      Talk.say("過五關斬六將", 1);
      Talk.say("終於成為了世界桌球王", 1);

    } else if (i == 4) { // 0分 game over
      Talk.say("輕輕的我走了", 1);
      Talk.say("正如我輕輕地來", 1);
      Talk.say("我揮一揮衣袖", 1);
      Talk.say("不帶走任何學分", 1);
    } else if (i == 5) { // final
      Talk.say("你完成了final project", 1);
      Talk.say("跟其他同學一起過了OOP", 1);
      Talk.say("不過大四還有更嚴苛的挑戰在等著你", 1);
      Talk.say("同學!加油吧!", 1);
    }
  }
Esempio n. 10
0
 public void run() {
   try {
     progress_frame = new JFrame("Loading...");
     Dimension d = progress_frame.getToolkit().getScreenSize();
     progressBar.setIndeterminate(true);
     progressBar.setBackground(Color.white);
     progress_frame.getContentPane().add(progressBar);
     progress_frame.pack();
     progress_frame.setLocation(
         ((int) d.getWidth() - progress_frame.getWidth()) / 2,
         ((int) d.getHeight() - progress_frame.getHeight()) / 2);
     progress_frame.setVisible(true);
   } catch (NoSuchMethodError nsme) {
   }
 }
Esempio n. 11
0
  private static void createAndShowGUI() {
    // create and setup the window
    frame = new JFrame("Morph");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JComponent newContentPane = new Morph();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);

    // display the window.
    frame.pack();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Dimension screenSize = toolkit.getScreenSize();
    frame.setLocation(
        (screenSize.width - frame.getWidth()) / 2, (screenSize.height - frame.getHeight()) / 2);
    frame.setVisible(true);
  }
Esempio n. 12
0
  public static void main(String args[]) {
    Component comp = new Component();
    System.out.println("Mineblock Development Console: ");
    System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
    System.out.println("Current Version: " + versionNumber);
    frame = new JFrame();
    frame.add(comp);
    frame.pack();

    realSize = new Dimension(frame.getWidth(), frame.getHeight());

    frame.setTitle(name + versionNumber);
    frame.setResizable(true);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    comp.start();
  }
  public acceuil() {
    f = new JFrame("Espace Liaison FTTx");
    f.setSize(700, 700);
    c = f.getContentPane();
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    f.setLocation(dim.width / 2 - f.getWidth() / 2, dim.height / 2 - f.getHeight() / 2);
    progressbar1 = new JProgressBar();
    progressbar1.setMinimum(1);
    progressbar1.setMaximum(100);

    ImageIcon icon = new ImageIcon(".\\src\\images\\icon.png");
    ImageIcon iconc = new ImageIcon(".\\src\\images\\iconc.png");

    b1 = new JButton(icon);
    b2 = new JButton(iconc);
    p1 = new JPanel(new BorderLayout());
    p2 = new JPanel(new BorderLayout());
    p3 = new JPanel();
    lhaut = new JLabel(new ImageIcon(".\\src\\images\\telecom.jpg"));

    p1.add(lhaut, BorderLayout.NORTH);
    p2.add(progressbar1, BorderLayout.NORTH);
    p3.add(b2);
    p3.add(b1);
    p2.add(p3, BorderLayout.CENTER);
    p1.add(p2, BorderLayout.CENTER);
    c.add(p1);

    b1.addActionListener(this);
    b2.addActionListener(this);
    b1.setEnabled(false);
    b2.setEnabled(false);
    f.setResizable(false);
    f.setVisible(true);
    f.pack();
    progress();
    b1.setEnabled(true);
    b2.setEnabled(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
Esempio n. 14
0
  /**
   * @param filenames
   * @exception Exception if internal error
   */
  public ChestImageViewer(String filenames[]) throws Exception {
    DisplayDeviceArea[] displayDeviceAreas = getPresentationAndImageDeviceAreas();
    if (displayDeviceAreas == null) {
      System.err.println("Cannot determine device display areas");
    } else {
      System.err.println("Found " + displayDeviceAreas.length + " device display areas");
      for (int i = 0; i < displayDeviceAreas.length; ++i) {
        System.err.println("[" + i + "] = " + displayDeviceAreas[i]);
        displayDeviceAreas[i].getFrame().setBackground(Color.black);
        displayDeviceAreas[i].getFrame().setVisible(true);
      }

      {
        // Need to actually add something to the unused left display frame, else background will not
        // be set to black on Windows
        JPanel backgroundPanel = new JPanel();
        backgroundPanel.setBackground(Color.black);
        displayDeviceAreas[0].getFrame().getContentPane().add(backgroundPanel);
        displayDeviceAreas[0].getFrame().validate();
      }

      frame = displayDeviceAreas[1].getFrame();

      Container content = frame.getContentPane();
      content.setLayout(new GridLayout(1, 1));
      multiPanel = new JPanel();
      // multiPanel.setBackground(Color.black);
      frameWidth = (int) frame.getWidth();
      frameHeight = (int) frame.getHeight();
      Dimension d = new Dimension(frameWidth, frameHeight);
      // multiPanel.setSize(d);
      multiPanel.setPreferredSize(d);
      multiPanel.setBackground(Color.black);
      content.add(multiPanel);
      // frame.pack();
      content.validate();

      loadMultiPanelFromSpecifiedFiles(filenames);
    }
  }
Esempio n. 15
0
    public void run() {
      adjustToScreenSize =
          (float)
              Math.min(
                  jframe.getWidth(),
                  jframe.getHeight()); // used here, since you can change the screen-Size

      Matrix4f newTranslation = new Matrix4f();
      newTranslation.setIdentity();

      Matrix4f oldcTranslation = new Matrix4f();
      oldcTranslation = camera.getCameraMatrix();

      // world z-Axis-turn
      if (mouseWorldTurn != null) {
        newTranslation.mul(mouseWorldTurn);
        mouseWorldTurn.setIdentity();
      }

      // camera x-Axis-turn
      if (mouseTurn != null) {
        newTranslation.mul(mouseTurn);
        mouseTurn.setIdentity();
      }

      // camera movement
      if (keyMove != null) {
        newTranslation.mul(keyMove);
        keyMove.setIdentity();
      }

      newTranslation.mul(oldcTranslation);

      camera.setCameraMatrix(newTranslation);
      // something still appears to be wrong while turning

      // Trigger redrawing of the render window
      renderPanel.getCanvas().repaint();
    }
Esempio n. 16
0
 private static void initGui() {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception exception) {
     exception.printStackTrace();
   }
   JFrame frame = new JFrame("DarkBot");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLayout(new GridBagLayout());
   Insets noInsets = new Insets(0, 0, 0, 0);
   final JToggleButton sessionsButton = new JToggleButton("Login (0)");
   frame.add(
       sessionsButton,
       new GridBagConstraints(
           0, 0, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0));
   sessionsButton.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           sessions.set(sessionsButton.isSelected());
           synchronized (sessions) {
             sessions.notifyAll();
           }
         }
       });
   final JToggleButton joinsButton = new JToggleButton("Join (0)");
   frame.add(
       joinsButton,
       new GridBagConstraints(
           0, 1, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0));
   joinsButton.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           joins.set(joinsButton.isSelected());
           synchronized (joins) {
             joins.notifyAll();
           }
         }
       });
   final JTextField field = new JTextField();
   frame.add(
       field,
       new GridBagConstraints(
           0, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0));
   final JButton button = new JButton("Start");
   frame.add(
       button,
       new GridBagConstraints(
           1, 2, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0));
   button.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           if (button.getText().startsWith("Start")) {
             field.setEnabled(false);
             spamMessage = field.getText();
             button.setText("Stop");
           } else {
             spamMessage = null;
             button.setText("Start");
             field.setEnabled(true);
           }
         }
       });
   Timer timer =
       new Timer(
           500,
           new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
               sessionsButton.setText(
                   sessionsButton.getText().split(" ")[0]
                       + " ("
                       + Integer.toString(sessionCount.get())
                       + ")");
               joinsButton.setText(
                   joinsButton.getText().split(" ")[0]
                       + " ("
                       + Integer.toString(amountJoined.get())
                       + ")");
             }
           });
   timer.setRepeats(true);
   timer.start();
   frame.pack();
   frame.setSize(500, frame.getHeight());
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
 public boolean isCompletelyOnScreen() {
   Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
   return jFrame.getX() + jFrame.getWidth() < dim.getWidth()
       && jFrame.getY() + jFrame.getHeight() < dim.getHeight();
 }
Esempio n. 18
0
  private void updateInternal(Scene scene, MarioState ms, EnemySimulator enemySim) {
    if (!frame.isShowing()) return;
    int x, y;
    Image image = frame.createImage(frame.getWidth(), frame.getHeight());
    Graphics g = image.getGraphics();

    int mx = (int) (ms.x - scene.originX);
    int my = (int) (ms.y - scene.originY);
    int tx = 20 - mx + 16 * 11;
    int ty = 50 - my + 16 * 11;

    g.setColor(Color.BLACK);
    g.fillRect(0, 0, frame.getWidth(), frame.getHeight());

    g.translate(tx, ty);

    g.setColor(Color.WHITE);
    for (Edge e : scene.floors) {
      g.drawLine(
          (int) (e.x1 - scene.originX),
          (int) (e.y1 - 1 - scene.originY),
          (int) (e.x2 - 2 - scene.originX),
          (int) (e.y2 - 1 - scene.originY));
    }
    g.setColor(Color.CYAN);
    for (Edge e : scene.walls) {
      g.drawLine(
          (int) (e.x1 - 1 - scene.originX),
          (int) (e.y1 - scene.originY),
          (int) (e.x2 - 1 - scene.originX),
          (int) (e.y2 - 2 - scene.originY));
    }
    g.setColor(Color.YELLOW);
    for (Edge e : scene.ceilings) {
      g.drawLine(
          (int) (e.x1 - scene.originX),
          (int) (e.y1 - 1 - scene.originY),
          (int) (e.x2 - 2 - scene.originX),
          (int) (e.y2 - 1 - scene.originY));
    }

    if (targetFloor != null) {
      g.setColor(new Color(100, 100, 255));
      g.fillRect(
          (int) (targetFloor.x1 - scene.originX + 2),
          (int) (targetFloor.y1 + 2 - scene.originY),
          (int) (targetFloor.x2 - targetFloor.x1 - 4.0f),
          3);
    }

    if (planX != null && planY != null) {
      Graphics g2 = g.create();
      if (planIsValid) g2.setColor(Color.GREEN);
      else g2.setColor(Color.PINK);
      g2.translate((int) -scene.originX, (int) -scene.originY);
      g2.drawPolyline(planX, planY, Math.min(planX.length, planY.length));
    }

    // Draw Mario
    // Mario's origin is somewhere at his feet.
    // TODO: if small, he is 12 high, else 24 high.
    // He is 8 wide, centered around x position.
    g.setColor(Color.RED);
    // g.drawLine(mx-8, my-8, mx+7, my+7);
    // g.drawLine(mx-8, my+7, mx+7, my-8);
    g.fillRect(mx - 4, my - (int) ms.height, 8, (int) ms.height);

    // Fire power?  Horizontal line.
    /*if (sanitizedScene.marioMode == 2) {
    int halfY = my - (int)sanitizedScene.marioHeight / 2;
    g.drawLine(mx - 4, halfY, mx + 3, halfY);
    }*/

    /* sanitizedScene. */
    // Can jump? arrow at top.
    /*if (sanitizedScene.marioMayJump) {
    int top = my - (int) sanitizedScene.marioHeight;
    g.drawLine(mx - 4, top + 4, mx, top);
    g.drawLine(mx, top, mx + 3, top + 3);
    }*/

    // On ground? Add a foot-like line.
    /*if (sanitizedScene.marioOnGround) {
    g.drawLine(mx - 2, my - 2, mx + 1, my - 2);
    }*/

    // Carrying? Draw a circle in the middle.
    if (ms.carrying) {
      int halfY = my - (int) ms.height / 2;
      g.drawOval(mx - 3, halfY - 3, 5, 6);
    }

    // TODO: fireballs and such: do I even know where they are?

    // Enemies
    if (enemySim != null) {
      for (Enemy enemy : enemySim.enemies) {
        int ex = (int) (enemy.x - scene.originX);
        int ey = (int) (enemy.y - scene.originY);
        g.setColor(Color.MAGENTA);
        g.drawRect(
            (int) (ex - enemy.width / 2.0f),
            (int) (ey - enemy.height),
            (int) enemy.width - 1,
            (int) enemy.height - 1);
        if (enemy.safeTop) {
          g.setColor(Color.WHITE);
          g.drawLine(
              (int) (ex - enemy.width / 2.0f),
              (int) (ey - enemy.height),
              (int) (ex + enemy.width / 2.0f - 1.0f),
              (int) (ey - enemy.height));
        }
        g.drawString(Integer.toString(enemy.type), ex, ey);
      }
    }

    g.translate(-tx, -ty);
    g.setColor(Color.WHITE);
    g.drawString(Integer.toString((int) (scene.constructTime / 1000)), 30, 50);
    g.drawString(Integer.toString(tx) + "," + Integer.toString(ty), 30, 70);

    Graphics g2 = frame.getGraphics();
    g2.drawImage(image, 0, 0, null);
  }
Esempio n. 19
0
  /**
   * Inizialize frame components
   *
   * @throws CMSException
   * @throws FileNotFoundException
   * @throws IOException
   * @throws GeneralSecurityException
   */
  private void initComponents()
      throws CMSException, FileNotFoundException, IOException, GeneralSecurityException {

    // *********************************

    panel4 = new JPanel();
    label2 = new JLabel();
    textPane1 = new JTextPane();
    panel5 = new JPanel();
    textArea1 = new JTextArea();
    textArea2 = new JTextArea();

    progressBar = new JProgressBar();

    textPane2 = new JTextPane();
    textField1 = new JTextField();
    button1 = new JButton();
    panel6 = new JPanel();
    button2 = new JButton();
    button3 = new JButton();
    button4 = new JButton();
    GridBagConstraints gbc;
    // ======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());
    ((GridBagLayout) contentPane.getLayout()).columnWidths = new int[] {165, 0, 0};
    ((GridBagLayout) contentPane.getLayout()).rowHeights = new int[] {105, 50, 0};
    ((GridBagLayout) contentPane.getLayout()).columnWeights = new double[] {0.0, 1.0, 1.0E-4};
    ((GridBagLayout) contentPane.getLayout()).rowWeights = new double[] {1.0, 0.0, 1.0E-4};

    // ======== panel4 ========
    {
      panel4.setBackground(Color.white);
      panel4.setLayout(new GridBagLayout());
      ((GridBagLayout) panel4.getLayout()).columnWidths = new int[] {160, 0};
      ((GridBagLayout) panel4.getLayout()).rowHeights = new int[] {0, 0, 0};
      ((GridBagLayout) panel4.getLayout()).columnWeights = new double[] {0.0, 1.0E-4};
      ((GridBagLayout) panel4.getLayout()).rowWeights = new double[] {1.0, 1.0, 1.0E-4};

      // ---- label2 ----
      label2.setIcon(
          new ImageIcon(
              "images" + System.getProperty("file.separator") + "logo-freesigner-piccolo.png"));
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.insets.bottom = 5;
      panel4.add(label2, gbc);

      // ---- textPane1 ----
      textPane1.setFont(new Font("Verdana", Font.BOLD, 12));
      textPane1.setText("Lettura\ncertificati\nda token");
      textPane1.setEditable(false);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 1;
      gbc.anchor = GridBagConstraints.NORTHWEST;
      panel4.add(textPane1, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets.bottom = 5;
    gbc.insets.right = 5;
    contentPane.add(panel4, gbc);

    // ======== panel5 ========
    {
      panel5.setBackground(Color.white);
      panel5.setLayout(new GridBagLayout());
      ((GridBagLayout) panel5.getLayout()).columnWidths = new int[] {0, 205, 0, 0};
      ((GridBagLayout) panel5.getLayout()).rowHeights = new int[] {100, 0, 30, 30, 0};
      ((GridBagLayout) panel5.getLayout()).columnWeights = new double[] {1.0, 0.0, 1.0, 1.0E-4};
      ((GridBagLayout) panel5.getLayout()).rowWeights = new double[] {0.0, 0.0, 1.0, 1.0, 1.0E-4};

      // ---- textArea1 ----
      textArea1.setFont(new Font("Verdana", Font.BOLD, 14));
      textArea1.setText("Lettura certificati da token");
      textArea1.setEditable(false);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.gridwidth = 3;
      gbc.fill = GridBagConstraints.VERTICAL;
      gbc.insets.bottom = 5;
      panel5.add(textArea1, gbc);

      // ---- textArea2 ----
      textArea2.setFont(new Font("Verdana", Font.PLAIN, 12));
      textArea2.setText("Ricerca certificati...\n");
      textArea2.setEditable(false);
      textArea2.setColumns(30);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 1;
      gbc.gridwidth = 3;
      gbc.fill = GridBagConstraints.BOTH;
      panel5.add(textArea2, gbc);
      progressBar.setValue(0);
      progressBar.setMaximum(1);
      progressBar.setStringPainted(true);
      progressBar.setBounds(0, 0, 300, 150);

      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 2;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.insets.bottom = 5;
      gbc.insets.right = 5;
      gbc.gridwidth = 3;
      panel5.add(progressBar, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets.bottom = 5;
    contentPane.add(panel5, gbc);

    // ======== panel6 ========
    {
      panel6.setBackground(Color.white);
      panel6.setLayout(new GridBagLayout());
      ((GridBagLayout) panel6.getLayout()).columnWidths = new int[] {0, 0, 0, 0};
      ((GridBagLayout) panel6.getLayout()).rowHeights = new int[] {0, 0};
      ((GridBagLayout) panel6.getLayout()).columnWeights = new double[] {1.0, 1.0, 1.0, 1.0E-4};
      ((GridBagLayout) panel6.getLayout()).rowWeights = new double[] {1.0, 1.0E-4};

      // ---- button2 ----
      button2.setText("Indietro");
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.insets.right = 5;
      button2.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {

              frame.hide();

              FreeSignerSignApplet nuovo = new FreeSignerSignApplet();
            }
          });

      // panel6.add(button2, gbc);

      // ---- button4 ----
      button4.setText("Annulla");
      gbc = new GridBagConstraints();
      gbc.gridx = 2;
      gbc.gridy = 0;
      // panel6.add(button4, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.BOTH;
    contentPane.add(panel6, gbc);
    contentPane.setBackground(Color.white);
    frame = new JFrame();
    frame.setContentPane(contentPane);
    frame.setTitle("Freesigner");
    frame.setSize(300, 150);
    frame.setResizable(false);
    frame.pack();
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((d.width - frame.getWidth()) / 2, (d.height - frame.getHeight()) / 2);

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    timer =
        new Timer(
            10,
            new ActionListener() {

              public void actionPerformed(ActionEvent evt) {
                frame.show();
                if (task.getMessage() != null) {
                  String s = new String();
                  s = task.getMessage();
                  s = s.substring(0, Math.min(60, s.length()));

                  textArea2.setText(s + " ");
                  progressBar.setValue(task.getStatus());
                }
                if (task.isDone()) {
                  timer.stop();

                  // Finalizzo la cryptoki, onde evitare
                  // successivi errori PKCS11 "cryptoki alreadi initialized"

                  if ((task != null)) task.libFinalize();

                  ArrayList slotInfos = task.getSlotInfos();
                  if ((slotInfos == null) || slotInfos.isEmpty()) {

                    frame.show();

                    JOptionPane.showMessageDialog(
                        frame,
                        "Controllare la presenza sul sistema\n"
                            + "della libreria PKCS11 impostata.",
                        "Nessun lettore rilevato",
                        JOptionPane.WARNING_MESSAGE);

                    frame.hide();

                  } else {
                    String st = task.getCRLerror();

                    if (st.length() > 0) {
                      timer.stop();

                      JOptionPane.showMessageDialog(
                          frame,
                          "C'è stato un errore nella verifica CRL.\n" + st,
                          "Errore verifica CRL",
                          JOptionPane.ERROR_MESSAGE);
                      frame.hide();
                      FreeSignerSignApplet nuovo = new FreeSignerSignApplet();
                    }
                    if (task.getDifferentCerts() == 0) {
                      if (task.getCIr() != null) {
                        JOptionPane.showMessageDialog(
                            frame,
                            "La carta "
                                + task.getCardDescription()
                                + " nel lettore "
                                + conf.getReader()
                                + " non contiene certificati",
                            "Attenzione",
                            JOptionPane.WARNING_MESSAGE);

                      } else
                        JOptionPane.showMessageDialog(
                            frame, task.getMessage(), "Errore:", JOptionPane.ERROR_MESSAGE);
                    }

                    frame.hide();

                    // confFrame.createTreeAndTokenNodes(task.getSlotInfos());

                  }
                }
              }
            });
  }
Esempio n. 20
0
 /**
  * factory method to create and display box
  *
  * @param parent owner
  * @param actionList action sequence list
  */
 public static void showActionSequence(
     JFrame parent, List actionList, oclTask curTask, oclDomain curDomain) {
   ActionSequence pw = new ActionSequence(parent, actionList, curTask, curDomain);
   pw.setLocation((int) (0.5 * parent.getWidth()), (int) (0.5 * parent.getHeight()));
   pw.show();
 }
Esempio n. 21
0
 private void setWidth(Map<String, String> arguments, Scope scope) {
   JFrame frame = windowMap.get(getStringFromScope(scope, arguments.get("id")));
   frame.setSize(getIntFromScope(scope, arguments.get("val")), frame.getHeight());
 }
 @Override
 public int getHeight() {
   return _frame.getHeight();
 }
Esempio n. 23
0
  // --------------------------------initGUI------------------------------------
  public void initGUI() {
    bDeployed = bOpponentDeployed = false;
    listAT = new LinkedList();

    frame.setJMenuBar(new GameMenuBar(this));
    panParty = new PartyPanel(200, 480);
    panStatus = new JPanel(null);
    oMap = new Map(600, 350);
    panChat = new ChatPanel(600, 200);

    Container contentPane = frame.getContentPane();

    panParty.setOpaque(true);
    panStatus.setOpaque(true);
    panChat.setOpaque(true);

    panStatus.setPreferredSize(new Dimension(200, 70));

    contentPane.add(panStatus);
    contentPane.add(panParty);
    contentPane.add(oMap);
    contentPane.add(panChat);

    SpringLayout oLayout = new SpringLayout();
    contentPane.setLayout(oLayout);

    oLayout.putConstraint(SpringLayout.WEST, panParty, 0, SpringLayout.WEST, contentPane);
    oLayout.putConstraint(SpringLayout.NORTH, panParty, 0, SpringLayout.NORTH, contentPane);
    oLayout.putConstraint(SpringLayout.WEST, panStatus, 0, SpringLayout.WEST, contentPane);
    oLayout.putConstraint(SpringLayout.SOUTH, panStatus, 0, SpringLayout.SOUTH, contentPane);
    oLayout.putConstraint(SpringLayout.EAST, oMap, 0, SpringLayout.EAST, contentPane);
    oLayout.putConstraint(SpringLayout.NORTH, oMap, 0, SpringLayout.NORTH, contentPane);
    oLayout.putConstraint(SpringLayout.WEST, panChat, 0, SpringLayout.EAST, panStatus);
    oLayout.putConstraint(SpringLayout.NORTH, panChat, 0, SpringLayout.SOUTH, oMap);
    oLayout.putConstraint(SpringLayout.EAST, contentPane, 0, SpringLayout.EAST, panChat);
    oLayout.putConstraint(SpringLayout.SOUTH, contentPane, 0, SpringLayout.SOUTH, panChat);

    panChat.validate();
    panChat.setVisible(true);

    Insets oInsets = panStatus.getInsets();
    int nX = oInsets.left + 5;
    int nY = oInsets.top + 5;

    lblStatus1 = new JLabel("Not Connected...");
    lblStatus2 = new JLabel("No Party Formed...");
    lblStatus3 = new JLabel();

    Dimension oSize = lblStatus1.getPreferredSize();

    lblStatus1.setBounds(nX, nY, 180, oSize.height);
    nY += oSize.height + 7;
    lblStatus2.setBounds(nX, nY, 180, oSize.height);
    nY += oSize.height + 7;
    lblStatus3.setBounds(nX, nY, 180, oSize.height);

    panStatus.add(lblStatus1);
    panStatus.add(lblStatus2);
    panStatus.add(lblStatus3);

    frame.pack();
    frame.setResizable(false);
    frame.setLocation(
        ((scrBounds.x + scrBounds.width - frame.getWidth()) / 2),
        ((scrBounds.y + scrBounds.height - frame.getHeight()) / 2));

    oMap.addKeyListener(oMap);
    oMap.setButtonEvents(this);
  }
Esempio n. 24
0
  static String[] input(int d, int m, int y) { // input frame for schedule
    String[] out = new String[4]; // appointment info storage

    final String[] doctors = {"Dr. Whitehead", "Dr. Namie", "Dr. Liddell"};

    final JFrame input = new JFrame("Make Appointment");
    Container pane1;
    JPanel pan = new JPanel(null);
    JLabel doctor = new JLabel("Choose your Doctor:");
    JLabel da = new JLabel("Date:");
    /*JLabel day=new JLabel(Integer.toString(d));
    JLabel mo=new JLabel("Month:");
    JLabel month=new JLabel(Integer.toString(m));
    JLabel ye=new JLabel("Year:");
    JLabel year=new JLabel(Integer.toString(y));*/
    JLabel time = new JLabel("Appointment Time:");
    JButton submit = new JButton("Submit");
    docName = new JComboBox(doctors);

    JSpinner timeSpinner = new JSpinner(new SpinnerDateModel());
    JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(timeSpinner, "hh:mm a");
    timeSpinner.setEditor(timeEditor);
    timeSpinner.setValue(new Date());

    JSpinner dateSpinner = new JSpinner(new SpinnerDateModel());
    JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(dateSpinner, "MMM/dd/yyyy");
    dateSpinner.setEditor(dateEditor);
    dateSpinner.setValue(new Date());

    input.setSize(330, 375); // Set size to 400x400 pixels
    pane1 = input.getContentPane();
    pane1.setLayout(null); // Apply null layout
    pan.setLayout(new GridLayout(4, 2, 20, 50));
    pane1.setSize((int) (input.getHeight() / 2), (int) (input.getWidth() / 2));
    pane1.setLocation(
        input.getHeight() - ((int) (input.getHeight() / 2)),
        input.getWidth() - ((int) (input.getWidth() / 2))); // trying to center failed
    input.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // Close when X is clicked
    pane1.add(pan);
    // pan.add(ye);
    // pan.add(year);
    pan.add(da);
    pan.add(dateSpinner);
    pan.add(time);
    pan.add(timeSpinner);
    pan.add(doctor);
    pan.add(docName);
    pan.add(submit);

    submit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            fmain.setVisible(true);
            input.setVisible(false);
          }
        });

    pan.setBounds(0, 0, 320, 335);
    input.setResizable(false);
    input.setVisible(true);
    return out;
  }