摘要:
This example demonstrates a 3x3 kernel that embosses an image. 阅读全文
摘要:
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: 阅读全文
摘要:
To draw on a buffered image, create a graphics context on the buffered image. If the buffered image supports transparency, (see e661 确定图像中是否有透明像素), pi 阅读全文
摘要:
AffineTransform tx = new AffineTransform(); tx.scale(scalex, scaley); tx.shear(shiftx, shifty); tx.translate(x, y); tx.rotate(radians, bufferedImage.getWidth()/2, bufferedImage.getHei... 阅读全文
摘要:
// From an Image image = createImage(new FilteredImageSource(image.getSource(), new CropImageFilter(x, y, w, h))); // From a BufferedImage bufferedImage = bufferedImage.getSubimage... 阅读全文
摘要:
// This method returns an Image object from a buffered image public static Image toImage(BufferedImage bufferedImage) { return Toolkit.getDefaultToolkit().createImage(bufferedImage.g... 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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... 阅读全文
摘要:
AffineTransform tx = new AffineTransform(); tx.scale(scalex, scaley); tx.shear(shiftx, shifty); tx.translate(x, y); tx.rotate(radians); Shape newShape = tx.createTransformedShape(... 阅读全文
摘要:
GeneralPath shape = new GeneralPath(); shape.moveTo(x, y); shape.lineTo(x, y); shape.quadTo(controlPointX, controlPointY, x, y); shape.curveTo(controlPointX1, controlPointY1, controlP... 阅读全文
摘要:
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... 阅读全文
摘要:
Shape getTextShape(Graphics2D g2d, String str, Font font) { FontRenderContext frc = g2d.getFontRenderContext(); TextLayout tl = new TextLayout(str, font, frc); return tl.getOut... 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
In order to change the font of the text, you need to supply an attributed string to the LineBreakMeasurer. See e655 混合风格的文本 for an example. 阅读全文
摘要:
component.addMouseListener(new MyMouseListener()); public class MyMouseListener extends MouseAdapter { public void mouseClicked(MouseEvent evt) { if (evt.getClickCoun... 阅读全文
摘要:
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 阅读全文
摘要:
component.addMouseMotionListener(new MyMouseMotionListener()); public class MyMouseMotionListener extends MouseMotionAdapter { public void mouseMoved(MouseEvent evt) { ... 阅读全文
摘要:
component.addMouseListener(new MyMouseListener()); public class MyMouseListener extends MouseAdapter { public void mouseClicked(MouseEvent evt) { if ((evt.getModifier... 阅读全文
摘要:
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 阅读全文
摘要:
An object wishing to fire item events must implement ItemSelectable. This example shows typical code that an object must implement to fire item events 阅读全文
摘要:
component.addFocusListener(new MyFocusListener()); public class MyFocusListener extends FocusAdapter { public void focusGained(FocusEvent evt) { // The component gain... 阅读全文
摘要:
Action events are fired by subclasses of AbstractButton and includes buttons, checkboxes, and menus. 阅读全文
摘要:
public class DropTargetComponent extends JComponent implements DropTargetListener { public DropTargetComponent() { new DropTarget(this, this); } public void dragE... 阅读全文
摘要:
This example demonstrates the code needed to make a component draggable. The object being transferred in this example is a string. 阅读全文
摘要:
The drop target in this example only accepts dropped String objects. A drop target must implement DropTargetListener and supply an implementation for 阅读全文
摘要:
Setting an image on the system clipboard requires a custom Transferable object to hold the image while on the clipboard. 阅读全文
摘要:
This examples defines methods for getting and setting text on the system clipboard. 阅读全文
摘要:
See also e551 精简的Applet. 阅读全文
摘要:
// See also e551 精简的Applet applet.showStatus("Your Message Here"); Related Examples 阅读全文
摘要:
// See also e551 精简的Applet public void init() { // Load audio clip AudioClip ac = getAudioClip(getDocumentBase(), "http://hostname.com/audio.au"); // Play audio clip... 阅读全文
摘要:
try { URL url = new URL("http://hostname/audio.au"); AudioClip ac = Applet.newAudioClip(url); ac.play(); } catch (MalformedURLException e) { } Related Examples ... 阅读全文
摘要:
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 阅读全文
摘要:
// See also e551 精简的Applet try { URL url = new URL(getDocumentBase(), "http://hostname.com/page.html"); applet.getAppletContext().showDocument(url); } catch (Malformed... 阅读全文
摘要:
Every applet must subclass Applet. Here is an example of an HTML file that will cause the browser to load and start the applet: 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文