|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container java.awt.Window java.awt.Dialog javax.swing.JDialog com.asprise.util.ui.JImageDialog
A dialog allows the user to load images and to perform basic image editing tasks.
This component proves to be extremely useful if you need the user to
load/browse/edit/specify images in your applications.
Advantages include:
The user can load images from local computer or the web, he or she can also acquire images from digital cammeras and scanners. After the image has been loaded, the user can rotate, clip, flip, and scale the image. The image has been loaded and edited, the user can save the image or select the image - which will be used in your applications.
Sample uses:
1. Modal (synchronous) mode
JImageDialog dialog = new JImageDialog(frame, "Sample", true); // Modal dialog
BufferedImage image = dialog.showDialog();
...
2. Asynchronous mode
public class JImageDialogSample extends JPanel implements JImageDialogListener {
...
BufferedImage image;
// Displays selected image if any.
public void paintComponent(Graphics g) {
super.paintComponent(g); // Paint background.
if(image != null)
g.drawImage(image, 0, 0, null);
}
// Sets image and refreshes the panel.
public void setImage(BufferedImage image) {
this.image = image;
setPreferredSize(getPreferredSize());
revalidate();
repaint();
}
// Methods in JImageDialogListener
// When the user presses cancel button, this method will be called.
public void onCancel() {
setImage(null);
}
// When the user presses the selection button, this method will be invoked.
public void onImageSet(BufferedImage image) {
setImage(image);
}
}
...
JImageDialogSample imagePanel = new JImageDialogSample();
JImageDialog dialog = new JImageDialog();
dialog.addImageDialogListener(imagePanel);
dialog.showDialog();
...
Note: Only the licensed copy allows directly access to image reading and writing functions and other advanced features.
Field Summary |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.WindowConstants |
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
JImageDialog()
Creates a JImageDialog with default settings. |
|
JImageDialog(Dialog parent,
String title,
boolean modal)
Creates an image dialog with parent dialog, title and modal option. |
|
JImageDialog(Frame parent,
String title,
boolean modal)
Creates an image dialog with parent frame, title and modal option. |
Method Summary | |
void |
addImageDialogListener(JImageDialogListener l)
Add an ImageDialogListener. |
String |
getDefaultFileExtension()
Get default file extension. |
void |
removeImageAcquisitionDialogListener(JImageDialogListener l)
Remove an ImageAcquisitionDialogListener. |
void |
setDefaultFileExtension(String defaultExt)
Set default file extension. |
void |
setImage(File file)
Loads the image from file and put it in the editor. |
void |
setImage(Image image)
Sets the image to be edited/viewed. |
void |
setImage(URL url)
Loads the image from url and put it in the editor. |
void |
setProxy(String host,
int port)
Set the proxy. |
void |
setSelectionButtonText(String text)
Set the selection button text. |
BufferedImage |
showDialog()
Brings up the image dialog. |
Methods inherited from class javax.swing.JDialog |
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, update |
Methods inherited from class java.awt.Dialog |
addNotify, dispose, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public JImageDialog()
public JImageDialog(Dialog parent, String title, boolean modal)
parent
- title
- modal
- public JImageDialog(Frame parent, String title, boolean modal)
parent
- title
- modal
- Method Detail |
public void setImage(Image image)
image
- public void setImage(URL url)
url
- public void setImage(File file)
file
- public BufferedImage showDialog()
null
if the user cancels selection.public String getDefaultFileExtension()
jpg
public void setDefaultFileExtension(String defaultExt)
defaultExt
- default extension, samples are jpg
(default), png
, bmp
, etc.public void addImageDialogListener(JImageDialogListener l)
l
is null
l
- public void removeImageAcquisitionDialogListener(JImageDialogListener l)
l
is null
l
- public void setProxy(String host, int port)
host
- host nameport
- port.public void setSelectionButtonText(String text)
text
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |