Search in sources :

Example 1 with Painter

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;
}
Also used : JXTitledPanel(org.jdesktop.swingx.JXTitledPanel) FocusAdapter(java.awt.event.FocusAdapter) MouseEvent(java.awt.event.MouseEvent) JXImageView(org.jdesktop.swingx.JXImageView) Painter(org.jdesktop.swingx.painter.Painter) MouseAdapter(java.awt.event.MouseAdapter) Dimension(java.awt.Dimension) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) FocusEvent(java.awt.event.FocusEvent) BufferedImage(java.awt.image.BufferedImage)

Aggregations

Dimension (java.awt.Dimension)1 Image (java.awt.Image)1 FocusAdapter (java.awt.event.FocusAdapter)1 FocusEvent (java.awt.event.FocusEvent)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 BufferedImage (java.awt.image.BufferedImage)1 JXImageView (org.jdesktop.swingx.JXImageView)1 JXTitledPanel (org.jdesktop.swingx.JXTitledPanel)1 Painter (org.jdesktop.swingx.painter.Painter)1