Example #1
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   setBackground(Color.black);
   add(l);
   add(s);
   drawSpecialLines(g);
   g.setColor(Color.white);
   g.fillOval(30, 100, 75, 75);
   g.setColor(Color.blue);
   g.fillRect(getWidth() / 2, getHeight() / 2, (int) bl, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 40, (int) gl, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 80, (int) ll, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 120, (int) sl, 10);
   g.drawImage(bullet.getImage(), 30, getHeight() / 2 - 10, 20, 20, null);
   g.drawImage(grenade.getImage(), 30, getHeight() / 2 + 40 - 10, 20, 20, null);
   g.drawImage(laser.getImage(), 30, getHeight() / 2 + 80 - 10, 20, 20, null);
   g.drawImage(shotgun.getImage(), 30, getHeight() / 2 + 120 - 10, 20, 20, null);
   g.setColor(Color.yellow);
   if (gunTrack == 0) {
     g.drawRect(30, getHeight() / 2 - 10, 20, 20);
   } else if (gunTrack == 1) {
     g.drawRect(30, getHeight() / 2 + 40 - 10, 20, 20);
   } else if (gunTrack == 2) {
     g.drawRect(30, getHeight() / 2 + 80 - 10, 20, 20);
   } else {
     g.drawRect(30, getHeight() / 2 + 120 - 10, 20, 20);
   }
 }
Example #2
0
  /** Creates new form QueueView */
  public QueueView(
      ScanService scanService,
      EventManager eventManager,
      QueueManager queueProcessor,
      Queue queue,
      Repo repo) {
    this.queue = queue;
    this.scanService = scanService;
    this.repo = repo;
    this.queueProcessor = queueProcessor;
    this.eventManager = eventManager;
    this.setTitle("Queue: " + repo.getDescription());
    initComponents();
    TableUtils.setTimeColumn(tblQueue, "Started");
    TableUtils.setTimeColumn(tblQueue, "Completed");
    //        TableRowSorter rowSorter = new TableRowSorter( tblQueue.getModel());
    //        tblQueue.setRowSorter( rowSorter );

    File scanDir = scanService.getCurrentScanDir();
    if (scanDir != null) {
      lblCurrentDirVal.setText(scanDir.getAbsolutePath());
    }

    eventManager.registerEventListener(this, ScanDirEvent.class);
    eventManager.registerEventListener(this, ScanEvent.class);
    eventManager.registerEventListener(this, QueueProcessEvent.class);

    ImageIcon imageIcon = new ImageIcon(getClass().getResource("/logo16x16.png"), "");
    setIconImage(imageIcon.getImage());

    showNextScan();

    initCurrent();
  }
Example #3
0
  public void createGUI() {
    setLayout(new BorderLayout());

    buttonPanel.add(submitButton);
    buttonPanel.setSize(400, 400);
    hostPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    ImageIcon imageIcon = new ImageIcon("images/logo.png"); // load the image to a imageIcon
    Image image = imageIcon.getImage(); // transform it
    Image newimg =
        image.getScaledInstance(600, 120, java.awt.Image.SCALE_SMOOTH); // scale it the smooth way
    imageIcon = new ImageIcon(newimg); // transform it back
    JLabel scrabbleLabel = new JLabel(imageIcon, SwingConstants.CENTER);
    add(scrabbleLabel, BorderLayout.NORTH);
    gbc.gridx = 0;
    gbc.gridy = 0;
    hostPanel.add(hostLabel, gbc);
    gbc.gridx = 0;
    gbc.insets = new Insets(46, 0, 46, 0);
    gbc.gridy = 1;
    hostPanel.add(portLabel, gbc);
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.anchor = GridBagConstraints.EAST;
    hostPanel.add(portTF, gbc);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.gridwidth = 2;
    hostPanel.add(buttonPanel, gbc);
    add(hostPanel, BorderLayout.CENTER);
  }
Example #4
0
    private void paintSprites(List<Sprite> sprites) {

      if (sprites != null) {
        for (int i = 0; i < sprites.size(); i++) {

          // get all sprites with getresource
          URL imagePath = this.getClass().getResource(sprites.get(i).getImageName().toString());
          ImageIcon icon = new ImageIcon(imagePath);
          JLabel picLabel = new JLabel(icon);
          picLabel.setBounds(
              sprites.get(i).getX(),
              sprites.get(i).getY(),
              icon.getIconWidth(),
              icon.getIconHeight());
          this.add(picLabel);
        }

        ImageIcon bgImageIcon =
            new ImageIcon(this.getClass().getResource(controller.getGameModel().getBkgURL()));
        Image reImage = bgImageIcon.getImage();
        reImage =
            reImage.getScaledInstance(
                Dimensions.GAME_MAKER_RIGHT_PANEL_WIDTH,
                Dimensions.GAME_MAKER_RIGHT_PANEL_HEIGHT,
                Image.SCALE_SMOOTH);
        bgImageIcon = new ImageIcon(reImage);
        JLabel bkgImageLabel = new JLabel(bgImageIcon);
        bkgImageLabel.setBounds(
            0,
            Dimensions.GAME_MAKER_RIGHT_PANEL_Y,
            Dimensions.GAME_MAKER_RIGHT_PANEL_WIDTH,
            Dimensions.GAME_MAKER_RIGHT_PANEL_HEIGHT);
        this.add(bkgImageLabel);
      }
    }
  public void paint(Graphics g) {
    Graphics2D graficos = (Graphics2D) g;
    graficos.drawImage(fundo, 0, 0, null);

    if (emJogo) {
      graficos.drawImage(nave.getImagem(), nave.getX(), nave.getY(), this);

      List<Missel> misseis = nave.getMisseis();

      for (int i = 0; i < misseis.size(); i++) {
        Missel m = (Missel) misseis.get(i);
        graficos.drawImage(m.getImagem(), m.getX(), m.getY(), this);
      }

      for (int i = 0; i < inimigos.size(); i++) {
        Inimigo in = inimigos.get(i);
        graficos.drawImage(in.getImagem(), in.getX(), in.getY(), this);
      }

      graficos.setColor(Color.white);
      graficos.drawString("Inimigos: " + inimigos.size(), 5, 15);

    } else {
      ImageIcon fimJogo = new ImageIcon(Main.class.getResource("/res/game_over.jpg"));

      graficos.drawImage(fimJogo.getImage(), 0, 0, null);
    }
    g.dispose();
  }
  public Character() {
    try {
      ImageIcon iiP = new ImageIcon(resourcesPath + imageCount + ".png");
      this.image = iiP.getImage();
      image = iiP.getImage();
    } catch (Exception e) {
      System.out.println("Exception: " + e.getMessage());
    }

    int width =
        Integer.parseInt(
            RossLib.parseXML(resourcesPath + "character_data.xml", "character", "bobert", "width"));
    int height =
        Integer.parseInt(
            RossLib.parseXML(
                resourcesPath + "character_data.xml", "character", "bobert", "height"));
    name = RossLib.parseXML(dataPath, "character", "bobert", "name");
    worldObjectType = WorldObjectType.CHARACTER;
    collisionType = CollisionType.IMPASSABLE;
    horizVelocity = 0;
    int defaultX = (int) (Main.B_WINDOW_WIDTH * 0.5);
    int defaultY = 350;
    initBoxes(
        new Rectangle(
            defaultX, defaultY,
            width, height));
  }
Example #7
0
 // 添加背景
 protected void paintComponent(Graphics g) {
   // TODO Auto-generated method stub
   super.paintComponent(g);
   ImageIcon background = new ImageIcon("pictures\\adminleft1.png");
   Image bg = background.getImage();
   g.drawImage(bg, 0, 0, frameWidth / 4, frameHeight, null);
 }
Example #8
0
  private void drawMapBackground(Graphics2D g2d) {
    int mapPieceX1 = (startX / MAP_PIECE_WIDTH) + 1;
    int mapPieceX2 = (endX / MAP_PIECE_WIDTH) + 1;
    int mapPieceY1 = (startY / MAP_PIECE_HEIGHT) + 1;
    int mapPieceY2 = (endY / MAP_PIECE_HEIGHT) + 1;

    for (int y = mapPieceY1; y <= mapPieceY2; y++) {
      for (int x = mapPieceX1; x <= mapPieceX2; x++) {
        String mapNumber = (x < 10 ? "0" + x : "" + x) + (y < 10 ? "0" + y : "" + y);
        String mapName = "/maps/map" + mapNumber + ".jpg";

        ImageIcon icon = null;
        if (mapCache.containsKey(mapName)) {
          icon = (ImageIcon) mapCache.get(mapName);
        } else {
          icon = ImageUtil.createImageIcon(mapName);
          mapCache.put(mapName, icon);
        }

        if (icon != null) {
          int pieceX = (x - 1) * MAP_PIECE_WIDTH;
          int pieceY = (y - 1) * MAP_PIECE_HEIGHT;
          icon.paintIcon(this, g2d, pieceX - startX, pieceY - startY);
        }
      }
    }
  }
Example #9
0
 /**
  * Gets an Image.
  *
  * @return the image
  */
 public Image getImage() {
   ImageIcon icon = getIcon();
   if (icon != null) {
     return icon.getImage();
   }
   return null;
 }
Example #10
0
File: frame.java Project: ApolZ/GUI
  public static void main(String[] args) {
    JPanel panel = new JPanel();
    JPanel sub1 = new PushCounterPanel(Color.yellow);
    JPanel sub2 = new CalculatorPanel();
    panel.add(sub1);
    panel.add(sub2);

    // 八爪猫实力上镜展示panel,label,imageIcon
    ImageIcon icon = new ImageIcon("resource/octocat.jpeg");
    icon.setImage(icon.getImage().getScaledInstance(30, 30, Image.SCALE_DEFAULT));
    JLabel label1 =
        new JLabel(
            "Cat on the left", icon, SwingConstants.CENTER); // 第三个参数,label在panel中水平方向定位,默认为CENTER
    JLabel label2 = new JLabel("Cat on the right");
    label2.setIcon(icon);
    label2.setHorizontalTextPosition(SwingConstants.LEFT); // label中,文字相对图像的水平位子,默认为RIGHT
    label2.setVerticalTextPosition(SwingConstants.BOTTOM); // label中,文字相对图像的垂直位子,默认为CENTER
    JPanel sub3 = new JPanel();
    sub3.add(label1);
    sub3.add(label2);
    sub3.setPreferredSize(new Dimension(150, 120)); // subPanel大小,否则以一行形式往右延展
    panel.add(sub3);

    JPanel sub4 = new CheckBoxPanel();
    panel.add(sub4);
    JPanel sub5 = new RadioButtonPanel();
    panel.add(sub5);

    JFrame jframe = new JFrame("HelloWorld");
    jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jframe.getContentPane().add(panel); // 自建类
    jframe.pack(); // 必备,否则无初始大小
    jframe.setVisible(true); // 必备,否则不可见
  }
Example #11
0
  public VentanaJuego(Canasta c) {
    // tamaño e inicializacion de contenedores
    setSize(1000, 800);
    Image canasta;
    ImageIcon imageIcon = new ImageIcon("src/basketArcade/image/basket_ball_court.jpg");
    canasta = imageIcon.getImage();
    canasta = canasta.getScaledInstance(1000, 800, java.awt.Image.SCALE_SMOOTH);
    this.lCancha = new JPanel();
    this.puntuacion = new JPanel();
    panelPoints = new JPanel();

    lPuntos = new JLabel("0");
    panelPoints.add(lPuntos);
    lCancha.setLayout(null);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    // botones
    pausa = new JButton("Pausa");
    // lista de puntos
    puntuacion.setLayout(new BorderLayout());
    JPanel pane = new JPanel();
    pane.add(pausa);
    puntuacion.add(pane, BorderLayout.NORTH);
    // introduccion de los paneles en en contenedor de la ventana
    getContentPane().add(panelPoints, BorderLayout.WEST);
    getContentPane().add(lCancha, BorderLayout.CENTER);
    getContentPane().add(puntuacion, BorderLayout.EAST);
    pause = false;
    lCancha.add(c.getlCanasta());
    // no se permite redimensionar la ventana
    setResizable(false);
    setVisible(true);
  }
Example #12
0
  public static void attachIcon(Window frame) {
    if (ICONS == null) {
      List<Image> loadedIcons = new ArrayList<Image>();
      ClassLoader loader = LFrame.class.getClassLoader();
      for (int size : SIZES) {
        URL url = loader.getResource(PATH + size + ".png");
        if (url != null) {
          ImageIcon icon = new ImageIcon(url);
          loadedIcons.add(icon.getImage());
          if (size == DEFAULT_SIZE) {
            DEFAULT_ICON = icon.getImage();
          }
        }
      }
      ICONS = loadedIcons;
    }

    boolean success = false;
    try {
      if (ICONS != null && !ICONS.isEmpty()) {
        Method set = frame.getClass().getMethod("setIconImages", List.class);
        set.invoke(frame, ICONS);
        success = true;
      }
    } catch (Exception e) {
    }

    if (!success && frame instanceof JFrame && DEFAULT_ICON != null) {
      ((JFrame) frame).setIconImage(DEFAULT_ICON);
    }
  }
  // Grafiskā lietotāja interfeisa inicializācija
  private void getGUI() {
    JFrame frame = new mainForm();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setVisible(true);
    frame.setTitle("Your Monitoring Agent");
    String icoPath = "./images/eye.gif";
    ImageIcon img = new ImageIcon(icoPath);

    if (!SystemTray.isSupported()) {
      System.out.println("SystemTray is not supported");
      return;
    }
    final TrayIcon trayIcon = new TrayIcon(img.getImage());
    final SystemTray tray = SystemTray.getSystemTray();

    trayIcon.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            frame.setVisible(true);
          }
        });

    try {
      tray.add(trayIcon);
    } catch (AWTException e) {
      JOptionPane.showMessageDialog(
          null, "TrayIcon could not be added.", "Alert", JOptionPane.ERROR_MESSAGE);
    }
  }
Example #14
0
  @Override
  public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setColor(new Color(0, 0, 0));

    for (int j = 0; j < 8; j++) {
      ImageIcon ii = new ImageIcon(this.getClass().getResource("/images/" + 2 + ".png"));
      g2.drawImage(ii.getImage(), j * 70, 560, this);
    }

    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        ImageIcon ii =
            new ImageIcon(this.getClass().getResource("/images/" + mGame[i][j] + ".png"));
        g2.setFont(new Font("ARIAL", Font.BOLD, 60));
        if (mGame[i][j] == OK) {
          g2.drawString(" " + logic.getScore(), j * 70, i * 70);
        }
        if (mGame[i][j] == ERROR) {
          g2.drawString("-3", j * 70, i * 70);
        }
        g2.drawImage(ii.getImage(), j * 70, i * 70, this);
        g2.setFont(new Font("ARIAL", Font.BOLD, 20));
        g2.setColor(Color.DARK_GRAY);

        g2.drawString("Seus Tijolos : " + logic.getScore(), 10, 600);
        g2.drawString("Quantidade : " + QUANTIDADE_TIJOLO, 200, 600);
        g2.drawString("Tempo : " + time, 450, 600);
      }
    }
  }
Example #15
0
 public PlayGamePanel(JFrame frame, BoardConfiguration bc) {
   this.bc = bc;
   this.frame = frame;
   ImageIcon icon = new ImageIcon("ent.jpg");
   this.image = icon.getImage();
   this.one = new TransparentButton("1 Player");
   this.two = new TransparentButton("2 Players");
   this.three = new TransparentButton("3 Players");
   this.four = new TransparentButton("4 Players");
   this.setSize(frame.getSize());
   this.setLocation(0, 0);
   this.setLayout(null);
   one.setBounds(450, 140, 200, 40);
   two.setBounds(450, 200, 200, 40);
   three.setBounds(450, 260, 200, 40);
   four.setBounds(450, 320, 200, 40);
   this.add(one);
   this.add(two);
   this.add(three);
   this.add(four);
   this.back = new TransparentButton("Back");
   back.setBounds(450, 380, 200, 40);
   this.add(back);
   this.one.setFont(new Font("calibri", Font.ITALIC, 30));
   this.two.setFont(new Font("calibri", Font.ITALIC, 30));
   this.three.setFont(new Font("calibri", Font.ITALIC, 30));
   this.four.setFont(new Font("calibri", Font.ITALIC, 30));
   this.back.setFont(new Font("calibri", Font.ITALIC, 30));
   this.one.addMouseListener(this);
   this.two.addMouseListener(this);
   this.three.addMouseListener(this);
   this.four.addMouseListener(this);
   this.back.addMouseListener(this);
   this.back.setForeground(Color.red);
 }
  /**
   * Sets the row data.
   *
   * @param list the list data to convert to row data
   */
  public void setRowData(List<TopicUserCluster> list) {
    removeAllRow();
    for (int row = 0; row < list.size(); row++) {
      TopicUserCluster topicUser = (TopicUserCluster) list.get(row);
      Vector<Object> rowData = new Vector<Object>();

      // user profile image
      ImageIcon profileImage = null;
      try {
        profileImage = new ImageIcon(new URL(topicUser.getUserProfileImage()));
        System.out.println("profile image == " + profileImage.getDescription());
      } catch (Exception ex) {
        ex.printStackTrace();
      }

      rowData.add(row + 1);
      rowData.add(topicUser.getWebsiteId());
      rowData.add(topicUser.getTopicId());
      rowData.add(topicUser.getUserId());
      rowData.add(topicUser.getUserName());
      if (profileImage == null) rowData.add("");
      else rowData.add(profileImage);
      rowData.add(topicUser.getUserUrl());
      rowData.add(topicUser.isTopicUser());
      rowData.add(topicUser.getCluster());
      rowData.add(convertScale(topicUser.getAuthority(), 2));
      rowData.add(convertScale(topicUser.getTopicScore(), 2));
      rowData.add(convertScale(topicUser.getAuthorityTopicScore(), 2));
      tableModel.insertRow(row, rowData);
    }
  }
Example #17
0
  private void initGUI() {

    removeAll();

    ImageIcon kbdIcon = app.getScaledIcon("cas-keyboard.png");

    iconHeight = kbdIcon.getIconHeight();
    iconDimension = new Dimension(iconHeight, iconHeight);
    btnShowKeyboard = new MyToggleButton(kbdIcon, iconHeight);

    createTextButtons();

    add(btnUseAsText);
    add(btnTextColor);
    add(btnBold);
    add(btnItalic);

    btnShowKeyboard.addActionListener(this);
    add(btnShowKeyboard);
    // add(btnTextSize); //TODO: Fix text size

    popupBtnList = newPopupBtnList();
    toggleBtnList = newToggleBtnList();

    updateStyleBar();
  }
  /**
   * Sets the image to display in the frame.
   *
   * @param imageIcon the image to display in the frame
   */
  public void setImageIcon(ImageIcon imageIcon) {
    // Intercept the action to validate the user icon and not the default
    super.setImageIcon(imageIcon.getImage());
    this.isDefaultImage = false;

    this.currentImage = imageIcon.getImage();
  }
  protected final void doActionPerformed(ActionEvent evt) {
    try {
      ApplicationDiagram diag =
          (ApplicationDiagram) (ApplicationContext.getFocusManager().getFocusObject());
      Point clickPosition = getDiagramLocation(evt);
      if (clickPosition == null)
        clickPosition = GraphicUtil.rectangleGetCenter(diag.getMainView().getViewRect());
      java.awt.Image image = SRSystemClipboard.getClipboardImage();
      if (image == null) return;
      DbObject diagGo = diag.getDiagramGO();
      Db db = diagGo.getDb();

      ImageIcon icon = new ImageIcon(image);
      int imageHeigth = icon.getIconHeight();
      int imageWidth = icon.getIconWidth();

      db.beginTrans(Db.WRITE_TRANS, LocaleMgr.action.getString("pasteDiagramImage"));

      DbObject imageGo = diagGo.createComponent(DbGraphic.fImageGoDiagramImage.getMetaClass());
      imageGo.set(DbGraphic.fImageGoDiagramImage, image);
      imageGo.set(
          DbGraphic.fGraphicalObjectRectangle,
          new Rectangle(
              clickPosition.x - (imageWidth / 2),
              clickPosition.y - (imageHeigth / 2),
              imageWidth,
              imageHeigth));
      db.commitTrans();
    } catch (Exception e) {
      org.modelsphere.jack.util.ExceptionHandler.processUncatchedException(
          ApplicationContext.getDefaultMainFrame(), e);
    }
  }
Example #20
0
  public ImageIcon getImageIcon() {
    if (mImageIcon == null) {
      mImageIcon = new ImageIcon(mPath);

      /** If the image is too big, scale it down to max pixel size squared */
      if (mImageIcon.getIconWidth() > sMAX_IMAGE_DIMENSION
          || mImageIcon.getIconHeight() > sMAX_IMAGE_DIMENSION) {
        /**
         * getScaled instance will correct any negative value to the correct value, maintaining
         * original aspect ratio. So, we only scale the larger value, and allow the image class to
         * determine the correct value for the other measurement
         */
        int height = -1;
        int width = -1;

        /** Use the larger width or height value to determine the scaling factor */
        if (mImageIcon.getIconHeight() > mImageIcon.getIconWidth()) {
          height = sMAX_IMAGE_DIMENSION;
        } else {
          width = sMAX_IMAGE_DIMENSION;
        }

        mImageIcon =
            new ImageIcon(
                mImageIcon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH));
      }
    }

    return mImageIcon;
  }
Example #21
0
 protected void buildTabPane() {
   this.tabPane = new JTabbedPane();
   this.tabPane.setTabPlacement(JTabbedPane.RIGHT);
   ImageIcon icon = new ImageIcon(getClass().getResource("typing.gif"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Text", icon, new TextPanel(this));
   icon = new ImageIcon(getClass().getResource("chat.jpg"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("IRC", icon, new IRCPanel(this));
   icon = new ImageIcon(getClass().getResource("www.png"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Http", icon, new HttpPanel(this));
   icon = new ImageIcon(getClass().getResource("Email.png"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Email", icon, new EmailPanel(this));
   icon = new ImageIcon(getClass().getResource("twitter.png"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Twitter", icon, new TwitterPanel(this));
   icon = new ImageIcon(getClass().getResource("eye.gif"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Vision", icon, new JPanel());
   icon = new ImageIcon(getClass().getResource("brain.gif"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Bot", icon, new ContextPanel(this));
   icon = new ImageIcon(getClass().getResource("DrawingHands.jpg"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Self", icon, new SelfPanel(this));
   icon = new ImageIcon(getClass().getResource("log-icon.png"));
   icon = new ImageIcon(icon.getImage().getScaledInstance(45, 45, Image.SCALE_SMOOTH));
   this.tabPane.addTab("Log", icon, new StatusPanel(this));
 }
          /** Creates full size and thumbnail versions of the target image files. */
          @Override
          protected Void doInBackground() throws Exception {
            for (int i = 0; i < Length; i++) {
              ImageIcon icon;
              icon = createImageIcon(imagedir + imageFileNames[i], imageCaptions[i]);
              ThumbnailAction thumbAction;
              if (icon != null) {

                ImageIcon Icon = new ImageIcon(getScaledImage(icon.getImage(), 640, 480));

                ImageIcon thumbnailIcon = new ImageIcon(getScaledImage(icon.getImage(), 64, 64));

                thumbAction = new ThumbnailAction(Icon, thumbnailIcon, imageCaptions[i]);

              } else {
                // the image failed to load for some reason
                // so load a placeholder instead
                thumbAction =
                    new ThumbnailAction(placeholderIcon, placeholderIcon, imageCaptions[i]);
              }
              publish(thumbAction);
            }
            // unfortunately we must return something, and only null is valid to
            // return when the return type is void.
            return null;
          }
Example #23
0
  /*Add button to master panel*/
  private void addHistoryButton(JFrame frame, JPanel panel) {
    ImageIcon buttonImage = new ImageIcon("assets\\other\\button.png");
    ImageIcon buttonPressedImage = new ImageIcon("assets\\other\\buttonPressed.png");
    // button
    JPanel buttonHolder = new JPanel();
    this.searchButton = new JButton("MATCH HISTORY");
    this.searchButton.setPreferredSize(new Dimension(222, 50));
    this.searchButton.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 10)); // custom font
    this.searchButton.setForeground(Color.WHITE); // text color
    this.searchButton.setBackground(Color.DARK_GRAY);
    this.searchButton.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    this.searchButton.setHorizontalTextPosition(AbstractButton.CENTER);
    // search button background image
    // regular button
    Image tempImage = buttonImage.getImage();
    Image newTempImg = tempImage.getScaledInstance(222, 50, Image.SCALE_SMOOTH);
    buttonImage = new ImageIcon(newTempImg);
    // pressed button
    Image tempImage2 = buttonPressedImage.getImage();
    Image newTempImg2 = tempImage2.getScaledInstance(222, 50, Image.SCALE_SMOOTH);
    buttonPressedImage = new ImageIcon(newTempImg2);
    this.searchButton.setIcon(buttonImage);
    this.searchButton.setRolloverIcon(buttonPressedImage);

    this.searchButton.addActionListener(this);
    buttonHolder.add(this.searchButton);
    buttonHolder.setOpaque(false);
    panel.add(buttonHolder);
  }
Example #24
0
  private BufferedImage generateFrame(GifFrame frame) {
    int width = frame.getColumns() * CELL_WIDTH;
    BufferedImage img =
        new BufferedImage(width, frame.getRows() * CELL_HEIGHT + TEXT_AREA_HEIGHT, IMAGE_TYPE_GIF);
    Graphics graphics = img.getGraphics();
    for (int row = 0; row < frame.getRows(); row++) {
      for (int col = 0; col < frame.getColumns(); col++) {
        ImageIcon icon =
            new ImageIcon(
                "site/images/" + frame.getBoard().get(row, col).getImageFilename() + ".png");
        graphics.drawImage(icon.getImage(), col * CELL_WIDTH, row * CELL_HEIGHT, null);
      }
    }

    for (BoxOverlay overlay : frame.getOverlays()) {
      graphics.setColor(overlay.getColor());
      Rectangle rect = overlay.getRectangle();
      int rect_x = rect.getLeft() * CELL_WIDTH - OVERLAY_PADDING;
      int rect_y = rect.getTop() * CELL_HEIGHT - OVERLAY_PADDING;
      int rect_width = (rect.getRight() - rect.getLeft() + 1) * CELL_WIDTH + 2 * OVERLAY_PADDING;
      int rect_height = (rect.getBottom() - rect.getTop() + 1) * CELL_HEIGHT + 2 * OVERLAY_PADDING;
      graphics.drawRect(rect_x, rect_y, rect_width, rect_height);
      graphics.drawRect(rect_x - 1, rect_y - 1, rect_width + 2, rect_height + 2);
    }

    graphics.setColor(FONT_COLOR);
    graphics.setFont(FONT);
    FontMetrics fm = graphics.getFontMetrics();
    graphics.drawString(
        frame.getText(),
        width / 2 - fm.stringWidth(frame.getText()) / 2,
        frame.getRows() * CELL_HEIGHT + TEXT_AREA_HEIGHT / 2 + fm.getHeight() / 2);

    return img;
  }
 final void initHuman() {
   String sql = "Select * from tblHuman where id = ?";
   try (Connection cn = Tools.getConn();
       PreparedStatement pst = cn.prepareStatement(sql); ) {
     pst.setInt(1, Integer.parseInt(vRow.get(0).toString()));
     ResultSet rs = pst.executeQuery();
     if (rs.next()) {
       txtUserName.setText(rs.getString(2));
       txtBirthDay.setDate(rs.getDate(3));
       txtGender.setText(rs.getString(4));
       txtBirthPlace.setText(rs.getString(5));
       txtNativeCountry.setText(rs.getString(6));
       txtNation.setText(rs.getString(7));
       txtReligion.setText(rs.getString(8));
       txtOccupation.setText(rs.getString(9));
       txtWorkPlace.setText(rs.getString(10));
       txtIDCard.setText(rs.getString(11));
       txtArrivalDate.setDate(rs.getDate(12));
       byte[] b = rs.getBytes(13);
       ImageIcon icon = new ImageIcon(b);
       Image img = icon.getImage();
       img = img.getScaledInstance(lblImage.getWidth(), lblImage.getHeight(), Image.SCALE_SMOOTH);
       lblImage.setIcon(new ImageIcon(img));
       txtRoomID.setText(rs.getString(14));
       txtEmail.setText(rs.getString(15));
     }
   } catch (SQLException ex) {
     Logger.getLogger(EditHumanDialog.class.getName()).log(Level.SEVERE, null, ex);
   }
 }
Example #26
0
  public PassWord() {

    flogin = new JFrame();
    panel = new JPanel();
    panel.setPreferredSize(new Dimension(400, 300));
    panel.setOpaque(false); // 设置透明
    flogin.setResizable(false);
    randomphoto = new random();
    ImageIcon titleIcon = new ImageIcon(getClass().getResource("/image/1.jpg")); // 获取图片
    randomno = new JLabel(new ImageIcon(randomphoto.creatImage()));
    ImagePanel jDialogImage = new ImagePanel("/image/2.jpg");

    flogin.setContentPane(jDialogImage); // 设置背景图片
    jDialogImage.setBounds(0, 0, flogin.getWidth(), flogin.getHeight());
    flogin.setIconImage(titleIcon.getImage()); // 设置图标

    initframe();

    contentPane = flogin.getContentPane();
    layout1 = new SpringLayout();
    layout2 = new SpringLayout();
    add();
    contentPane.setLayout(layout1);
    signIn.addActionListener(this);
    reset.addActionListener(this);
    flogin.setBounds(400, 120, 400, 300);
    flogin.getRootPane().setDefaultButton(signIn); // 设置响应回车键
    flogin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    flogin.setVisible(true);
    contentPane.add(panel);
  }
Example #27
0
 public void init() {
   vlog.debug("init called");
   setBackground(Color.white);
   ClassLoader cl = this.getClass().getClassLoader();
   ImageIcon icon = new ImageIcon(cl.getResource("com/tigervnc/vncviewer/tigervnc.png"));
   logo = icon.getImage();
 }
 /**
  * Gets the IconBox for the specified image IRI.
  *
  * @param iri The IRI pointing to the image.
  * @return The icon box containing the image.
  * @throws MalformedURLException
  */
 private IconBox getImageBox(IRI iri) throws MalformedURLException {
   ImageIcon imageIcon = new ImageIcon(iri.toURI().toURL());
   imageIcon.getImageLoadStatus();
   IconBox iconBox = new IconBox(imageIcon, new HTTPLink(iri.toURI()));
   iconBox.setMaxHeight(50);
   return iconBox;
 }
Example #29
0
  public AboutPanel() {
    setTitle("About Panel");
    ImageIcon img = new ImageIcon("icons/preferences.jpg");
    setIconImage(img.getImage());
    Container contentPane = getContentPane();
    contentPane.setLayout(new MigLayout());

    setBackground(Color.GRAY);

    int style1 = Font.CENTER_BASELINE;
    Font font = new Font("Arial", style1, 13);

    about = new JLabel();
    about.setFont(font);
    String key = userPrefs.getRegistrationKey();
    if (key == null || key.length() == 0) {
      userPrefs.setRegistrationKey("Community Edition");
    }
    about.setText("<html>WattzAp Community Edition<br/><br/>Version 2.5.1<br/>19th August 2015");
    add(about, "alignx right, span");

    debug = new JCheckBox("Enable Debugging");
    if (userPrefs.isDebug()) {
      debug.setSelected(true);
    } else {
      debug.setSelected(false);
    }
    debug.addActionListener(this);
    add(debug);

    Dimension d = new Dimension(550, 300);
    this.setPreferredSize(d);
    pack();
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  }
Example #30
0
 public void mouseClicked(MouseEvent e) {
   Tile t = (Tile) e.getSource();
   ImageIcon temp = (ImageIcon) t.getIcon();
   currTileImg = new ImageIcon(scaleImage(temp.getImage(), DISPLAY_SCALE));
   currTileDisplay.setIcon(new ImageIcon(scaleImage(temp.getImage(), DISPLAY_SCALE * 2)));
   currTileLoc = t.getSource();
 }