摘要: This example demonstrates how to set a clipping area using a shape. The example sets an oval for the clipping area and then draws and image. Only thos 阅读全文
posted @ 2018-09-02 22:02 Borter 阅读(161) 评论(0) 推荐(0)
摘要: This example demonstrates how to convert between a color value in RGB (three integer values in the range 0 to 255 representing red, green, and blue) a 阅读全文
posted @ 2018-09-02 22:02 Borter 阅读(146) 评论(0) 推荐(0)
摘要: To draw on the screen, it is first necessary to subclass a JComponent and override its paint() method. The paint() method is automatically called by t 阅读全文
posted @ 2018-09-02 22:01 Borter 阅读(159) 评论(0) 推荐(0)
摘要: This is the simplest application to animate an array of images. 阅读全文
posted @ 2018-09-02 22:00 Borter 阅读(114) 评论(0) 推荐(0)
摘要: // See e575 The Quintessential Drawing Program public void paint(Graphics g) { // Retrieve the graphics context; this object is used to paint shapes Graphics2D g2d = (Graphics2D)g;... 阅读全文
posted @ 2018-09-02 22:00 Borter 阅读(147) 评论(0) 推荐(0)
摘要: The print dialog allows the user to change the default printer settings such as the default printer, number of copies, range of pages, etc. 阅读全文
posted @ 2018-09-02 21:58 Borter 阅读(145) 评论(0) 推荐(0)
摘要: PrinterJob pjob = PrinterJob.getPrinterJob(); PageFormat pf = pjob.defaultPage(); if (portrait) { pf.setOrientation(PageFormat.PORTRAIT); } else { pf.setOrientation(... 阅读全文
posted @ 2018-09-02 21:58 Borter 阅读(338) 评论(0) 推荐(0)
摘要: A Book object is used when printing pages with different page formats. This example prints the first page in landscape and five more pages in portrait 阅读全文
posted @ 2018-09-02 21:57 Borter 阅读(241) 评论(0) 推荐(0)
摘要: Note that (0, 0) of the Graphics object is at the top-left of the actual page, which is outside the printable area. 阅读全文
posted @ 2018-09-02 21:56 Borter 阅读(274) 评论(0) 推荐(0)
摘要: Note that (0, 0) of the Graphics object is at the top-left of the actual page, outside the printable area. In this example, the Graphics object is tra 阅读全文
posted @ 2018-09-02 21:55 Borter 阅读(229) 评论(0) 推荐(0)
摘要: The page format dialog allows the user to change the default page format values such as the orientation and paper size. 阅读全文
posted @ 2018-09-02 21:55 Borter 阅读(296) 评论(0) 推荐(0)
摘要: Images in accelerated memory are much faster to draw on the screen. This example demonstrates how to take an image and make an accelerated copy of it 阅读全文
posted @ 2018-09-02 21:54 Borter 阅读(191) 评论(0) 推荐(0)
摘要: This example demonstrates a 3x3 kernel that sharpens an image. 阅读全文
posted @ 2018-09-02 21:53 Borter 阅读(251) 评论(0) 推荐(0)
摘要: ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY); ColorConvertOp op = new ColorConvertOp(cs, null); bufferedImage = op.filter(bufferedImage, null); Related Examples 阅读全文
posted @ 2018-09-02 21:53 Borter 阅读(255) 评论(0) 推荐(0)
摘要: This example demonstrates how to convert a byte array of pixel values that are indices to a color table into a BufferedImage. In particular, the examp 阅读全文
posted @ 2018-09-02 21:52 Borter 阅读(197) 评论(0) 推荐(0)
摘要: // Get a pixel int rgb = bufferedImage.getRGB(x, y); // Get all the pixels int w = bufferedImage.getWidth(null); int h = bufferedImage.getHeight(null); int[] rgbs = new ... 阅读全文
posted @ 2018-09-02 21:51 Borter 阅读(276) 评论(0) 推荐(0)
摘要: This example demonstrates how to convert a byte array of pixel values that are indices to a color table into an Image. In particular, the example gene 阅读全文
posted @ 2018-09-02 21:51 Borter 阅读(145) 评论(0) 推荐(0)
摘要: An Image object cannot be converted to a BufferedImage object. The closest equivalent is to create a buffered image and then draw the image on the buf 阅读全文
posted @ 2018-09-02 21:50 Borter 阅读(155) 评论(0) 推荐(0)
摘要: This example demonstrates a 3x3 kernel that blurs an image. 阅读全文
posted @ 2018-09-02 21:50 Borter 阅读(188) 评论(0) 推荐(0)
摘要: // This method returns true if the specified image has transparent pixels public static boolean hasAlpha(Image image) { // If buffered image, the color model is readily available ... 阅读全文
posted @ 2018-09-02 21:49 Borter 阅读(173) 评论(0) 推荐(0)
摘要: // This method returns the color model of an image public static ColorModel getColorModel(Image image) { // If buffered image, the color model is readily available if (image instan... 阅读全文
posted @ 2018-09-02 21:48 Borter 阅读(161) 评论(0) 推荐(0)
摘要: A IndexColorModel is used to represent the color table of a GIF image. 阅读全文
posted @ 2018-09-02 21:48 Borter 阅读(129) 评论(0) 推荐(0)
摘要: Images in accelerated memory are much faster to draw on the screen. However, accelerated memory is typically limited and it is usually necessary for a 阅读全文
posted @ 2018-09-02 21:48 Borter 阅读(134) 评论(0) 推荐(0)
摘要: // To create a buffered image, see e666 创建缓冲图像 // Flip the image vertically AffineTransform tx = AffineTransform.getScaleInstance(1, -1); tx.translate(0, -image.getHeight(null)); ... 阅读全文
posted @ 2018-09-02 21:47 Borter 阅读(154) 评论(0) 推荐(0)
摘要: This example demonstrates a 3x3 kernel that embosses an image. 阅读全文
posted @ 2018-09-02 21:46 Borter 阅读(259) 评论(0) 推荐(0)
摘要: This example demonstrates how to create a filter that can modify any of the RGB pixel values in an image. Here's some code that uses the filter: 阅读全文
posted @ 2018-09-02 21:46 Borter 阅读(268) 评论(0) 推荐(0)
摘要: To draw on a buffered image, create a graphics context on the buffered image. If the buffered image supports transparency, (see e661 确定图像中是否有透明像素), pi 阅读全文
posted @ 2018-09-02 21:45 Borter 阅读(185) 评论(0) 推荐(0)
摘要: AffineTransform tx = new AffineTransform(); tx.scale(scalex, scaley); tx.shear(shiftx, shifty); tx.translate(x, y); tx.rotate(radians, bufferedImage.getWidth()/2, bufferedImage.getHei... 阅读全文
posted @ 2018-09-02 21:44 Borter 阅读(120) 评论(0) 推荐(0)
摘要: // From an Image image = createImage(new FilteredImageSource(image.getSource(), new CropImageFilter(x, y, w, h))); // From a BufferedImage bufferedImage = bufferedImage.getSubimage... 阅读全文
posted @ 2018-09-02 21:44 Borter 阅读(110) 评论(0) 推荐(0)
摘要: // This method returns an Image object from a buffered image public static Image toImage(BufferedImage bufferedImage) { return Toolkit.getDefaultToolkit().createImage(bufferedImage.g... 阅读全文
posted @ 2018-09-02 21:43 Borter 阅读(110) 评论(0) 推荐(0)
摘要: A buffered image is a type of image whose pixels can be modified. For example, you can draw on a buffered image and then draw the resulting buffered i 阅读全文
posted @ 2018-09-02 21:43 Borter 阅读(266) 评论(0) 推荐(0)
摘要: This example demonstrates how to brighten or darken an RGB buffered image by scaling the red, green, and blue values in the image. If the image is not 阅读全文
posted @ 2018-09-02 21:42 Borter 阅读(121) 评论(0) 推荐(0)
摘要: Shape line = new Line2D.Float(x1, y1, x2, y2); Shape arc = new Arc2D.Float(x, y, w, h, start, extent, type); Shape oval = new Ellipse2D.Float(x, y, w, h); Shape rectangle = new Rectangle2D... 阅读全文
posted @ 2018-09-02 21:38 Borter 阅读(117) 评论(0) 推荐(0)
摘要: AffineTransform tx = new AffineTransform(); tx.scale(scalex, scaley); tx.shear(shiftx, shifty); tx.translate(x, y); tx.rotate(radians); Shape newShape = tx.createTransformedShape(... 阅读全文
posted @ 2018-09-02 21:38 Borter 阅读(164) 评论(0) 推荐(0)
摘要: GeneralPath shape = new GeneralPath(); shape.moveTo(x, y); shape.lineTo(x, y); shape.quadTo(controlPointX, controlPointY, x, y); shape.curveTo(controlPointX1, controlPointY1, controlP... 阅读全文
posted @ 2018-09-02 21:37 Borter 阅读(278) 评论(0) 推荐(0)
摘要: Area shape = new Area(shape1); shape.add(new Area(shape2)); shape.subtract(new Area(shape3)); shape.intersect(new Area(shape4)); shape.exclusiveOr(new Area(shape5)); Related Exa... 阅读全文
posted @ 2018-09-02 21:36 Borter 阅读(151) 评论(0) 推荐(0)
摘要: Shape getTextShape(Graphics2D g2d, String str, Font font) { FontRenderContext frc = g2d.getFontRenderContext(); TextLayout tl = new TextLayout(str, font, frc); return tl.getOut... 阅读全文
posted @ 2018-09-02 21:34 Borter 阅读(196) 评论(0) 推荐(0)
摘要: This example applies a new font and background color to a part of the text. You can apply styles to as many parts of the text as you need. See TextAtt 阅读全文
posted @ 2018-09-02 21:34 Borter 阅读(116) 评论(0) 推荐(0)
摘要: A font family refers to a set of font faces with a related typographic design. For example, the font faces in the family Lucida Sans Typewriter might 阅读全文
posted @ 2018-09-02 21:33 Borter 阅读(169) 评论(0) 推荐(0)
摘要: To create a Font object to draw text, it is necessary to specify the font face name. This example demonstrates how to retrieve all the font face names 阅读全文
posted @ 2018-09-02 21:33 Borter 阅读(109) 评论(0) 推荐(0)
摘要: In order to change the font of the text, you need to supply an attributed string to the LineBreakMeasurer. See e655 混合风格的文本 for an example. 阅读全文
posted @ 2018-09-02 21:30 Borter 阅读(132) 评论(0) 推荐(0)
摘要: component.addMouseListener(new MyMouseListener()); public class MyMouseListener extends MouseAdapter { public void mouseClicked(MouseEvent evt) { if (evt.getClickCoun... 阅读全文
posted @ 2018-09-02 21:29 Borter 阅读(151) 评论(0) 推荐(0)
摘要: You can get the key that was pressed either as a key character (which is a Unicode character) or as a key code (a special value representing a particu 阅读全文
posted @ 2018-09-02 21:28 Borter 阅读(102) 评论(0) 推荐(0)
摘要: component.addMouseListener(new MyMouseListener()); public class MyMouseListener extends MouseAdapter { public void mouseClicked(MouseEvent evt) { if ((evt.getModifier... 阅读全文
posted @ 2018-09-02 21:28 Borter 阅读(229) 评论(0) 推荐(0)
摘要: component.addMouseMotionListener(new MyMouseMotionListener()); public class MyMouseMotionListener extends MouseMotionAdapter { public void mouseMoved(MouseEvent evt) { ... 阅读全文
posted @ 2018-09-02 21:28 Borter 阅读(174) 评论(0) 推荐(0)
摘要: If an event handler is specific to a component (that is, not shared by other components), there is no need to declare a class to handle the event. The 阅读全文
posted @ 2018-09-02 21:24 Borter 阅读(153) 评论(0) 推荐(0)
摘要: An object wishing to fire item events must implement ItemSelectable. This example shows typical code that an object must implement to fire item events 阅读全文
posted @ 2018-09-02 21:24 Borter 阅读(135) 评论(0) 推荐(0)
摘要: component.addFocusListener(new MyFocusListener()); public class MyFocusListener extends FocusAdapter { public void focusGained(FocusEvent evt) { // The component gain... 阅读全文
posted @ 2018-09-02 21:23 Borter 阅读(221) 评论(0) 推荐(0)
摘要: Action events are fired by subclasses of AbstractButton and includes buttons, checkboxes, and menus. 阅读全文
posted @ 2018-09-02 21:14 Borter 阅读(239) 评论(0) 推荐(0)
摘要: public class DropTargetComponent extends JComponent implements DropTargetListener { public DropTargetComponent() { new DropTarget(this, this); } public void dragE... 阅读全文
posted @ 2018-09-02 21:13 Borter 阅读(285) 评论(0) 推荐(0)
摘要: This example demonstrates the code needed to make a component draggable. The object being transferred in this example is a string. 阅读全文
posted @ 2018-09-02 21:12 Borter 阅读(149) 评论(0) 推荐(0)
摘要: The drop target in this example only accepts dropped String objects. A drop target must implement DropTargetListener and supply an implementation for 阅读全文
posted @ 2018-09-02 21:12 Borter 阅读(111) 评论(0) 推荐(0)
摘要: Setting an image on the system clipboard requires a custom Transferable object to hold the image while on the clipboard. 阅读全文
posted @ 2018-09-02 21:11 Borter 阅读(315) 评论(0) 推荐(0)
摘要: This examples defines methods for getting and setting text on the system clipboard. 阅读全文
posted @ 2018-09-02 21:10 Borter 阅读(245) 评论(0) 推荐(0)
摘要: See also e551 精简的Applet. 阅读全文
posted @ 2018-09-02 21:08 Borter 阅读(150) 评论(0) 推荐(0)
摘要: // See also e551 精简的Applet applet.showStatus("Your Message Here"); Related Examples 阅读全文
posted @ 2018-09-02 21:08 Borter 阅读(124) 评论(0) 推荐(0)
摘要: // See also e551 精简的Applet public void init() { // Load audio clip AudioClip ac = getAudioClip(getDocumentBase(), "http://hostname.com/audio.au"); // Play audio clip... 阅读全文
posted @ 2018-09-02 21:07 Borter 阅读(150) 评论(0) 推荐(0)
摘要: try { URL url = new URL("http://hostname/audio.au"); AudioClip ac = Applet.newAudioClip(url); ac.play(); } catch (MalformedURLException e) { } Related Examples ... 阅读全文
posted @ 2018-09-02 21:06 Borter 阅读(163) 评论(0) 推荐(0)
摘要: An applet can be configured through the use of applet parameters. For example, the contents for a news ticker applet could be specified through an app 阅读全文
posted @ 2018-09-02 21:05 Borter 阅读(227) 评论(0) 推荐(0)
摘要: // See also e551 精简的Applet try { URL url = new URL(getDocumentBase(), "http://hostname.com/page.html"); applet.getAppletContext().showDocument(url); } catch (Malformed... 阅读全文
posted @ 2018-09-02 21:05 Borter 阅读(124) 评论(0) 推荐(0)
摘要: Every applet must subclass Applet. Here is an example of an HTML file that will cause the browser to load and start the applet: 阅读全文
posted @ 2018-09-02 21:04 Borter 阅读(134) 评论(0) 推荐(0)
摘要: This is the simplest applet to animate an array of images. In practice, you should use double-buffering (which this example does not use) to eliminate 阅读全文
posted @ 2018-09-02 21:03 Borter 阅读(147) 评论(0) 推荐(0)
摘要: The try/catch statement encloses some code and is used to handle errors and exceptions that might occur in that code. Here is the general syntax of th 阅读全文
posted @ 2018-09-02 21:01 Borter 阅读(107) 评论(0) 推荐(0)
摘要: The if statement encloses some code which is executed only if a condition is true. The general syntax of the if statement is: The if statement has two 阅读全文
posted @ 2018-09-02 20:59 Borter 阅读(167) 评论(0) 推荐(0)
摘要: The for statement can be used to conveninently iterate over the elements of an array. The general syntax of the array-based for statement is: The arra 阅读全文
posted @ 2018-09-02 20:58 Borter 阅读(177) 评论(0) 推荐(0)
摘要: All errors and exceptions extend from Throwable. By catching Throwable, it is possible to handle all unexpected conditions. There are several scenario 阅读全文
posted @ 2018-09-02 20:57 Borter 阅读(196) 评论(0) 推荐(0)