public MapBuilder(String name, File toLoad, File toSave, String tileDir) { super(name); currTileImg = null; currTileLoc = ""; try { System.out.println(tileDir); currTileImg = new ImageIcon(getTile(tileDir, 0, 0, DISPLAY_SCALE)); currTileLoc = "0_0"; } catch (IOException e) { System.out.println("Generating current tile failed."); System.out.println(e); System.exit(0); } currTileDisplay = new JLabel(new ImageIcon(scaleImage(currTileImg.getImage(), 2))); this.input = toLoad; output = toSave; this.tileDir = tileDir; if (toLoad != null) { try { backEnd = loadMap(toLoad); } catch (FileNotFoundException e) { System.err.println("Could not find input file."); System.exit(0); } } else { backEnd = emptyMap(DEFAULT_WIDTH, DEFAULT_HEIGHT); } mapWidth = backEnd.getWidth(); mapHeight = backEnd.getHeight(); }
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(); }
/** Stop animating this instance of <code>AbstractIconAnimator</code>. */ public void stop() { icon.setImageObserver(null); icon.getImage().flush(); Map map = (Map) contexts.get(context); if (map != null) { map.remove(key); if (map.size() == 0) contexts.remove(context); } }
public void squish(Graphics g, ImageIcon icon, int x, int y, double scale) { if (isVisible()) { g.drawImage( icon.getImage(), x, y, (int) (icon.getIconWidth() * scale), (int) (icon.getIconHeight() * scale), this); } }
// method overload the constructor so you can have ImageIcon buttons, Image buttons, or String // buttons (like JButton); public BillyButton(ImageIcon img, String filename) { // set up images with the black one for when its selected this.img = img; enabled = true; image = img.getImage(); this.filename = filename; BWimg = new ImageIcon("Real Pok Pics\\" + filename + "Chosen.gif"); BWimage = BWimg.getImage(); mode = "ImageIcon"; visible = true; }
public static ImageIcon AboutImage() { ImageIcon image = null; String imagename = Settings().getAboutImage(); if ((imagename != null) && "".compareTo(imagename) != 0) { image = new ImageIcon(); try { image.setImage(ImageIO.read(Settings().getResourceAsStream(imagename))); } catch (Exception e) { Logger().warning("About image not found " + imagename + ": " + e.getMessage()); } } return image; }
public void loadImage(File f) { if (f == null) { thumbnail = null; } else { ImageIcon tmpIcon = new ImageIcon(f.getPath()); if (tmpIcon.getIconWidth() > 90) { thumbnail = new ImageIcon(tmpIcon.getImage().getScaledInstance(90, -1, Image.SCALE_DEFAULT)); } else { thumbnail = tmpIcon; } } }
private void addMenuToTray() { HashMap categories = new HashMap(); // create menu list Iterator plugins = PluginManager.getInstance().getAvailablePlugins(); plugins = PluginComparator.sortPlugins(plugins); while (plugins.hasNext()) { Plugin p = (Plugin) plugins.next(); JMenu category = (JMenu) categories.get(p.getCategory()); if (category == null) { category = new JMenu(p.getCategory()); categories.put(p.getCategory(), category); // copy menu to real one if (!p.getCategory().equals("Invisible")) this.trayIcon.add(category); } ImageIcon icon = new ImageIcon(); try { icon = new ImageIcon(new URL(p.getDirectory() + p.getIcon())); icon = new ImageIcon(icon.getImage().getScaledInstance(16, 16, Image.SCALE_SMOOTH)); } catch (Exception e) { // error at icon loading } JMenuItem menu = new JMenuItem(p.getTitle(), icon); menu.setName(p.getName()); menu.setToolTipText(p.getToolTip()); menu.addActionListener(this); category.add(menu); } this.trayIcon.addSeparator(); // windows this.trayIcon.add(new WindowMenu(this)); // open main interface JMenuItem menu = new JMenuItem(tr("open")); menu.setName("org.lucane.applications.maininterface"); menu.addActionListener(this); this.trayIcon.add(menu); // exit menu = new JMenuItem(tr("exit")); menu.setName("exit"); menu.addActionListener(this); this.trayIcon.add(menu); }
public void paint(Graphics g) { super.paint(g); if (thumbnail != null) { int x = getWidth() / 2 - thumbnail.getIconWidth() / 2; int y = getHeight() / 2 - thumbnail.getIconHeight() / 2; if (y < 0) { y = 0; } if (x < 5) { x = 5; } thumbnail.paintIcon(this, g, x, y); } }
public void paintComponent(Graphics g) { g.setColor(new Color(96, 96, 96)); image.paintIcon(this, g, 1, 1); FontMetrics fm = g.getFontMetrics(); String[] args = {jEdit.getVersion()}; String version = jEdit.getProperty("about.version", args); g.drawString(version, (getWidth() - fm.stringWidth(version)) / 2, getHeight() - 5); g = g.create((getWidth() - maxWidth) / 2, TOP, maxWidth, getHeight() - TOP - BOTTOM); int height = fm.getHeight(); int firstLine = scrollPosition / height; int firstLineOffset = height - scrollPosition % height; int lines = (getHeight() - TOP - BOTTOM) / height; int y = firstLineOffset; for (int i = 0; i <= lines; i++) { if (i + firstLine >= 0 && i + firstLine < text.size()) { String line = (String) text.get(i + firstLine); g.drawString(line, (maxWidth - fm.stringWidth(line)) / 2, y); } y += fm.getHeight(); } }
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; bg.paintIcon(this, g2, 0, 0); TreeMap<Integer, FactoryObject> to = (TreeMap<Integer, FactoryObject>) fos.clone(); for (Integer i : to.keySet()) { FactoryObject t = to.get(i); if (t.getIsLine()) { g2.setColor(Color.WHITE); g2.drawLine(t.getPositionX(), t.getPositionY(), t.getPositionXF(), t.getPositionYF()); } else { if (t.getImageIndex() >= 0) { ImageIcon tmp = images.getIcon(t.getImageIndex()); tmp.paintIcon(this, g2, t.getPositionX(), t.getPositionY()); } } } }
private List<JLabel> getComponents() { List<JLabel> images = new ArrayList<>(); for (INDArray arr : digits) { BufferedImage bi = new BufferedImage(28, 28, BufferedImage.TYPE_BYTE_GRAY); for (int i = 0; i < 768; i++) { bi.getRaster().setSample(i % 28, i / 28, 0, (int) (255 * arr.getDouble(i))); } ImageIcon orig = new ImageIcon(bi); Image imageScaled = orig.getImage() .getScaledInstance( (int) (imageScale * 28), (int) (imageScale * 28), Image.SCALE_REPLICATE); ImageIcon scaled = new ImageIcon(imageScaled); images.add(new JLabel(scaled)); } return images; }
public ClientMainForm() { super("Halli Galli"); // 타이틀 제목 im = new ImageIcon("img/imicon.jpg"); // 타이틀바 왼쪽에 넣을 작은 이미지 아이콘 생성 this.setIconImage(im.getImage()); // 타이틀바에 이미지 넣기 setLayout(card); // BorderLayout add("LOAD", ld); new Thread(ld).start(); // 로딩쓰레드 실행 add("LOG", login); // 2.login창 add("WR", wr); // 3.WaitRoom창 add("GW", gw); // 4.GAME Window창 setSize(800, 600); // window창 크기 설정 setLocation(270, 170); // window창 위치 설정 setVisible(true); // 보여지게 함11 setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setResizable(false); // window창 고정(늘어나지 않음) setLocationRelativeTo(null); // 게임 프레임을 화면 정중앙에 위치시킴 ld.st.addActionListener(this); // 로딩의 enter버튼 login.bt1.addActionListener(this); // 회원가입 버튼 누르면 login.bt2.addActionListener(this); // 로그인 버튼 누르면 wr.b1.addActionListener(this); // 로그인 버튼 누르면 wr.b2.addActionListener(this); // 방만들기 버튼 누르면 wr.b3.addActionListener(this); // 방들어가기 버튼 누르면 wr.b8.addActionListener(this); // 도움말 버튼 누르면 wr.b9.addActionListener(this); // 게임종료 버튼 누르면 wr.tf.addActionListener(this); mr.b1.addActionListener(this); // 방만들기창에서 확인버튼 누르면 gw.b1.addActionListener(this); // 게임창에서 전송버튼 누르면 gw.b4.addActionListener(this); // 게임창에서 준비버튼 누르면 gw.b5.addActionListener(this); // 게임창에서 시작버튼 누르면 gw.b6.addActionListener(this); // 게임창에서 나가기 누르면 gw.tf.addActionListener(this); // 게임창에서 채팅하면 gw.cardOpen.addActionListener(this); gw.bell.addActionListener(this); mID.b1.addActionListener(this); mID.b2.addActionListener(this); mID.b3.addActionListener(this); wr.table1 .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (wr.table1.getSelectedRow() > -1) // 방번호가 0 이상이면 { rowNum = wr.table1.getSelectedRow(); System.out.println(rowNum); } } }); }
/** * Creates a new GMap object based on a base directory specified in the constructure. * * @param cache - Base directory to search for cached image folders. */ public GMap(String cache) { // data source this.gDataSourceMap = new GDataSourceMap(cache + "/map_cache"); this.gDataSourceSatellite = new GDataSourceSatellite(cache + "/sat_cache"); // this.gDataSourceOverlay = new GDataSourceOverlay(cache+"/overlay_cache"); this.gDataSourceHybrid = new GDataSourceHybrid(cache + "/hybrid_cache", gDataSourceSatellite); // build default image defaultImage = getDefaultImage(GDataSource.sourceSize.width, GDataSource.sourceSize.height); // init gdraw draw object this.gDraw = new GDraw(); // mode this.mode = MAP_MODE; // icon ImageIcon loadImage = new ImageIcon("images/google.png"); googleImage = loadImage.getImage(); }
public void paintComponent(Graphics g) { super.paintComponent(g); if (placer != null && index >= 0) { Dimension dim = placer.getModel().getSizeOf(index); ImageIcon icon, scaled_icon; // XXX: Come up with a cleaner way to do this. if (((ConfigElement) placer.getModel().getElement(index)) .getDefinition() .getToken() .equals(SURFACE_VIEWPORT_TYPE)) { icon = surfaceIcon; scaled_icon = scaledSurfaceIcon; } else { icon = simIcon; scaled_icon = scaledSimIcon; } // Check if we need to update the scaled image Image img = scaled_icon.getImage(); if ((scaled_icon.getIconWidth() != dim.width) || (scaled_icon.getIconHeight() != dim.height)) { img = icon.getImage().getScaledInstance(dim.width, dim.height, Image.SCALE_DEFAULT); scaled_icon.setImage(img); } // Sanity check in case our scale failed if (img != null) { g.drawImage(img, 0, 0, null); } // Highlight the window nicely if (selected) { g.setColor(getBackground()); } else { g.setColor(Color.white); } g.drawRect(0, 0, dim.width - 1, dim.height - 1); g.fillRect(0, 0, dim.width, 3); } }
/** * Create an object to animate <code>icon</code> on the given <code>Component</code> at the * substructure location represented by the <code>key</code>. * * @param context Component on which the animation is to be painted * @param key Substructure location identifier * @param icon The animated icon */ public JGraphAbstractIconAnimator(final Component context, final Object key, ImageIcon icon) { this.context = context; this.key = key; // Make a copy, since the original icon may be used repeatedly. this.icon = new ImageIcon(icon.getImage()); this.icon.setImageObserver( new ImageObserver() { public boolean imageUpdate(Image image, int flags, int x, int y, int w, int h) { if ((flags & (FRAMEBITS | ALLBITS)) != 0) { repaint(context, key); } return (flags & (ALLBITS | ABORT)) == 0; } }); Map map = (Map) contexts.get(context); if (map == null) { map = new HashMap(); contexts.put(context, map); } map.put(key, this); }
public void drawOn(Graphics2D g) { g.drawImage(ii.getImage(), 0, 0, null); // trying to find right placement for names int Y = 75; int inc = 40; // increment for y int X = 50; g.setColor(Color.BLACK); g.setFont(new Font("Courier New", Font.BOLD, 25)); // drawString (str, x, y) ArrayList<Species> speciesList = new ArrayList<Species>(); for (int x = 0; x < Species.all().size(); x++) { speciesList.add(Species.all().get(x)); } for (int i = 0; i < 6; i++) { Species s = speciesList.get((i + topIndex) % (speciesList.size())); g.drawString(player().pokedex().hasSeen(s) ? s.name() : "----------", X, Y); if (player().pokedex().hasCaught(s)) g.drawImage(pokeball.getImage(), X - 20, Y - 15, null); Y += inc; } g.drawString("" + player().pokedex().allSeen().size(), 270, 75); g.drawString("" + player().pokedex().allCaught().size(), 270, 75 + 50); ImageIcon pkmnArrow, menuArrow; if (pkmn) { pkmnArrow = arrow; menuArrow = idleArrow; } else { pkmnArrow = idleArrow; menuArrow = arrow; } g.drawImage(pkmnArrow.getImage(), X - 40, 60 + pkmnCursorIndex * inc, null); g.drawImage(menuArrow.getImage(), 240, 158 + menuCursorIndex * 31, null); }
/** THIS IS THE IMPORTANT PART-- DRAWS ALL THE STATES OF LANE AND UPDATES ITS PARTS */ @Override public void draw(Graphics g) { if (state == State.FULL) {} if (state == State.PARTIALLYFILLED) { g.drawImage(imageL.getImage(), xPos, yPos, width, height, null); g.drawImage(imageM.getImage(), xPos + stdWidth, yPos, width, height, null); g.drawImage(imageM.getImage(), xPos + stdWidth * 2, yPos, width, height, null); g.drawImage(imageM.getImage(), xPos + stdWidth * 3, yPos, width, height, null); g.drawImage(imageR.getImage(), xPos + stdWidth * 4, yPos, width, height, null); for (int i = 0; i < laneLines.length; i++) { Graphics2D g2 = (Graphics2D) g; // g2.setColor(Color.BLACK); g2.setColor(new Color(20, 124, 185)); g2.draw(laneLines[i]); } } if (state == State.EMPTY) { g.drawImage(imageL.getImage(), xPos, yPos, width, height, null); g.drawImage(imageM.getImage(), xPos + stdWidth, yPos, width, height, null); g.drawImage(imageM.getImage(), xPos + stdWidth * 2, yPos, width, height, null); g.drawImage(imageM.getImage(), xPos + stdWidth * 3, yPos, width, height, null); g.drawImage(imageR.getImage(), xPos + stdWidth * 4, yPos, width, height, null); for (int i = 0; i < laneLines.length; i++) { Graphics2D g2 = (Graphics2D) g; // g2.setColor(Color.BLACK); g2.setColor(new Color(20, 124, 185)); g2.draw(laneLines[i]); } } if (state == State.LANE_MOVING) { g.drawImage(imageL.getImage(), xPos, yPos + shakeY, width, height, null); g.drawImage(imageM.getImage(), xPos + stdWidth, yPos + shakeY, width, height, null); g.drawImage(imageM.getImage(), xPos + stdWidth * 2, yPos + shakeY, width, height, null); g.drawImage(imageM.getImage(), xPos + stdWidth * 3, yPos + shakeY, width, height, null); g.drawImage(imageR.getImage(), xPos + stdWidth * 4, yPos + shakeY, width, height, null); for (int i = 0; i < laneLines.length; i++) { Graphics2D g2 = (Graphics2D) g; // g2.setColor(Color.BLACK); g2.setColor(new Color(20, 124, 185)); g2.draw(laneLines[i]); } boolean movedLaneLines = false; // boolean shakeLane = false; for (int i = 0; i < parts.size(); i++) { int placeX = endX + i * 18; if (parts.get(i).getX() > placeX) { if (parts.get(i).getX() - speed > placeX) parts.get(i).moveX(-speed); else { // parts.get(i).moveX(placeX - parts.get(i).getX()); parts.get(i).moveX(-1); } if (!movedLaneLines) { for (int k = 0; k < laneLines.length; k++) { Double x = laneLines[k].getX(); if (x > xPos) { x--; } else { x = (double) xPos + 250; } laneLines[k].setFrame(x, yPos + 8, 1, height - 16); } movedLaneLines = true; } /*if(!shakeLane) { shakeCounter++; if(shakeCounter==10) { shakeY=-1; } if(shakeCounter==12) { shakeY=0; } if(shakeCounter>=14) { shakeY=1; shakeCounter = 0; } shakeLane = true; }*/ } if (parts.get(i).getY() > endY) { // if (parts.get(i).getY() + speed > endY) // parts.get(i).moveY(speed); // else // { // parts.get(i).moveX(endY - parts.get(i).getY()); parts.get(i).moveX(1); // } } if (parts.get(i).getY() < endY) { // if (parts.get(i).getY() - speed < endY) // parts.get(i).moveY(-speed); // else // { // parts.get(i).moveY(endY + parts.get(i).getY()); parts.get(i).moveY(-1); // } } if (parts.get(i).getX() == endX && parts.get(i).getY() == endY) { // state = State.PARTIALLYFILLED; // THIS WILL CHANGE BASED ON AGENT INTERACTIONS if (nest.getState() != NestState.ADDING_PART && nest.getState() != NestState.FULL && nest.fullState == false) { if (partsLane.get(i).toldAgentItsDone == false) { myAgent.msgGuiDoneMovingPart(parts.get(i)); partsLane.get(i).toldAgentItsDone = true; } nest.givePart(parts.get(i), this); parts.remove(i); partsLane.remove(i); } } } } }
/** * Returns this panel that has been configured to display the meta contact and meta contact group * cells. * * @param tree the source tree * @param value the tree node * @param selected indicates if the node is selected * @param expanded indicates if the node is expanded * @param leaf indicates if the node is a leaf * @param row indicates the row number of the node * @param hasFocus indicates if the node has the focus * @return this panel */ public Component getTreeCellRendererComponent( JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { this.treeContactList = (TreeContactList) tree; this.row = row; this.isSelected = selected; this.treeNode = (TreeNode) value; this.rightLabel.setIcon(null); DefaultTreeContactList contactList = (DefaultTreeContactList) tree; setBorder(); addLabels(1); // Set background color. if (contactList instanceof TreeContactList) { ContactListFilter filter = ((TreeContactList) contactList).getCurrentFilter(); if (filter != null && filter.equals(TreeContactList.historyFilter) && value instanceof ContactNode && row % 2 == 0) { setBackground(Constants.CALL_HISTORY_EVEN_ROW_COLOR); } else { setBackground(Color.WHITE); } } // Make appropriate adjustments for contact nodes and group nodes. if (value instanceof ContactNode) { UIContactImpl contact = ((ContactNode) value).getContactDescriptor(); String displayName = contact.getDisplayName(); if ((displayName == null || displayName.trim().length() < 1) && !(contact instanceof ShowMoreContact)) { displayName = GuiActivator.getResources().getI18NString("service.gui.UNKNOWN"); } this.nameLabel.setText(displayName); if (statusIcon != null && contactList.isContactActive(contact) && statusIcon instanceof ImageIcon) ((ImageIcon) statusIcon).setImage(msgReceivedImage); else statusIcon = contact.getStatusIcon(); this.statusLabel.setIcon(statusIcon); this.nameLabel.setFont(this.getFont().deriveFont(Font.PLAIN)); if (contactForegroundColor != null) nameLabel.setForeground(contactForegroundColor); // Initializes status message components if the given meta contact // contains a status message. this.initDisplayDetails(contact.getDisplayDetails()); if (this.treeContactList.isContactButtonsVisible()) this.initButtonsPanel(contact); int avatarWidth, avatarHeight; if (isSelected && treeContactList.isContactButtonsVisible()) { avatarWidth = EXTENDED_AVATAR_WIDTH; avatarHeight = EXTENDED_AVATAR_HEIGHT; } else { avatarWidth = AVATAR_WIDTH; avatarHeight = AVATAR_HEIGHT; } Icon avatar = contact.getAvatar(isSelected, avatarWidth, avatarHeight); if (avatar != null) { this.rightLabel.setIcon(avatar); } if (contact instanceof ShowMoreContact) { rightLabel.setFont(rightLabel.getFont().deriveFont(12f)); rightLabel.setForeground(Color.GRAY); rightLabel.setText((String) contact.getDescriptor()); } else { rightLabel.setFont(rightLabel.getFont().deriveFont(9f)); rightLabel.setText(""); } this.setToolTipText(contact.getDescriptor().toString()); } else if (value instanceof GroupNode) { UIGroupImpl groupItem = ((GroupNode) value).getGroupDescriptor(); this.nameLabel.setText(groupItem.getDisplayName()); this.nameLabel.setFont(this.getFont().deriveFont(Font.BOLD)); if (groupForegroundColor != null) this.nameLabel.setForeground(groupForegroundColor); this.remove(displayDetailsLabel); this.remove(callButton); this.remove(callVideoButton); this.remove(desktopSharingButton); this.remove(chatButton); this.remove(addContactButton); clearCustomActionButtons(); statusIcon = expanded ? openedGroupIcon : closedGroupIcon; this.statusLabel.setIcon(expanded ? openedGroupIcon : closedGroupIcon); // We have no photo icon for groups. this.rightLabel.setIcon(null); this.rightLabel.setText(""); if (groupItem.countChildContacts() >= 0) { rightLabel.setFont(rightLabel.getFont().deriveFont(9f)); this.rightLabel.setForeground(Color.BLACK); this.rightLabel.setText( groupItem.countOnlineChildContacts() + "/" + groupItem.countChildContacts()); } this.initDisplayDetails(groupItem.getDisplayDetails()); this.initButtonsPanel(groupItem); this.setToolTipText(groupItem.getDescriptor().toString()); } return this; }
public Displayer(Player x, int num) { super("Player " + num + " Information"); playernum = num; this.x = x; setSize(400, 400); setResizable(false); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); moneyLabel = new JLabel("Money Owned:" + x.getMoney() + ""); jcards = new JLabel("Get out of Jail Cards Owned: " + x.getJailCards()); propertydisplay = new JComboBox(getPropertyName()); icon = new ImageIcon(Game.wdr + "images/tokens/monopoly_token_" + x.getToken() + ".png"); mortgage = new JButton("Manage Mortgage"); mortgage.addActionListener(this); mortgage.setActionCommand("mortgage"); buyHouse = new JButton("Buy a House"); buyHouse.addActionListener(this); buyHouse.setActionCommand("buyHouse"); sellHouse = new JButton("Sell a House"); sellHouse.addActionListener(this); sellHouse.setActionCommand("sellHouse"); sellProperty = new JButton("Sell this Property"); sellProperty.addActionListener(this); sellProperty.setActionCommand("sellProperty"); Image img = icon.getImage(); Image newimg = img.getScaledInstance(80, 80, java.awt.Image.SCALE_SMOOTH); ImageIcon newicon = new ImageIcon(newimg); timg = new JLabel(newicon); propertydisplay.addItemListener(this); p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS)); p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS)); p2.setAlignmentX(Component.RIGHT_ALIGNMENT); p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS)); p3.setAlignmentX(Component.LEFT_ALIGNMENT); p2.add(timg); p3.add(moneyLabel); p3.add(jcards); p1.add(p2); p1.add(p3); p4.setLayout(new BoxLayout(p4, BoxLayout.Y_AXIS)); p4.setAlignmentY(Component.CENTER_ALIGNMENT); p4.add(propertydisplay); p4.add(pr1); p4.add(pr2); p4.add(pr3); p4.add(pr4); p4.add(pr5); p5.setLayout(new BoxLayout(p5, BoxLayout.X_AXIS)); p5.add(mortgage); p5.add(buyHouse); p5.add(sellHouse); p.add(p1); p.add(p4); p.add(p5); add(p); setVisible(true); timer.setActionCommand("timing"); timer.setInitialDelay(500); timer.start(); }
public IUmenu(String host) { setTitle("GUUERRA_NAVAL"); efectos = new Efectos(); try { cliente = new Cliente(host); } catch (Exception ex) { } /* Titulo */ titulo = new JLabel(" JHONMAN "); titulo.setForeground(Color.BLACK); titulo.setFont(new Font("Algerian", Font.BOLD, 24)); titulo.setBounds(120, 40, 560, 40); titulo.setHorizontalAlignment(JLabel.CENTER); /* MeEnu de Opciones */ mEnU = new JLabel("MENU DE OPCIONES"); mEnU.setForeground(Color.BLACK); mEnU.setFont(new Font("Algerian", Font.BOLD, 24)); mEnU.setBounds(40, 135, 390, 40); mEnU.setHorizontalAlignment(JLabel.LEFT); ImageIcon i = new ImageIcon("imagenes/apariencia/fondo_def.jpg"); fondo = new JLabel(new ImageIcon(i.getImage().getScaledInstance(800, 600, Image.SCALE_SMOOTH))); fondo.setBounds(0, 0, 800, 600); ImageIcon i1 = new ImageIcon("imagenes/apariencia/botRegistrar.jpg"); ImageIcon i2 = new ImageIcon("imagenes/apariencia/botPrincipiante.jpg"); ImageIcon i3 = new ImageIcon("imagenes/apariencia/botDificil.jpg"); ImageIcon i4 = new ImageIcon("imagenes/apariencia/botSalir.jpg"); ImageIcon i5 = new ImageIcon("imagenes/apariencia/botRaking.jpg"); ImageIcon i6 = new ImageIcon("imagenes/apariencia/brJuegoRed2.jpg"); ImageIcon i11 = new ImageIcon("imagenes/apariencia/botRegistrar2.jpg"); ImageIcon i22 = new ImageIcon("imagenes/apariencia/botPrincipiante2.jpg"); ImageIcon i33 = new ImageIcon("imagenes/apariencia/botDificil2.jpg"); ImageIcon i44 = new ImageIcon("imagenes/apariencia/botSalir2.jpg"); ImageIcon i55 = new ImageIcon("imagenes/apariencia/botRaking2.jpg"); ImageIcon i66 = new ImageIcon("imagenes/apariencia/brJuegoRed.jpg"); /* Boton Puntajes */ estad = new JButton(new ImageIcon(i5.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); estad.setBounds(98, 148, 170, 40); estad.setRolloverIcon( new ImageIcon( i55.getImage() .getScaledInstance( 170, 40, Image .SCALE_SMOOTH))); // cuando el mouse esta sobre el boton cambia a esta // imagen estad.setBorderPainted(false); // elimino los bordes de el boton estad.addActionListener(this); estad.setMnemonic(KeyEvent.VK_P); estad.setToolTipText("ver Raking ALT + P"); /* Boton Registrar */ registrar = new JButton(new ImageIcon(i1.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); registrar.setBounds(98, 205, 170, 40); registrar.setRolloverIcon( new ImageIcon(i11.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); registrar.setBorderPainted(false); registrar.addActionListener(this); registrar.setMnemonic(KeyEvent.VK_Q); registrar.setToolTipText("Registrarse ALT + Q"); /* Boton TipoFacil */ facil = new JButton(new ImageIcon(i2.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); facil.setBounds(97, 262, 170, 40); facil.setRolloverIcon( new ImageIcon(i22.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); facil.setBorderPainted(false); facil.addActionListener(this); facil.setMnemonic(KeyEvent.VK_F); facil.setToolTipText("jugar en modo principiante ALT + F"); /* Boton TipoDificil */ dific = new JButton(new ImageIcon(i3.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); dific.setBounds(97, 317, 170, 40); dific.setRolloverIcon( new ImageIcon(i33.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); dific.setBorderPainted(false); dific.addActionListener(this); dific.setMnemonic(KeyEvent.VK_D); dific.setToolTipText("jugar en modo dificil ALT + D"); /* Boton Salir */ salir = new JButton(new ImageIcon(i4.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); salir.setBounds(97, 430, 170, 40); salir.setRolloverIcon( new ImageIcon(i44.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); salir.setBorderPainted(false); salir.addActionListener(this); salir.setMnemonic(KeyEvent.VK_S); salir.setToolTipText("Salir ALT + S"); /* Boton Red */ red = new JButton(new ImageIcon(i6.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); red.setBounds(97, 374, 170, 40); red.setRolloverIcon( new ImageIcon(i66.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); red.setBorderPainted(false); red.addActionListener(this); red.setMnemonic(KeyEvent.VK_C); red.setToolTipText("Jugar con varios jugadores ALT + C"); c = getContentPane(); c.setLayout(null); c.add(titulo); c.add(estad); c.add(facil); c.add(registrar); c.add(dific); c.add(salir); c.add(red); c.add(fondo); }
public Dimension getPreferredSize() { return new Dimension(1 + image.getIconWidth(), 1 + image.getIconHeight()); }
public Ssys3() { store = new Storage(); tableSorter = new TableRowSorter<Storage>(store); jobs = new LinkedList<String>(); makeGUI(); frm.setSize(800, 600); frm.addWindowListener( new WindowListener() { public void windowActivated(WindowEvent evt) {} public void windowClosed(WindowEvent evt) { try { System.out.println("joining EDT's"); for (EDT edt : encryptDecryptThreads) { edt.weakStop(); try { edt.join(); System.out.println(" - joined"); } catch (InterruptedException e) { System.out.println(" - Not joined"); } } System.out.println("saving storage"); store.saveAll(tempLoc); } catch (IOException e) { e.printStackTrace(); System.err.println( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nFailed to save properly\n\n!!!!!!!!!!!!!!!!!!!!!!!!!"); System.exit(1); } clean(); System.exit(0); } public void windowClosing(WindowEvent evt) { windowClosed(evt); } public void windowDeactivated(WindowEvent evt) {} public void windowDeiconified(WindowEvent evt) {} public void windowIconified(WindowEvent evt) {} public void windowOpened(WindowEvent evt) {} }); ImageIcon ico = new ImageIcon(ICON_NAME); frm.setIconImage(ico.getImage()); frm.setLocationRelativeTo(null); frm.setVisible(true); // load config storeLocs = new ArrayList<File>(); String ossl = "openssl"; int numThreadTemp = 2; boolean priorityDecryptTemp = true; boolean allowExportTemp = false; boolean checkImportTemp = true; try { Scanner sca = new Scanner(CONF_FILE); while (sca.hasNextLine()) { String ln = sca.nextLine(); if (ln.startsWith(CONF_SSL)) { ossl = ln.substring(CONF_SSL.length()); } else if (ln.startsWith(CONF_THREAD)) { try { numThreadTemp = Integer.parseInt(ln.substring(CONF_THREAD.length())); } catch (Exception exc) { // do Nothing } } else if (ln.equals(CONF_STORE)) { while (sca.hasNextLine()) storeLocs.add(new File(sca.nextLine())); } else if (ln.startsWith(CONF_PRIORITY)) { try { priorityDecryptTemp = Boolean.parseBoolean(ln.substring(CONF_PRIORITY.length())); } catch (Exception exc) { // do Nothing } } else if (ln.startsWith(CONF_EXPORT)) { try { allowExportTemp = Boolean.parseBoolean(ln.substring(CONF_EXPORT.length())); } catch (Exception exc) { // do Nothing } } else if (ln.startsWith(CONF_CONFIRM)) { try { checkImportTemp = Boolean.parseBoolean(ln.substring(CONF_CONFIRM.length())); } catch (Exception exc) { // do Nothing } } } sca.close(); } catch (IOException e) { } String osslWorks = OpenSSLCommander.test(ossl); while (osslWorks == null) { ossl = JOptionPane.showInputDialog( frm, "Please input the command used to run open ssl\n We will run \"<command> version\" to confirm\n Previous command: " + ossl, "Find open ssl", JOptionPane.OK_CANCEL_OPTION); if (ossl == null) { System.err.println("Refused to provide openssl executable location"); System.exit(1); } osslWorks = OpenSSLCommander.test(ossl); if (osslWorks == null) JOptionPane.showMessageDialog( frm, "Command " + ossl + " unsuccessful", "Unsuccessful", JOptionPane.ERROR_MESSAGE); } if (storeLocs.size() < 1) JOptionPane.showMessageDialog( frm, "Please select an initial sotrage location\nIf one already exists, or there are more than one, please select it"); while (storeLocs.size() < 1) { JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (jfc.showOpenDialog(frm) != JFileChooser.APPROVE_OPTION) { System.err.println("Refused to provide an initial store folder"); System.exit(1); } File sel = jfc.getSelectedFile(); if (sel.isDirectory()) storeLocs.add(sel); } numThreads = numThreadTemp; priorityExport = priorityDecryptTemp; allowExport = allowExportTemp; checkImports = checkImportTemp; try { PrintWriter pw = new PrintWriter(CONF_FILE); pw.println(CONF_SSL + ossl); pw.println(CONF_THREAD + numThreads); pw.println(CONF_PRIORITY + priorityExport); pw.println(CONF_EXPORT + allowExport); pw.println(CONF_CONFIRM + checkImports); pw.println(CONF_STORE); for (File fi : storeLocs) { pw.println(fi.getAbsolutePath()); } pw.close(); } catch (IOException e) { System.err.println("Failed to save config"); } File chk = null; for (File fi : storeLocs) { File lib = new File(fi, LIBRARY_NAME); if (lib.exists()) { chk = lib; // break; } } char[] pass = null; if (chk == null) { JOptionPane.showMessageDialog( frm, "First time run\n Create your password", "Create Password", JOptionPane.INFORMATION_MESSAGE); char[] p1 = askPassword(); char[] p2 = askPassword(); boolean same = p1.length == p2.length; for (int i = 0; i < Math.min(p1.length, p2.length); i++) { if (p1[i] != p2[i]) same = false; } if (same) { JOptionPane.showMessageDialog( frm, "Password created", "Create Password", JOptionPane.INFORMATION_MESSAGE); pass = p1; } else { JOptionPane.showMessageDialog( frm, "Passwords dont match", "Create Password", JOptionPane.ERROR_MESSAGE); System.exit(1); } } else { pass = askPassword(); } sec = OpenSSLCommander.getCommander(chk, pass, ossl); if (sec == null) { System.err.println("Wrong Password"); System.exit(1); } store.useSecurity(sec); store.useStorage(storeLocs); tempLoc = new File("temp"); if (!tempLoc.exists()) tempLoc.mkdirs(); // load stores try { store.loadAll(tempLoc); store.fireTableDataChanged(); } catch (IOException e) { System.err.println("Storage loading failure"); System.exit(1); } needsSave = false; encryptDecryptThreads = new EDT[numThreads]; for (int i = 0; i < encryptDecryptThreads.length; i++) { encryptDecryptThreads[i] = new EDT(i); encryptDecryptThreads[i].start(); } updateStatus(); txaSearch.grabFocus(); }
/** * Losing Function. This method contains everything required to end a game, and also give the user * options afterwards. */ private void losing() { InformationFrame.stopClock(); timerStart = false; for (int r = 0; r < ButtonGrid.length; r++) { for (int c = 0; c < ButtonGrid[1].length; c++) { if (MainManager.getMainGrid().getMines(r, c) == 9) { ButtonGrid[r][c].setSelected(true); // prepare special icons ImageIcon MineIcon; MineIcon = new ImageIcon( "C://Users/Joseph/Downloads/GitHub/" + "Outside/2013/Minesweeper/src/Images/MineImage.png"); // prepare resize Image MineImage = MineIcon.getImage(); // transform it int maxSize = Math.max(ButtonGrid[r][c].getHeight(), ButtonGrid[r][c].getWidth()) / 2; Image rescaledImage; ImageIcon imageIcon; rescaledImage = MineImage.getScaledInstance( maxSize, maxSize, Image.SCALE_SMOOTH); // scale it the smooth way imageIcon = new ImageIcon(rescaledImage); // transform it back JLabel test1 = new JLabel(imageIcon); ButtonGrid[r][c].add(test1); // ButtonGrid[r][c].repaint(); resetFont("", r, c); } } } /* JOptionPane.showMessageDialog(rootPane, "You lose. Sorry." + "\n╔╦╦╦╦╦╦╦╦╦╦╦╦╗" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬█╬╬╬╬╬╬█╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬██████████╬╣" + "\n╠╬█╬╬╬╬╬╬╬╬█╬╣" + "\n╚╩╩╩╩╩╩╩╩╩╩╩╩╝", "☹", JOptionPane.YES_NO_CANCEL_OPTION); * */ // Custom button text String[] options = {"Try again", "Go back to Start", "Quit"}; int n = JOptionPane.showOptionDialog( rootPane, "You lose. Sorry." + "\n╔╦╦╦╦╦╦╦╦╦╦╦╦╗" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬█╬╬╬╬╬╬█╬╬╣" + "\n╠╬╬╬╬╬╬█╬╬╬╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬╬╬╬╬╬╬╬╬╬╬╬╣" + "\n╠╬██████████╬╣" + "\n╠╬█╬╬╬╬╬╬╬╬█╬╣" + "\n╚╩╩╩╩╩╩╩╩╩╩╩╩╝" + "\n What would you like to do?", "☹", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); if (n == 2) { // System.out.println("n = " + n); System.exit(0); } else if (n == 1) { InformationFrame.dispose(); main(null); this.dispose(); } else if (n == 0) { String difficulty = MainManager.getMainGrid().getDifficulty(); MainPanel.removeAll(); constructMinesweeper(difficulty.toLowerCase()); } for (int y = 0; y < ButtonGrid.length; y++) { for (int x = 0; x < ButtonGrid[1].length; x++) { ButtonGrid[y][x].setFocusable(false); } } System.out.println("You lose"); }
private void jbInit() throws Exception { setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); this.setIconImage(icon.getImage()); this.addComponentListener( new java.awt.event.ComponentAdapter() { public void componentShown(ComponentEvent e) { this_componentShown(e); } }); this.getContentPane().setLayout(borderLayout1); this.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent e) { this_windowClosing(e); } }); this.setJMenuBar(menuBar); // This size is chosen so that when the user hits the Info tool, the // window // fits between the lower edge of the TaskFrame and the lower edge of // the // WorkbenchFrame. See the call to #setSize in InfoFrame. [Jon Aquino] setSize(900, 665); // OUTLINE_DRAG_MODE is excruciatingly slow in JDK 1.4.1, so don't use // it. // (although it's supposed to be fixed in 1.4.2, which has not yet been // released). (see Sun Java Bug ID 4665237). [Jon Aquino] // desktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); messageLabel.setOpaque(true); memoryLabel.setText("jLabel1"); wmsLabel.setHorizontalAlignment(SwingConstants.LEFT); wmsLabel.setText(" "); this.getContentPane().add(statusPanel, BorderLayout.SOUTH); exitMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { exitMenuItem_actionPerformed(e); } }); windowMenu.addMenuListener( new javax.swing.event.MenuListener() { public void menuCanceled(MenuEvent e) {} public void menuDeselected(MenuEvent e) {} public void menuSelected(MenuEvent e) { windowMenu_menuSelected(e); } }); coordinateLabel.setBorder(BorderFactory.createLoweredBevelBorder()); wmsLabel.setBorder(BorderFactory.createLoweredBevelBorder()); coordinateLabel.setText(" "); statusPanel.setLayout(gridBagLayout1); statusPanel.setBorder(BorderFactory.createRaisedBevelBorder()); messageLabel.setBorder(BorderFactory.createLoweredBevelBorder()); messageLabel.setText(" "); timeLabel.setBorder(BorderFactory.createLoweredBevelBorder()); timeLabel.setText(" "); memoryLabel.setBorder(BorderFactory.createLoweredBevelBorder()); memoryLabel.setText(" "); menuBar.add(fileMenu); menuBar.add(windowMenu); getContentPane().add(toolBar, BorderLayout.NORTH); getContentPane().add(desktopPane, BorderLayout.CENTER); fileMenu.addSeparator(); fileMenu.add(exitMenuItem); statusPanel.add( coordinateLabel, new GridBagConstraints( 5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); statusPanel.add( timeLabel, new GridBagConstraints( 2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); statusPanel.add( messageLabel, new GridBagConstraints( 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); // Give memoryLabel the 1.0 weight. All the rest should have their // sizes // configured using #configureStatusLabel. [Jon Aquino] statusPanel.add( memoryLabel, new GridBagConstraints( 3, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); statusPanel.add( wmsLabel, new GridBagConstraints( 4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); }