use of org.jdesktop.swingx.painter.Painter in project adempiere by adempiere.
the class WindowMenu method createImageBox.
private JXTitledPanel createImageBox(JPanel p, JDialog dialog, int width, int height, CFrame window) {
BufferedImage bi = new BufferedImage(window.getWidth(), window.getHeight(), // TYPE_INT_ARGB is tinted red
BufferedImage.TYPE_INT_RGB);
window.paintAll(bi.createGraphics());
Image image = bi.getScaledInstance(width, height, Image.SCALE_SMOOTH);
final JXTitledPanel box = new JXTitledPanel();
final Painter painter = box.getTitlePainter();
box.setTitlePainter(null);
box.setFocusable(true);
box.setTitle(window.getTitle());
final JXImageView imageView = new JXImageView();
imageView.setImage(image);
imageView.setEditable(false);
box.setContentContainer(imageView);
box.setPreferredSize(new Dimension(width, height));
box.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
box.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
box.requestFocus();
}
});
imageView.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
box.requestFocus();
}
});
PreviewMouseAdapter adapter = new PreviewMouseAdapter(dialog, window);
box.addMouseListener(adapter);
imageView.addMouseListener(adapter);
imageView.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
box.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
box.setTitlePainter(painter);
}
@Override
public void focusLost(FocusEvent e) {
box.setTitlePainter(null);
}
});
return box;
}
Aggregations