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); } }
public Player(double x) { hp = 100; pX = x; playerTex = new ImageIcon("TEXTURE/stickman.png"); pY = Constants.GROUND - playerTex.getIconHeight(); pRect = new Rectangle2D.Double(x + playerTex.getIconWidth() / 2, pY, 1, playerTex.getIconHeight()); }
private void updateImages() { mainIcon.setIcon(model.getCharacterToken().getIcon()); if (model.getCharacter().getGameObject().hasThisAttribute(CharacterInfoCard.NO_INVERT_ICON)) { ImageIcon icon = model.getCharacter().getFullSizedIcon(); BufferedImage bi = new BufferedImage( icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_3BYTE_BGR); Graphics big = bi.getGraphics(); big.setColor(Color.black); big.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight()); big.drawImage(icon.getImage(), 0, 0, null); invertedIcon.setIcon(new ImageIcon(bi)); } else { invertedIcon.setIcon(getInvertedIcon()); } repaint(); }
@Test public void testRedimensionnerImage() { ImageIcon imageBar = new ImageIcon("ChatDesk/src/ca/qc/bdeb/gr1_420_P56_BB/Images/bar.png"); int tailleY = 20; int tailleX = 20; ImageIcon imageBarModifiee = Formatage.redimensionnerImage(imageBar, tailleX, tailleY); assertEquals(imageBarModifiee.getIconWidth(), tailleX); assertEquals(imageBarModifiee.getIconHeight(), tailleY); }
/** * Gets an ImageIcon. * * @return the icon */ public ImageIcon getIcon() { if (icon == null && isAnImage) { icon = new ImageIcon(getURL()); if (icon.getIconWidth() < 1) { icon = null; isAnImage = false; } } return icon; }
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); } }
private static ImageIcon makeRolloverIcon(ImageIcon srcIcon) { RescaleOp op = new RescaleOp(new float[] {1.2f, 1.2f, 1.2f, 1f}, new float[] {0f, 0f, 0f, 0f}, null); BufferedImage img = new BufferedImage( srcIcon.getIconWidth(), srcIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = img.getGraphics(); // g.drawImage(srcIcon.getImage(), 0, 0, null); srcIcon.paintIcon(null, g, 0, 0); g.dispose(); return new ImageIcon(op.filter(img, null)); }
private static ImageIcon scale(ImageIcon src) { // System.out.println(scaleFactor); if (scaleFactor > 1) { int w = (int) (scaleFactor * src.getIconWidth()); int h = (int) (scaleFactor * src.getIconHeight()); int type = BufferedImage.TYPE_INT_ARGB; BufferedImage dst = new BufferedImage(w, h, type); Graphics2D g2 = dst.createGraphics(); g2.drawImage(src.getImage(), 0, 0, w, h, null); g2.dispose(); return new ImageIcon(dst); } else return src; }
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; } } }
public void resize() { height = (height == 0) ? 1 : height; ratio = (double) image.getIconWidth() / image.getIconHeight(); Image img = image.getImage(); width = width - 10; // 4 = Image.SCALE_SMOOTH Image newimg = img.getScaledInstance(width, (int) (width / ratio), 4); label1.setIcon(new ImageIcon(newimg)); }
private void paintLifes(Graphics2D g2d) { int lifes = c.getLifes(); for (int i = 0; i < lifes; i++) { ImageIcon imageIcon = new ImageIcon( ItemFactory.class.getResource(Config.getImagePath() + Level.getLevel().getLife())); Life life = ItemFactory.createLife( Config.getBoardDimension().getLength() - (2 + i) * imageIcon.getIconWidth(), 0, imageIcon); g2d.drawImage(life.getImage(), life.getPosition().getX(), life.getPosition().getY(), this); } }
// populate version for corrections public void showCorrectionTileUpgrades() { // deactivate correctionTokenMode and tokenmode correctionTokenMode = false; tokenMode = false; // activate upgrade panel upgradePanel.removeAll(); GridLayout panelLayout = (GridLayout) upgradePanel.getLayout(); List<TileI> tiles = orUIManager.tileUpgrades; if (tiles == null || tiles.size() == 0) { // reset to the number of elements panelLayout.setRows(defaultNbPanelElements); // set to position 0 scrollPane.getVerticalScrollBar().setValue(0); } else { // set to the max of available or the default number of elements panelLayout.setRows(Math.max(tiles.size() + 2, defaultNbPanelElements)); for (TileI tile : tiles) { BufferedImage hexImage = getHexImage(tile.getId()); ImageIcon hexIcon = new ImageIcon(hexImage); // Cheap n' Easy rescaling. hexIcon.setImage( hexIcon .getImage() .getScaledInstance( (int) (hexIcon.getIconWidth() * GUIHex.NORMAL_SCALE * 0.8), (int) (hexIcon.getIconHeight() * GUIHex.NORMAL_SCALE * 0.8), Image.SCALE_SMOOTH)); HexLabel hexLabel = new HexLabel(hexIcon, tile.getId()); hexLabel.setName(tile.getName()); hexLabel.setTextFromTile(tile); hexLabel.setOpaque(true); hexLabel.setVisible(true); hexLabel.setBorder(border); hexLabel.addMouseListener(this); upgradePanel.add(hexLabel); } } upgradePanel.add(doneButton); upgradePanel.add(cancelButton); // repaint(); revalidate(); }
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); } }
/** Show splash - stays up untill user clicks, or closeSplash() is called. */ public void showSplash() { JPanel content = (JPanel) getContentPane(); content.setBackground(Color.white); // Set the window's bounds, centering the window ImageIcon im = new ImageIcon(getClass().getResource("/data/Splash.jpg")); int width = 450; int height = 115; if (im == null) { im = new ImageIcon(); } else { width = im.getIconWidth() + 10; height = im.getIconHeight() + 10; } Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screen.width - width) / 2; int y = (screen.height - height) / 2; setBounds(x, y, width, height); setAlwaysOnTop(true); // Build the splash screen // JLabel title = new JLabel // ("CONE: Collocation Network Explorer.", JLabel.CENTER); JLabel label = new JLabel(im); // JLabel copyrt = new JLabel // ("<html> Copyright 2010, David Gullick & Lancaster // University.<br/>Thanks to Francois taiani, Paul Rayson, John Mariani and Scott Piao</html>", // JLabel.CENTER); // copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 12)); content.add(new JLabel(im)); // content.add(title, BorderLayout.NORTH); // content.add(copyrt, BorderLayout.SOUTH); // content.setBorder(BorderFactory.createLineBorder(Color.BLACK, 5)); addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { setVisible(false); closeSplash(); } }); // Display it setVisible(true); }
Jf() { j.setBounds(500, 40, 500, 500); j.setVisible(true); j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); j.setLayout(null); ImageIcon image = new ImageIcon("im1.jpg"); JLabel l = new JLabel(image); int m = image.getIconWidth(); int m1 = image.getIconHeight(); j.setResizable(false); // frame resize nahi hoga l.setBounds(0, 0, m, m1); j.add(l); l.add(linfo); l.add(lid); l.add(fid); l.add(lpass); l.add(fpass); fpass.setEchoChar('*'); l.add(blogin); l.add(bnewaccount); l.add(bforget); ImageIcon image1 = new ImageIcon("logo1.png"); JLabel limage = new JLabel(image1); l.add(limage); limage.setBounds(10, 50, 190, 130); Font f = new Font("ALGERIAN", Font.BOLD, 20); linfo.setFont(f); linfo.setBounds(40, 10, 420, 30); lid.setBounds(210, 50, 70, 30); fid.setBounds(290, 50, 150, 30); lpass.setBounds(210, 90, 70, 30); fpass.setBounds(290, 90, 150, 30); blogin.setBounds(210, 130, 100, 50); bnewaccount.setBounds(320, 130, 160, 20); bforget.setBounds(320, 160, 160, 20); blogin.setBackground(Color.green); bnewaccount.setBackground(Color.cyan); bforget.setBackground(Color.pink); blogin.addActionListener(new Login()); bnewaccount.addActionListener(new Account()); bforget.addActionListener(new Forget()); }
/** * Read image from bytes * * @param imageBytes * @return */ private BufferedImage getBufferedImageFromBytes(byte[] imageBytes) { try { // try to read image using ImageIO return ImageIO.read(new ByteArrayInputStream(imageBytes)); } catch (Throwable e) { // try to load image trough awt - this is a workaround for Java 8 on OpenJDK on Linux ImageIcon icon = new ImageIcon(imageBytes); image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_RGB); Graphics g = image.createGraphics(); // paint the Icon to the BufferedImage. icon.paintIcon(null, g, 0, 0); g.dispose(); return image; } }
/** * Sets the icon for the given file. * * @param file the file to set an icon for * @return the byte array containing the thumbnail */ private byte[] getFileThumbnail(File file) { byte[] bytes = null; if (FileUtils.isImage(file.getName())) { try { ImageIcon image = new ImageIcon(file.toURI().toURL()); int width = image.getIconWidth(); int height = image.getIconHeight(); if (width > THUMBNAIL_WIDTH) width = THUMBNAIL_WIDTH; if (height > THUMBNAIL_HEIGHT) height = THUMBNAIL_HEIGHT; bytes = ImageUtils.getScaledInstanceInBytes(image.getImage(), width, height); } catch (MalformedURLException e) { if (logger.isDebugEnabled()) logger.debug("Could not locate image.", e); } } return bytes; }
protected void paintComponent(Graphics g) { if (thumbnail == null) { loadImage(); } 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); } }
/** * Draws an emblem (based on current theme) in the bottom left of the given component. Call this * in paintComponent() of the component. * * @param component the component to draw on * @param g the Graphics object from paintComponent() */ public static void drawEmblem(JComponent component, Graphics g) { Themes currentTheme = Themes.getCurrentTheme(); ImageIcon image = GUI.createImageIcon("translucent/" + currentTheme.getImageIconPath()); /*if(Themes.getCurrentTheme() == Themes.SNOW){ image = GUI.createImageIcon("translucent/snow.png"); }*/ int imageWidth = image.getIconWidth(); int imageHeight = image.getIconHeight(); // top left corner of where to start drawing int topLeftX = component.getWidth() - imageWidth; // x (horizontal) coordinate int topLeftY = component.getHeight() - imageHeight; // y (vertical) coordinate // draw in bottom right corner g.drawImage(image.getImage(), topLeftX, topLeftY, (java.awt.image.ImageObserver) null); // g.drawImage(image.getImage(), 0,0, (java.awt.image.ImageObserver)null); }
@Override public void paintComponent(Graphics g) { super.paintComponent(g); // resize picture to appropriate size ImageIcon newPicture = GUI.scaleImage(picture, PICTURE_WIDTH, PICTURE_HEIGHT); int width = newPicture.getIconWidth(); int height = newPicture.getIconHeight(); // get offsets in order to center picture int verticalOffset = (PICTURE_HEIGHT - height) / 2; int horizontalOffset = (PICTURE_WIDTH - width) / 2; // if the image is thinner than this panel, offset it // paint the picture g.drawImage(newPicture.getImage(), horizontalOffset, verticalOffset, this); // offsets let the image be centered }
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); } }
public void loadImage() { if (file == null) { thumbnail = null; return; } // Don't use createImageIcon (which is a wrapper for getResource) // because the image we're trying to load is probably not one // of this program's own resources. ImageIcon tmpIcon = new ImageIcon(file.getPath()); if (tmpIcon != null) { if (tmpIcon.getIconWidth() > 90) { thumbnail = new ImageIcon(tmpIcon.getImage().getScaledInstance(90, -1, Image.SCALE_DEFAULT)); } else { // no need to miniaturize thumbnail = tmpIcon; } } }
// Takes resource name and returns button public JButton createButton(String name, String toolTip) { // load the image String imagePath = "./resources/" + name + ".png"; ImageIcon iconRollover = new ImageIcon(imagePath); int w = iconRollover.getIconWidth(); int h = iconRollover.getIconHeight(); // get the cursor for this button Cursor cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); // make translucent default image Image image = createCompatibleImage(w, h, Transparency.TRANSLUCENT); Graphics2D g = (Graphics2D) image.getGraphics(); Composite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f); g.setComposite(alpha); g.drawImage(iconRollover.getImage(), 0, 0, null); g.dispose(); ImageIcon iconDefault = new ImageIcon(image); // make a pressed image image = createCompatibleImage(w, h, Transparency.TRANSLUCENT); g = (Graphics2D) image.getGraphics(); g.drawImage(iconRollover.getImage(), 2, 2, null); g.dispose(); ImageIcon iconPressed = new ImageIcon(image); // create the button JButton button = new JButton(); button.addActionListener(this); button.setIgnoreRepaint(true); button.setFocusable(false); button.setToolTipText(toolTip); button.setBorder(null); button.setContentAreaFilled(false); button.setCursor(cursor); button.setIcon(iconDefault); button.setRolloverIcon(iconRollover); button.setPressedIcon(iconPressed); return button; }
/** * Constructor public Enemy() * * <p>This constructor sets the initial variables of the enemy ship, loads the images. It also * strats off the ship in randomly either the right or the left direction and sets the images * accordingly.. */ public Enemy(int speed) { this.x = ((int) (Math.random() * (750))) + 5; this.y = 0; ImageIcon iR = new ImageIcon("resources\\images\\EnemyShipRight.png"); goingRight = iR.getImage(); ImageIcon iL = new ImageIcon("resources\\images\\EnemyShipLeft.png"); goingLeft = iL.getImage(); double randomSelection = Math.random(); if (randomSelection < 0.5) { speedX = speed; mainImage = goingRight; } else { speedX = -speed; mainImage = goingLeft; } this.width = iR.getIconWidth(); this.height = iL.getIconHeight(); }
private void updateColors() { ImageIcon icon; if (selected) { panelMain.setBackground(activeBackgroundColor); pnlBottom.setBackground(new Color(0xccd1d7)); icon = UnitUtilWrapper.BitcoinUnitWrapper.getWrapper(UnitUtil.BitcoinUnit.BTC).getBmpSlim(); } else { panelMain.setBackground(inactiveBackGroundColor); pnlBottom.setBackground(new Color(0xeeeeee)); icon = UnitUtilWrapper.BitcoinUnitWrapper.getWrapper(UnitUtil.BitcoinUnit.BTC).getBmpBlack(); } float width = icon.getIconWidth(); float height = icon.getIconHeight(); float scale = (float) 1.0f; icon.setImage( icon.getImage() .getScaledInstance((int) (width * scale), (int) (height * scale), Image.SCALE_SMOOTH)); }
public MainPanel() { super(new BorderLayout()); ActionListener al = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JComponent c = (JComponent) e.getSource(); if (ra.equals(c)) { label.setIcon(iia); } else if (rb.equals(c)) { label.setIcon(iib); } else { label.setIcon(new ImageIcon(createImage(source))); } } }; JPanel p = new JPanel(); ButtonGroup bg = new ButtonGroup(); for (JRadioButton r : Arrays.asList(ra, rb, rr)) { r.addActionListener(al); bg.add(r); p.add(r); } ra.setSelected(true); add(label); add(p, BorderLayout.SOUTH); int w = iia.getIconWidth(); int h = iia.getIconHeight(); int[] pixelsA = getData(iia, w, h); int[] pixelsB = getData(iib, w, h); source = new MemoryImageSource(w, h, pixelsA, 0, w); for (int i = 0; i < pixelsA.length; i++) { if (pixelsA[i] == pixelsB[i]) { pixelsA[i] = pixelsA[i] & 0x44FFFFFF; } } setPreferredSize(new Dimension(320, 240)); }
private JLabel makeLabelIcon() { ImageIcon i = new ImageIcon(getClass().getResource("duke.gif")); Dimension d = new Dimension(i.getIconWidth(), i.getIconHeight()); final BufferedImage image = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_ARGB); Graphics g = image.createGraphics(); i.paintIcon(null, g, 0, 0); g.dispose(); final JLabel icon = new JLabel(i) { @Override public boolean contains(int x, int y) { return super.contains(x, y) && ((image.getRGB(x, y) >> 24) & 0xff) != 0; } }; icon.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); MouseAdapter l = new MouseAdapter() { private final transient Point start = new Point(); private Point loc; @Override public void mousePressed(MouseEvent me) { start.setLocation(me.getPoint()); } @Override public void mouseDragged(MouseEvent me) { loc = icon.getLocation(loc); int x = loc.x - start.x + me.getX(); int y = loc.y - start.y + me.getY(); icon.setLocation(x, y); } }; icon.addMouseListener(l); icon.addMouseMotionListener(l); icon.setBounds(new Rectangle(22, 22, d.width, d.height)); return icon; }
public void showUpgrades() { upgradePanel.removeAll(); // reset to the number of elements GridLayout panelLayout = (GridLayout) upgradePanel.getLayout(); panelLayout.setRows(defaultNbPanelElements); if (tokenMode && possibleTokenLays != null && possibleTokenLays.size() > 0) { Color fgColour = null; Color bgColour = null; String text = null; String description = null; TokenIcon icon; ActionLabel tokenLabel; tokenLabels = new ArrayList<ActionLabel>(); for (LayToken action : possibleTokenLays) { if (action instanceof LayBaseToken) { PublicCompanyI comp = ((LayBaseToken) action).getCompany(); fgColour = comp.getFgColour(); bgColour = comp.getBgColour(); description = text = comp.getName(); if (action.getSpecialProperty() != null) { description += " (" + action.getSpecialProperty().getOriginalCompany().getName() + ")"; } } else if (action instanceof LayBonusToken) { fgColour = Color.BLACK; bgColour = Color.WHITE; BonusToken token = (BonusToken) action.getSpecialProperty().getToken(); description = token.getName(); text = "+" + token.getValue(); } icon = new TokenIcon(25, fgColour, bgColour, text); tokenLabel = new ActionLabel(icon); tokenLabel.setName(description); tokenLabel.setText(description); tokenLabel.setBackground(defaultLabelBgColour); tokenLabel.setOpaque(true); tokenLabel.setVisible(true); tokenLabel.setBorder(border); tokenLabel.addMouseListener(this); tokenLabel.addPossibleAction(action); tokenLabels.add(tokenLabel); upgradePanel.add(tokenLabel); } setSelectedToken(); } else if (orUIManager.tileUpgrades == null) {; } else if (orUIManager.tileUpgrades.size() == 0) { orUIManager.setMessage(LocalText.getText("NoTiles")); } else { for (TileI tile : orUIManager.tileUpgrades) { BufferedImage hexImage = getHexImage(tile.getPictureId()); ImageIcon hexIcon = new ImageIcon(hexImage); // Cheap n' Easy rescaling. hexIcon.setImage( hexIcon .getImage() .getScaledInstance( (int) (hexIcon.getIconWidth() * GUIHex.NORMAL_SCALE * 0.8), (int) (hexIcon.getIconHeight() * GUIHex.NORMAL_SCALE * 0.8), Image.SCALE_SMOOTH)); HexLabel hexLabel = new HexLabel(hexIcon, tile.getId()); hexLabel.setName(tile.getName()); hexLabel.setTextFromTile(tile); hexLabel.setOpaque(true); hexLabel.setVisible(true); hexLabel.setBorder(border); hexLabel.addMouseListener(this); upgradePanel.add(hexLabel); } } upgradePanel.add(doneButton); upgradePanel.add(cancelButton); // repaint(); revalidate(); }
public int getIconWidth() { int width = arrow.getIconWidth(); if (icon != null) width += icon.getIconWidth(); width += X_GAP; return width; }
// Inner class to manage help modal diaglog object. class HelpHandler extends JDialog implements ActionListener { // Define and initialize AWT container. Container c = getContentPane(); // Define and initialize Swing widgets. JButton okButton = new JButton("Check the Java API"); ImageIcon imageIcon = new ImageIcon("surfing.gif"); JLabel image = new JLabel(imageIcon); // Define and intialize phsyical size dimensions. int left = 0; int top = 0; int buttonWidth = 150; int buttonHeight = 25; int imageWidth = imageIcon.getIconWidth(); int imageHeight = imageIcon.getIconHeight(); int offsetMargin = 20; // The dialog width and height are derived from base objects. int dialogWidth = imageWidth + offsetMargin; int dialogHeight = imageHeight + buttonHeight + (3 * offsetMargin); // --------------------------- Constructor -------------------------------/ // The inner class requires an owning frame and cannot be called from // a default constructor. So, the default constructor is excluded. public HelpHandler(Frame owner, boolean modal) { super(owner, modal); buildDialogBox(); } // -------------------------- Begin Methods ------------------------------/ // Method to build the dialog box for help. private void buildDialogBox() { // Set the JDialog window properties. setTitle("Learning about Java"); setResizable(false); setSize(dialogWidth, dialogHeight); // Define behaviors of container. c.setLayout(null); c.setBackground(Color.cyan); c.add(image); c.add(okButton); // Set the bounds for the image. image.setBounds( (dialogWidth / 2) - (imageWidth / 2), (top + (offsetMargin / 2)), imageWidth, imageHeight); // Set the behaviors, bounds and action listener for the button. okButton.setBounds( (dialogWidth / 2) - (buttonWidth / 2), (imageHeight + (int) 1.5 * offsetMargin), buttonWidth, buttonHeight); // Set the font to the platform default Font for the object with the // properties of bold and font size of 11. okButton.setFont(new Font(okButton.getFont().getName(), Font.BOLD, 11)); // Set foreground and background of JButton(s). okButton.setForeground(Color.white); okButton.setBackground(Color.blue); // The class implements the ActionListener interface and therefore // provides an implementation of the actionPerformed() method. When a // class implements ActionListener, the instance handler returns an // ActionListener. The ActionListener then performs actionPerformed() // method on an ActionEvent. okButton.addActionListener(this); // Set the screen and display dialog window in relation to screen size. dim = tk.getScreenSize(); setLocation((dim.width / 2) - (dialogWidth / 2), (dim.height / 2) - (dialogHeight / 2)); // Display the dialog. show(); } // End of buildDialogBox method. // --------------------- Window ActionListener ---------------------------/ // Class listener based on implementing ActionListener. public void actionPerformed(ActionEvent e) { // Dispose of the help dialog. setVisible(false); dispose(); } // End of actionPerformed method. // -------------------------- End Methods --------------------------------/ } // End of HelpHandler inner class.