Example usage for java.awt Cursor HAND_CURSOR

List of usage examples for java.awt Cursor HAND_CURSOR

Introduction

In this page you can find the example usage for java.awt Cursor HAND_CURSOR.

Prototype

int HAND_CURSOR

To view the source code for java.awt Cursor HAND_CURSOR.

Click Source Link

Document

The hand cursor type.

Usage

From source file:op.care.med.inventory.DlgNewStocks.java

/**
 * This method is called from within the constructor to
 * initialize the form./*from w  w w .  j a v a 2 s  .co  m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc=" Erzeugter Quelltext ">//GEN-BEGIN:initComponents
private void initComponents() {
    mainPane = new JPanel();
    lblPZN = new JLabel();
    panel2 = new JPanel();
    txtMedSuche = new JXSearchField();
    hSpacer1 = new JPanel(null);
    btnMed = new JButton();
    lblProd = new JLabel();
    cmbMProdukt = new JComboBox<>();
    lblInventory = new JLabel();
    lblResident = new JLabel();
    txtBWSuche = new JTextField();
    lblAmount = new JLabel();
    lblPack = new JLabel();
    cmbPackung = new JComboBox<>();
    lblExpires = new JLabel();
    txtExpires = new JTextField();
    panel3 = new JPanel();
    lblWeightControl = new JLabel();
    txtWeightControl = new JTextField();
    lblRemark = new JLabel();
    txtBemerkung = new JTextField();
    btnPrint = new JToggleButton();
    panel1 = new JPanel();
    btnClose = new JButton();
    btnApply = new JButton();

    //======== this ========
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("Medikamente einbuchen");
    setMinimumSize(new Dimension(640, 300));
    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));

    //======== mainPane ========
    {
        mainPane.setLayout(new FormLayout(
                "14dlu, $lcgap, default, $lcgap, 39dlu:grow, $lcgap, default:grow, $lcgap, 14dlu",
                "14dlu, 2*($lgap, fill:17dlu), $lgap, fill:default, $lgap, 17dlu, 4*($lgap, fill:17dlu), 10dlu, fill:default, $lgap, 14dlu"));

        //---- lblPZN ----
        lblPZN.setText("PZN oder Suchbegriff");
        lblPZN.setFont(new Font("Arial", Font.PLAIN, 14));
        mainPane.add(lblPZN, CC.xy(3, 3));

        //======== panel2 ========
        {
            panel2.setLayout(new BoxLayout(panel2, BoxLayout.LINE_AXIS));

            //---- txtMedSuche ----
            txtMedSuche.setFont(new Font("Arial", Font.PLAIN, 14));
            txtMedSuche.addActionListener(e -> txtMedSucheActionPerformed(e));
            panel2.add(txtMedSuche);
            panel2.add(hSpacer1);

            //---- btnMed ----
            btnMed.setBackground(Color.white);
            btnMed.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
            btnMed.setToolTipText("Medikamente bearbeiten");
            btnMed.setBorder(null);
            btnMed.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
            btnMed.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnMed.addActionListener(e -> btnMedActionPerformed(e));
            panel2.add(btnMed);
        }
        mainPane.add(panel2, CC.xywh(5, 3, 4, 1));

        //---- lblProd ----
        lblProd.setText("Produkt");
        lblProd.setFont(new Font("Arial", Font.PLAIN, 14));
        mainPane.add(lblProd, CC.xy(3, 5));

        //---- cmbMProdukt ----
        cmbMProdukt.setModel(new DefaultComboBoxModel<>(new String[] {

        }));
        cmbMProdukt.setFont(new Font("Arial", Font.PLAIN, 14));
        cmbMProdukt.addItemListener(e -> cmbMProduktItemStateChanged(e));
        mainPane.add(cmbMProdukt, CC.xywh(5, 5, 4, 1));

        //---- lblInventory ----
        lblInventory.setText("vorhandene Vorr\u00e4te");
        lblInventory.setFont(new Font("Arial", Font.PLAIN, 14));
        mainPane.add(lblInventory, CC.xy(3, 13));

        //---- lblResident ----
        lblResident.setText("Zuordnung zu Bewohner");
        lblResident.setFont(new Font("Arial", Font.PLAIN, 14));
        mainPane.add(lblResident, CC.xy(3, 17));

        //---- txtBWSuche ----
        txtBWSuche.setFont(new Font("Arial", Font.PLAIN, 14));
        txtBWSuche.addCaretListener(e -> txtBWSucheCaretUpdate(e));
        mainPane.add(txtBWSuche, CC.xy(5, 17));

        //---- lblAmount ----
        lblAmount.setText("Buchungsmenge");
        lblAmount.setFont(new Font("Arial", Font.PLAIN, 14));
        mainPane.add(lblAmount, CC.xy(3, 11));

        //---- lblPack ----
        lblPack.setText("Packung");
        lblPack.setFont(new Font("Arial", Font.PLAIN, 14));
        mainPane.add(lblPack, CC.xy(3, 7));

        //---- cmbPackung ----
        cmbPackung.setModel(new DefaultComboBoxModel<>(new String[] {

        }));
        cmbPackung.setFont(new Font("Arial", Font.PLAIN, 14));
        cmbPackung.addItemListener(e -> cmbPackungItemStateChanged(e));
        mainPane.add(cmbPackung, CC.xywh(5, 7, 4, 1));

        //---- lblExpires ----
        lblExpires.setText("expires");
        lblExpires.setFont(new Font("Arial", Font.PLAIN, 14));
        mainPane.add(lblExpires, CC.xy(3, 9));

        //---- txtExpires ----
        txtExpires.setFont(new Font("Arial", Font.PLAIN, 14));
        txtExpires.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                txtExpiresFocusGained(e);
            }

            @Override
            public void focusLost(FocusEvent e) {
                txtExpiresFocusLost(e);
            }
        });
        txtExpires.addActionListener(e -> txtExpiresActionPerformed(e));
        mainPane.add(txtExpires, CC.xywh(5, 9, 3, 1, CC.DEFAULT, CC.FILL));

        //======== panel3 ========
        {
            panel3.setLayout(new FormLayout("pref, $lcgap, default:grow", "fill:17dlu"));

            //---- lblWeightControl ----
            lblWeightControl.setText("weightcontrol");
            lblWeightControl.setFont(new Font("Arial", Font.PLAIN, 14));
            lblWeightControl.setBackground(Color.pink);
            panel3.add(lblWeightControl, CC.xy(1, 1));

            //---- txtWeightControl ----
            txtWeightControl.setFont(new Font("Arial", Font.PLAIN, 14));
            txtWeightControl.setBackground(Color.pink);
            txtWeightControl.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    txtWeightControlFocusGained(e);
                }
            });
            txtWeightControl.addCaretListener(e -> txtWeightControlCaretUpdate(e));
            panel3.add(txtWeightControl, CC.xy(3, 1, CC.DEFAULT, CC.FILL));
        }
        mainPane.add(panel3, CC.xy(7, 11));

        //---- lblRemark ----
        lblRemark.setText("Bemerkung");
        lblRemark.setFont(new Font("Arial", Font.PLAIN, 14));
        mainPane.add(lblRemark, CC.xy(3, 15));

        //---- txtBemerkung ----
        txtBemerkung.setFont(new Font("Arial", Font.PLAIN, 14));
        txtBemerkung.addCaretListener(e -> txtBemerkungCaretUpdate(e));
        mainPane.add(txtBemerkung, CC.xywh(5, 15, 4, 1));

        //---- btnPrint ----
        btnPrint.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/printer-on.png")));
        btnPrint.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/printer-off.png")));
        btnPrint.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnPrint.setEnabled(false);
        btnPrint.addItemListener(e -> btnPrintItemStateChanged(e));
        mainPane.add(btnPrint, CC.xy(3, 19, CC.RIGHT, CC.DEFAULT));

        //======== panel1 ========
        {
            panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS));

            //---- btnClose ----
            btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
            btnClose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnClose.addActionListener(e -> btnCloseActionPerformed(e));
            panel1.add(btnClose);

            //---- btnApply ----
            btnApply.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
            btnApply.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnApply.addActionListener(e -> btnApplyActionPerformed(e));
            panel1.add(btnApply);
        }
        mainPane.add(panel1, CC.xywh(7, 19, 2, 1, CC.RIGHT, CC.DEFAULT));
    }
    contentPane.add(mainPane);
    pack();
    setLocationRelativeTo(getOwner());
}

From source file:op.care.prescription.DlgRegular.java

/**
 * This method is called from within the constructor to
 * initialize the form./*from w w w  .j a v  a  2  s .  c  om*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    jPanel1 = new JPanel();
    txtMed = new JXSearchField();
    cmbMed = new JComboBox<>();
    panel4 = new JPanel();
    btnMed = new JButton();
    cmbIntervention = new JComboBox<>();
    txtIntervention = new JXSearchField();
    jPanel8 = new JPanel();
    jspDosis = new JScrollPane();
    tblDosis = new JTable();
    panel2 = new JPanel();
    btnAddDosis = new JButton();
    jPanel3 = new JPanel();
    pnlOFF = new JPanel();
    rbActive = new JRadioButton();
    rbDate = new JRadioButton();
    txtTo = new JTextField();
    rbEndOfPackage = new JRadioButton();
    jScrollPane3 = new JScrollPane();
    txtBemerkung = new JTextPane();
    lblText = new JLabel();
    pnlON = new JPanel();
    cmbDocON = new JComboBox<>();
    btnAddGP = new JButton();
    cmbHospitalON = new JComboBox<>();
    btnAddHospital = new JButton();
    panel1 = new JPanel();
    btnClose = new JButton();
    btnSave = new JButton();
    lblTX = new JLabel();

    //======== this ========
    setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    setResizable(false);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout("$rgap, $lcgap, default, $lcgap, pref, $lcgap, $rgap",
            "$rgap, $lgap, fill:default:grow, $lgap, fill:default, $lgap, $rgap"));

    //======== jPanel1 ========
    {
        jPanel1.setBorder(null);
        jPanel1.setLayout(new FormLayout("68dlu, $lcgap, 284dlu, $lcgap, pref",
                "2*(16dlu, $lgap), default, $lgap, fill:default:grow"));

        //---- txtMed ----
        txtMed.setFont(new Font("Arial", Font.PLAIN, 14));
        txtMed.setPrompt("Medikamente");
        txtMed.setFocusBehavior(PromptSupport.FocusBehavior.HIGHLIGHT_PROMPT);
        txtMed.addActionListener(e -> txtMedActionPerformed(e));
        txtMed.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                txtMedFocusGained(e);
            }
        });
        jPanel1.add(txtMed, CC.xy(1, 1));

        //---- cmbMed ----
        cmbMed.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbMed.setFont(new Font("Arial", Font.PLAIN, 14));
        cmbMed.addItemListener(e -> cmbMedItemStateChanged(e));
        jPanel1.add(cmbMed, CC.xy(3, 1));

        //======== panel4 ========
        {
            panel4.setLayout(new BoxLayout(panel4, BoxLayout.LINE_AXIS));

            //---- btnMed ----
            btnMed.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
            btnMed.setBorderPainted(false);
            btnMed.setBorder(null);
            btnMed.setContentAreaFilled(false);
            btnMed.setToolTipText("Neues Medikament eintragen");
            btnMed.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnMed.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
            btnMed.addActionListener(e -> btnMedActionPerformed(e));
            panel4.add(btnMed);
        }
        jPanel1.add(panel4, CC.xy(5, 1));

        //---- cmbIntervention ----
        cmbIntervention
                .setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbIntervention.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(cmbIntervention, CC.xywh(3, 3, 3, 1));

        //---- txtIntervention ----
        txtIntervention.setFont(new Font("Arial", Font.PLAIN, 14));
        txtIntervention.setPrompt("Massnahmen");
        txtIntervention.addActionListener(e -> txtMassActionPerformed(e));
        jPanel1.add(txtIntervention, CC.xy(1, 3));

        //======== jPanel8 ========
        {
            jPanel8.setBorder(new TitledBorder(null, "Dosis / H\u00e4ufigkeit", TitledBorder.LEADING,
                    TitledBorder.DEFAULT_POSITION, new Font("Arial", Font.PLAIN, 14)));
            jPanel8.setFont(new Font("Arial", Font.PLAIN, 14));
            jPanel8.setLayout(new FormLayout("370dlu", "fill:default:grow, $lgap, pref"));

            //======== jspDosis ========
            {
                jspDosis.setToolTipText(null);

                //---- tblDosis ----
                tblDosis.setModel(new DefaultTableModel(
                        new Object[][] { { null, null, null, null }, { null, null, null, null },
                                { null, null, null, null }, { null, null, null, null }, },
                        new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
                tblDosis.setSurrendersFocusOnKeystroke(true);
                tblDosis.setToolTipText(null);
                tblDosis.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mousePressed(MouseEvent e) {
                        tblDosisMousePressed(e);
                    }
                });
                jspDosis.setViewportView(tblDosis);
            }
            jPanel8.add(jspDosis, CC.xy(1, 1));

            //======== panel2 ========
            {
                panel2.setLayout(new BoxLayout(panel2, BoxLayout.LINE_AXIS));

                //---- btnAddDosis ----
                btnAddDosis.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
                btnAddDosis.setBorderPainted(false);
                btnAddDosis.setBorder(null);
                btnAddDosis.setContentAreaFilled(false);
                btnAddDosis.setToolTipText("Neue Dosierung eintragen");
                btnAddDosis.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                btnAddDosis.setSelectedIcon(
                        new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
                btnAddDosis.addActionListener(e -> btnAddDosisActionPerformed(e));
                panel2.add(btnAddDosis);
            }
            jPanel8.add(panel2, CC.xy(1, 3, CC.LEFT, CC.DEFAULT));
        }
        jPanel1.add(jPanel8, CC.xywh(1, 7, 5, 1));
    }
    contentPane.add(jPanel1, CC.xy(5, 3));

    //======== jPanel3 ========
    {
        jPanel3.setBorder(null);
        jPanel3.setLayout(new FormLayout("149dlu", "3*(fill:default, $lgap), fill:108dlu:grow, $lgap, 60dlu"));

        //======== pnlOFF ========
        {
            pnlOFF.setBorder(new TitledBorder("Absetzung"));
            pnlOFF.setLayout(new FormLayout("pref, 86dlu:grow", "2*(fill:17dlu, $lgap), fill:17dlu"));

            //---- rbActive ----
            rbActive.setText("text");
            rbActive.setSelected(true);
            rbActive.addItemListener(e -> rbActiveItemStateChanged(e));
            pnlOFF.add(rbActive, CC.xywh(1, 1, 2, 1));

            //---- rbDate ----
            rbDate.setText(null);
            rbDate.addItemListener(e -> rbDateItemStateChanged(e));
            pnlOFF.add(rbDate, CC.xy(1, 3));

            //---- txtTo ----
            txtTo.addFocusListener(new FocusAdapter() {
                @Override
                public void focusLost(FocusEvent e) {
                    txtToFocusLost(e);
                }
            });
            pnlOFF.add(txtTo, CC.xy(2, 3));

            //---- rbEndOfPackage ----
            rbEndOfPackage.setText("text");
            rbEndOfPackage.addItemListener(e -> rbEndOfPackageItemStateChanged(e));
            pnlOFF.add(rbEndOfPackage, CC.xywh(1, 5, 2, 1));
        }
        jPanel3.add(pnlOFF, CC.xy(1, 3));

        //======== jScrollPane3 ========
        {

            //---- txtBemerkung ----
            txtBemerkung.addCaretListener(e -> txtBemerkungCaretUpdate(e));
            jScrollPane3.setViewportView(txtBemerkung);
        }
        jPanel3.add(jScrollPane3, CC.xy(1, 7));

        //---- lblText ----
        lblText.setText("Bemerkung:");
        jPanel3.add(lblText, CC.xy(1, 5));

        //======== pnlON ========
        {
            pnlON.setBorder(new TitledBorder("Ansetzung"));
            pnlON.setLayout(new FormLayout("119dlu:grow, $lcgap, default", "default, $lgap, default"));

            //---- cmbDocON ----
            cmbDocON.setModel(
                    new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
            cmbDocON.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                    cmbDocONKeyPressed(e);
                }
            });
            pnlON.add(cmbDocON, CC.xy(1, 1));

            //---- btnAddGP ----
            btnAddGP.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
            btnAddGP.setBorderPainted(false);
            btnAddGP.setBorder(null);
            btnAddGP.setContentAreaFilled(false);
            btnAddGP.setToolTipText("Neues Medikament eintragen");
            btnAddGP.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnAddGP.setSelectedIcon(
                    new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
            btnAddGP.addActionListener(e -> btnAddGPActionPerformed(e));
            pnlON.add(btnAddGP, CC.xy(3, 1));

            //---- cmbHospitalON ----
            cmbHospitalON.setModel(
                    new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
            pnlON.add(cmbHospitalON, CC.xy(1, 3));

            //---- btnAddHospital ----
            btnAddHospital.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
            btnAddHospital.setBorderPainted(false);
            btnAddHospital.setBorder(null);
            btnAddHospital.setContentAreaFilled(false);
            btnAddHospital.setToolTipText("Neues Medikament eintragen");
            btnAddHospital.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnAddHospital.setSelectedIcon(
                    new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
            btnAddHospital.addActionListener(e -> btnAddHospitalActionPerformed(e));
            pnlON.add(btnAddHospital, CC.xy(3, 3));
        }
        jPanel3.add(pnlON, CC.xy(1, 1));
    }
    contentPane.add(jPanel3, CC.xy(3, 3));

    //======== panel1 ========
    {
        panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS));

        //---- btnClose ----
        btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
        btnClose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnClose.addActionListener(e -> btnCloseActionPerformed(e));
        panel1.add(btnClose);

        //---- btnSave ----
        btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
        btnSave.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnSave.addActionListener(e -> btnSaveActionPerformed(e));
        panel1.add(btnSave);
    }
    contentPane.add(panel1, CC.xy(5, 5, CC.RIGHT, CC.DEFAULT));

    //---- lblTX ----
    lblTX.setText(null);
    lblTX.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/ambulance2.png")));
    contentPane.add(lblTX, CC.xy(3, 5));
    setSize(1015, 640);
    setLocationRelativeTo(getOwner());

    //---- bgMedikament ----
    ButtonGroup bgMedikament = new ButtonGroup();
    bgMedikament.add(rbActive);
    bgMedikament.add(rbDate);
    bgMedikament.add(rbEndOfPackage);
}

From source file:Proiect.uploadFTP.java

public void actionFTP() {
    adressf.addCaretListener(new CaretListener() {
        public void caretUpdate(CaretEvent e) {
            InetAddress thisIp;//from  w  ww  . j a  v a  2 s . com
            try {
                thisIp = InetAddress.getLocalHost();
                titleFTP.setText("Connection: " + thisIp.getHostAddress() + " -> " + adressf.getText());
            } catch (UnknownHostException e1) {
                e1.printStackTrace();
            }
        }
    });

    exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            saveState();
            uploadFTP.dispose();
            tree.dispose();
        }
    });

    connect.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            FTPClient client = new FTPClient();
            FileInputStream fis = null;
            String pass = String.valueOf(passf.getPassword());
            try {
                if (filename == null) {
                    status.setText("File does not exist!");
                } else {
                    // Server address
                    client.connect(adressf.getText());
                    // Login credentials
                    client.login(userf.getText(), pass);
                    if (client.isConnected()) {
                        status.setText("Succesfull transfer!");
                        // File type
                        client.setFileType(FTP.BINARY_FILE_TYPE);
                        // File location
                        File file = new File(filepath);
                        fis = new FileInputStream(file);
                        // Change the folder on the server
                        client.changeWorkingDirectory(folderf.getText());
                        // Save the file on the server
                        client.storeFile(filename, fis);
                    } else {
                        status.setText("Transfer failed!");
                    }
                }
                client.logout();
            } catch (IOException e1) {
                Encrypter.printException(e1);
            } finally {
                try {
                    if (fis != null) {
                        fis.close();
                    }
                    client.disconnect();
                } catch (IOException e1) {
                    Encrypter.printException(e1);
                }
            }
        }
    });

    browsef.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int retval = chooserf.showOpenDialog(chooserf);
            if (retval == JFileChooser.APPROVE_OPTION) {
                status.setText("");
                filename = chooserf.getSelectedFile().getName().toString();
                filepath = chooserf.getSelectedFile().getPath();
                filenf.setText(chooserf.getSelectedFile().getName().toString());
            }
        }
    });

    adv.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            tree.setSize(220, uploadFTP.getHeight());
            tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY());
            tree.setResizable(false);
            tree.setIconImage(Toolkit.getDefaultToolkit()
                    .getImage(getClass().getClassLoader().getResource("assets/ico.png")));
            tree.setUndecorated(true);
            tree.getRootPane().setBorder(BorderFactory.createLineBorder(Encrypter.color_black, 2));
            tree.setVisible(true);
            tree.setLayout(new BorderLayout());

            JLabel labeltree = new JLabel("Server documents");
            labeltree.setOpaque(true);
            labeltree.setBackground(Encrypter.color_light);
            labeltree.setBorder(BorderFactory.createMatteBorder(8, 10, 10, 0, Encrypter.color_light));
            labeltree.setForeground(Encrypter.color_blue);
            labeltree.setFont(Encrypter.font16);

            JButton refresh = new JButton("");
            ImageIcon refresh_icon = getImageIcon("assets/icons/refresh.png");
            refresh.setIcon(refresh_icon);
            refresh.setBackground(Encrypter.color_light);
            refresh.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
            refresh.setForeground(Encrypter.color_black);
            refresh.setFont(Encrypter.font16);
            refresh.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

            final FTPClient client = new FTPClient();
            DefaultMutableTreeNode top = new DefaultMutableTreeNode(adressf.getText());
            DefaultMutableTreeNode files = null;
            DefaultMutableTreeNode leaf = null;

            final JTree tree_view = new JTree(top);
            tree_view.setForeground(Encrypter.color_black);
            tree_view.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
            tree_view.putClientProperty("JTree.lineStyle", "None");
            tree_view.setBackground(Encrypter.color_light);
            JScrollPane scrolltree = new JScrollPane(tree_view);
            scrolltree.setBackground(Encrypter.color_light);
            scrolltree.getVerticalScrollBar().setPreferredSize(new Dimension(0, 0));

            UIManager.put("Tree.textBackground", Encrypter.color_light);
            UIManager.put("Tree.selectionBackground", Encrypter.color_blue);
            UIManager.put("Tree.selectionBorderColor", Encrypter.color_blue);

            tree_view.updateUI();

            final String pass = String.valueOf(passf.getPassword());
            try {
                client.connect(adressf.getText());
                client.login(userf.getText(), pass);
                client.enterLocalPassiveMode();
                if (client.isConnected()) {
                    try {
                        FTPFile[] ftpFiles = client.listFiles();
                        for (FTPFile ftpFile : ftpFiles) {
                            files = new DefaultMutableTreeNode(ftpFile.getName());
                            top.add(files);
                            if (ftpFile.getType() == FTPFile.DIRECTORY_TYPE) {
                                FTPFile[] ftpFiles1 = client.listFiles(ftpFile.getName());
                                for (FTPFile ftpFile1 : ftpFiles1) {
                                    leaf = new DefaultMutableTreeNode(ftpFile1.getName());
                                    files.add(leaf);
                                }
                            }
                        }
                    } catch (IOException e1) {
                        Encrypter.printException(e1);
                    }
                    client.disconnect();
                } else {
                    status.setText("Failed connection!");
                }
            } catch (IOException e1) {
                Encrypter.printException(e1);
            } finally {
                try {
                    client.disconnect();
                } catch (IOException e1) {
                    Encrypter.printException(e1);
                }
            }

            tree.add(labeltree, BorderLayout.NORTH);
            tree.add(scrolltree, BorderLayout.CENTER);
            tree.add(refresh, BorderLayout.SOUTH);

            uploadFTP.addComponentListener(new ComponentListener() {

                public void componentMoved(ComponentEvent e) {
                    tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY());
                }

                public void componentShown(ComponentEvent e) {
                }

                public void componentResized(ComponentEvent e) {
                }

                public void componentHidden(ComponentEvent e) {
                }
            });

            uploadFTP.addWindowListener(new WindowListener() {
                public void windowActivated(WindowEvent e) {
                    tree.toFront();
                }

                public void windowOpened(WindowEvent e) {
                }

                public void windowIconified(WindowEvent e) {
                }

                public void windowDeiconified(WindowEvent e) {
                }

                public void windowDeactivated(WindowEvent e) {
                }

                public void windowClosing(WindowEvent e) {
                }

                public void windowClosed(WindowEvent e) {
                }
            });

            refresh.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    tree.dispose();
                    tree.setVisible(true);
                }
            });
        }
    });

}

From source file:org.tinymediamanager.ui.movies.dialogs.MovieEditorDialog.java

/**
 * Create the dialog.//from  w w  w  .  j a  va  2s .co  m
 * 
 * @param movie
 *          the movie
 * @param inQueue
 *          the in queue
 */
public MovieEditorDialog(Movie movie, boolean inQueue) {
    super(BUNDLE.getString("movie.edit"), "movieEditor"); //$NON-NLS-1$
    setBounds(5, 5, 950, 650);

    movieToEdit = movie;
    ids = MediaIdTable.convertIdMapToEventList(movieToEdit.getIds());
    for (MediaFile mf : movie.getMediaFiles()) {
        mediaFiles.add(new MediaFile(mf));
    }

    getContentPane().setLayout(new BorderLayout());
    {
        JPanel panelPath = new JPanel();
        getContentPane().add(panelPath, BorderLayout.NORTH);
        panelPath.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("15px"),
                        FormFactory.RELATED_GAP_ROWSPEC, }));

        JLabel lblMoviePathT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$
        panelPath.add(lblMoviePathT, "2, 2, left, top");

        lblMoviePath = new JLabel("");
        TmmFontHelper.changeFont(lblMoviePath, 1.166, Font.BOLD);
        panelPath.add(lblMoviePath, "5, 2, left, top");
    }

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.NORTH);
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    /**
     * DetailsPanel 1
     */
    {
        details1Panel.setBorder(new EmptyBorder(5, 5, 5, 5));
        details1Panel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC,
                ColumnSpec.decode("max(40dlu;default)"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"),
                FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                ColumnSpec.decode("25dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("24dlu"),
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow(2)"),
                FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("50px:grow"),
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("15dlu"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        RowSpec.decode("fill:50dlu:grow"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        RowSpec.decode("50px"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        RowSpec.decode("fill:default:grow"), }));

        {
            JLabel lblTitle = new JLabel(BUNDLE.getString("metatag.title")); //$NON-NLS-1$
            details1Panel.add(lblTitle, "2, 4, right, default");
        }
        {
            tfTitle = new JTextField();
            details1Panel.add(tfTitle, "4, 4, 15, 1, fill, default");
            tfTitle.setColumns(10);
        }
        {
            // JLabel lblPoster = new JLabel("");
            lblPoster = new ImageLabel();
            lblPoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); //$NON-NLS-1$
            lblPoster.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.POSTER,
                            movieList.getDefaultArtworkScrapers(), lblPoster, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblPoster.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            details1Panel.add(lblPoster, "22, 4, 3, 23, fill, fill");
        }
        {
            JLabel lblOriginalTitle = new JLabel(BUNDLE.getString("metatag.originaltitle")); //$NON-NLS-1$
            details1Panel.add(lblOriginalTitle, "2, 6, right, default");
        }
        {
            tfOriginalTitle = new JTextField();
            details1Panel.add(tfOriginalTitle, "4, 6, 15, 1, fill, top");
            tfOriginalTitle.setColumns(10);
        }
        {
            JLabel lblSorttitle = new JLabel(BUNDLE.getString("metatag.sorttitle")); //$NON-NLS-1$
            details1Panel.add(lblSorttitle, "2, 8, right, default");
        }
        {
            tfSorttitle = new JTextField();
            details1Panel.add(tfSorttitle, "4, 8, 15, 1, fill, default");
            tfSorttitle.setColumns(10);
        }
        {
            JLabel lblTagline = new JLabel(BUNDLE.getString("metatag.tagline")); //$NON-NLS-1$
            details1Panel.add(lblTagline, "2, 10, right, top");
        }
        {
            JScrollPane scrollPaneTagline = new JScrollPane();
            tpTagline = new JTextPane();
            scrollPaneTagline.setViewportView(tpTagline);
            details1Panel.add(scrollPaneTagline, "4, 10, 15, 1, fill, fill");
        }
        {
            JLabel lblYear = new JLabel(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
            details1Panel.add(lblYear, "2, 12, right, default");
        }
        {
            spYear = new YearSpinner();
            details1Panel.add(spYear, "4, 12, fill, top");
        }
        {
            JLabel lblRuntime = new JLabel(BUNDLE.getString("metatag.runtime")); //$NON-NLS-1$
            details1Panel.add(lblRuntime, "8, 12, right, default");
        }
        {
            spRuntime = new JSpinner();
            details1Panel.add(spRuntime, "10, 12, fill, default");
        }
        {
            JLabel lblMin = new JLabel(BUNDLE.getString("metatag.minutes")); //$NON-NLS-1$
            details1Panel.add(lblMin, "12, 12");
        }
        {
            JLabel lblRating = new JLabel(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$
            details1Panel.add(lblRating, "16, 12, right, default");
        }
        {
            spRating = new JSpinner();
            details1Panel.add(spRating, "18, 12");
        }

        spRating.setModel(new SpinnerNumberModel(movie.getRating(), 0.0, 10.0, 0.1));
        {
            JLabel lblReleaseDate = new JLabel(BUNDLE.getString("metatag.releasedate")); //$NON-NLS-1$
            details1Panel.add(lblReleaseDate, "2, 14, right, default");
        }
        {
            dpReleaseDate = new DatePicker(movie.getReleaseDate());
            details1Panel.add(dpReleaseDate, "4, 14");
        }
        {
            JLabel lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$
            details1Panel.add(lblCertification, "8, 14, right, default");
        }
        cbCertification = new JComboBox();
        details1Panel.add(cbCertification, "10, 14, 3, 1, fill, default");
        {
            JLabel lblTop = new JLabel(BUNDLE.getString("metatag.top250")); //$NON-NLS-1$
            details1Panel.add(lblTop, "16, 14, right, default");
        }
        {
            spTop250 = new JSpinner();
            details1Panel.add(spTop250, "18, 14");
        }
        spTop250.setValue(movie.getTop250());
        {
            JLabel lblIds = new JLabel("Ids");
            details1Panel.add(lblIds, "2, 16, right, bottom");
        }
        {
            JScrollPane scrollPaneIds = new JScrollPane();
            details1Panel.add(scrollPaneIds, "4, 16, 9, 5, fill, fill");
            {
                tableIds = new MediaIdTable(ids, ScraperType.MOVIE);
                scrollPaneIds.setViewportView(tableIds);
            }
        }
        {
            JButton btnAddId = new JButton("");
            btnAddId.setAction(new AddIdAction());
            btnAddId.setIcon(IconManager.LIST_ADD);
            btnAddId.setMargin(new Insets(2, 2, 2, 2));
            details1Panel.add(btnAddId, "2, 18, right, top");
        }
        {
            JButton btnRemoveId = new JButton("");
            btnRemoveId.setAction(new RemoveIdAction());
            btnRemoveId.setIcon(IconManager.LIST_REMOVE);
            btnRemoveId.setMargin(new Insets(2, 2, 2, 2));
            details1Panel.add(btnRemoveId, "2, 20, right, top");
        }
        {
            JLabel lblSpokenLanguages = new JLabel(BUNDLE.getString("metatag.spokenlanguages")); //$NON-NLS-1$
            details1Panel.add(lblSpokenLanguages, "2, 22, right, default");
        }
        {
            tfSpokenLanguages = new JTextField();
            details1Panel.add(tfSpokenLanguages, "4, 22, fill, default");
            tfSpokenLanguages.setColumns(10);
        }
        {
            JLabel lblCountry = new JLabel(BUNDLE.getString("metatag.country")); //$NON-NLS-1$
            details1Panel.add(lblCountry, "8, 22, right, default");
        }
        {
            tfCountry = new JTextField();
            details1Panel.add(tfCountry, "10, 22, 3, 1, fill, default");
            tfCountry.setColumns(10);
        }
        {
            JLabel lblMovieSet = new JLabel(BUNDLE.getString("metatag.movieset")); //$NON-NLS-1$
            details1Panel.add(lblMovieSet, "2, 24, right, default");
        }
        {
            cbMovieSet = new JComboBox();
            cbMovieSet.addItem("");
            details1Panel.add(cbMovieSet, "4, 24, 9, 1, fill, default");
        }
        {
            JLabel lblDateAdded = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$
            details1Panel.add(lblDateAdded, "2, 26, right, default");
        }
        {
            spDateAdded = new JSpinner(new SpinnerDateModel());
            // JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(spDateAdded,
            // "dd.MM.yyyy HH:mm:ss");
            // spDateAdded.setEditor(timeEditor);
            details1Panel.add(spDateAdded, "4, 26");
        }
        spDateAdded.setValue(movie.getDateAdded());
        JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$
        details1Panel.add(lblWatched, "8, 26, right, default");
        {
            cbWatched = new JCheckBox("");
            details1Panel.add(cbWatched, "10, 26");
        }
        cbWatched.setSelected(movie.isWatched());
        lblWatched.setLabelFor(cbWatched);
        {
            JLabel lblSourceT = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
            details1Panel.add(lblSourceT, "2, 28, right, default");
        }
        {
            cbSource = new JComboBox(MediaSource.values());
            details1Panel.add(cbSource, "4, 28, fill, default");
        }
        cbSource.setSelectedItem(movie.getMediaSource());
        {
            final JLabel lblEditionT = new JLabel(BUNDLE.getString("metatag.edition")); //$NON-NLS-1$
            details1Panel.add(lblEditionT, "8, 28, right, default");
        }
        {
            cbEdition = new JComboBox(MovieEdition.values());
            details1Panel.add(cbEdition, "10, 28, 3, 1, fill, default");
        }
        {
            JLabel lblVideod = new JLabel(BUNDLE.getString("metatag.3d")); //$NON-NLS-1$
            details1Panel.add(lblVideod, "16, 28, right, default");
        }
        {
            chckbxVideo3D = new JCheckBox("");
            details1Panel.add(chckbxVideo3D, "18, 28");
        }
        chckbxVideo3D.setSelected(movie.isVideoIn3D());
        {
            JLabel lblPlot = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$
            details1Panel.add(lblPlot, "2, 30, right, top");
        }
        {
            JScrollPane scrollPanePlot = new JScrollPane();
            details1Panel.add(scrollPanePlot, "4, 30, 15, 1, fill, fill");
            {
                tpPlot = new JTextPane();
                scrollPanePlot.setViewportView(tpPlot);
            }
        }
        {
            lblFanart = new ImageLabel();
            lblFanart.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); //$NON-NLS-1$
            lblFanart.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            lblFanart.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.FANART,
                            movieList.getDefaultArtworkScrapers(), lblFanart, extrathumbs, extrafanarts,
                            MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            details1Panel.add(lblFanart, "22, 30, 3, 5, fill, fill");
        }
        lblFanart.setImagePath(movie.getArtworkFilename(MediaFileType.FANART));
        {
            JLabel lblDirector = new JLabel(BUNDLE.getString("metatag.director")); //$NON-NLS-1$
            details1Panel.add(lblDirector, "2, 32, right, default");
        }
        {
            tfDirector = new JTextField();
            details1Panel.add(tfDirector, "4, 32, 15, 1, fill, top");
            tfDirector.setColumns(10);
        }
        {
            JLabel lblWriter = new JLabel(BUNDLE.getString("metatag.writer")); //$NON-NLS-1$
            details1Panel.add(lblWriter, "2, 34, right, default");
        }
        {
            tfWriter = new JTextField();
            details1Panel.add(tfWriter, "4, 34, 15, 1, fill, top");
            tfWriter.setColumns(10);
        }
        {
            JLabel lblCompany = new JLabel(BUNDLE.getString("metatag.production")); //$NON-NLS-1$
            details1Panel.add(lblCompany, "2, 36, right, top");
        }
        {
            JScrollPane scrollPaneProduction = new JScrollPane();
            details1Panel.add(scrollPaneProduction, "4, 36, 15, 1, fill, fill");
            tfProductionCompanies = new JTextPane();
            scrollPaneProduction.setViewportView(tfProductionCompanies);
        }
        tabbedPane.addTab(BUNDLE.getString("metatag.details"), details1Panel); //$NON-NLS-1$
    }

    /**
     * DetailsPanel 2
     */
    {
        tabbedPane.addTab(BUNDLE.getString("metatag.details2"), details2Panel); //$NON-NLS-1$
        details2Panel.setBorder(new EmptyBorder(5, 5, 5, 5));
        details2Panel.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(40dlu;default)"),
                        FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"),
                        FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("100px:grow"),
                        FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:default"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow(2)"), }));
        {
            JLabel lblActors = new JLabel(BUNDLE.getString("metatag.actors")); //$NON-NLS-1$
            details2Panel.add(lblActors, "2, 2, right, default");
        }
        {
            JScrollPane scrollPane = new JScrollPane();
            details2Panel.add(scrollPane, "4, 2, 1, 11");
            tableActors = new JTable();
            tableActors.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            scrollPane.setViewportView(tableActors);
        }
        {
            JLabel lblProducers = new JLabel(BUNDLE.getString("metatag.producers")); //$NON-NLS-1$
            details2Panel.add(lblProducers, "6, 2, right, default");
        }
        {
            JScrollPane scrollPane = new JScrollPane();
            details2Panel.add(scrollPane, "8, 2, 1, 11");
            tableProducers = new JTable();
            tableProducers.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            scrollPane.setViewportView(tableProducers);
        }
        {
            JButton btnAddActor = new JButton(BUNDLE.getString("cast.actor.add")); //$NON-NLS-1$
            btnAddActor.setMargin(new Insets(2, 2, 2, 2));
            btnAddActor.setAction(new AddActorAction());
            btnAddActor.setIcon(IconManager.LIST_ADD);
            details2Panel.add(btnAddActor, "2, 4, right, top");
        }
        {
            JButton btnAddProducer = new JButton((String) null);
            btnAddProducer.setMargin(new Insets(2, 2, 2, 2));
            btnAddProducer.setAction(new AddProducerAction());
            btnAddProducer.setIcon(IconManager.LIST_ADD);
            details2Panel.add(btnAddProducer, "6, 4, right, top");
        }
        {
            JButton btnRemoveActor = new JButton(BUNDLE.getString("cast.actor.remove")); //$NON-NLS-1$
            btnRemoveActor.setMargin(new Insets(2, 2, 2, 2));
            btnRemoveActor.setAction(new RemoveActorAction());
            btnRemoveActor.setIcon(IconManager.LIST_REMOVE);
            details2Panel.add(btnRemoveActor, "2,6, right, top");
        }
        {
            JButton btnRemoveProducer = new JButton((String) null);
            btnRemoveProducer.setMargin(new Insets(2, 2, 2, 2));
            btnRemoveProducer.setAction(new RemoveProducerAction());
            btnRemoveProducer.setIcon(IconManager.LIST_REMOVE);
            details2Panel.add(btnRemoveProducer, "6, 6, right, top");
        }
        {
            JButton btnMoveActorUp = new JButton((String) null);
            btnMoveActorUp.setMargin(new Insets(2, 2, 2, 2));
            btnMoveActorUp.setAction(new MoveActorUpAction());
            btnMoveActorUp.setIcon(IconManager.ARROW_UP);
            details2Panel.add(btnMoveActorUp, "2, 8, right, top");
        }
        {
            JButton btnMoveProducerUp = new JButton((String) null);
            btnMoveProducerUp.setMargin(new Insets(2, 2, 2, 2));
            btnMoveProducerUp.setAction(new MoveProducerUpAction());
            btnMoveProducerUp.setIcon(IconManager.ARROW_UP);
            details2Panel.add(btnMoveProducerUp, "6, 8, right, top");
        }
        {
            JButton btnMoveActorDown = new JButton((String) null);
            btnMoveActorDown.setMargin(new Insets(2, 2, 2, 2));
            btnMoveActorDown.setAction(new MoveActorDownAction());
            btnMoveActorDown.setIcon(IconManager.ARROW_DOWN);
            details2Panel.add(btnMoveActorDown, "2, 10, right, top");
        }
        {
            JButton btnMoveProducerDown = new JButton((String) null);
            btnMoveProducerDown.setMargin(new Insets(2, 2, 2, 2));
            btnMoveProducerDown.setAction(new MoveProducerDownAction());
            btnMoveProducerDown.setIcon(IconManager.ARROW_DOWN);
            details2Panel.add(btnMoveProducerDown, "6, 10, right, top");
        }
        {
            JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$
            details2Panel.add(lblGenres, "2, 14, right, default");
        }
        {
            JScrollPane scrollPaneGenres = new JScrollPane();
            details2Panel.add(scrollPaneGenres, "4, 14, 1, 5");
            {
                listGenres = new JList();
                scrollPaneGenres.setViewportView(listGenres);
            }
        }
        {
            JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$
            details2Panel.add(lblTags, "6, 14, right, default");
        }
        {
            JScrollPane scrollPaneTags = new JScrollPane();
            details2Panel.add(scrollPaneTags, "8, 14, 1, 5");
            listTags = new JList();
            scrollPaneTags.setViewportView(listTags);
        }
        {
            JButton btnAddGenre = new JButton("");
            btnAddGenre.setAction(new AddGenreAction());
            btnAddGenre.setIcon(IconManager.LIST_ADD);
            btnAddGenre.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnAddGenre, "2, 16, right, top");
        }
        {
            JButton btnAddTag = new JButton("");
            btnAddTag.setAction(new AddTagAction());
            btnAddTag.setIcon(IconManager.LIST_ADD);
            btnAddTag.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnAddTag, "6, 16, right, top");
        }

        {
            JButton btnRemoveGenre = new JButton("");
            btnRemoveGenre.setAction(new RemoveGenreAction());
            btnRemoveGenre.setMargin(new Insets(2, 2, 2, 2));
            btnRemoveGenre.setIcon(IconManager.LIST_REMOVE);
            details2Panel.add(btnRemoveGenre, "2, 18, right, top");
        }
        {
            JButton btnRemoveTag = new JButton("");
            btnRemoveTag.setAction(new RemoveTagAction());
            btnRemoveTag.setIcon(IconManager.LIST_REMOVE);
            btnRemoveTag.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnRemoveTag, "6, 18, right, top");
        }
        {
            cbGenres = new AutocompleteComboBox(MediaGenres.values());
            details2Panel.add(cbGenres, "4, 20");
        }
        {
            cbTags = new AutocompleteComboBox(movieList.getTagsInMovies());
            details2Panel.add(cbTags, "8, 20");
        }

        {
            JLabel lblTrailer = new JLabel(BUNDLE.getString("metatag.trailer")); //$NON-NLS-1$
            details2Panel.add(lblTrailer, "2, 22, right, default");
        }
        {
            JScrollPane scrollPaneTrailer = new JScrollPane();
            details2Panel.add(scrollPaneTrailer, "4, 22, 5, 5");
            tableTrailer = new JTable();
            tableTrailer.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            scrollPaneTrailer.setViewportView(tableTrailer);
        }
        {
            JButton btnAddTrailer = new JButton("");
            btnAddTrailer.setAction(new AddTrailerAction());
            btnAddTrailer.setIcon(IconManager.LIST_ADD);
            btnAddTrailer.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnAddTrailer, "2, 24, right, top");
        }
        {
            JButton btnRemoveTrailer = new JButton("");
            btnRemoveTrailer.setAction(new RemoveTrailerAction());
            btnRemoveTrailer.setIcon(IconManager.LIST_REMOVE);
            btnRemoveTrailer.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnRemoveTrailer, "2, 26, right, top");
        }
    }

    /**
     * extra artwork pane
     */
    {
        JPanel artworkPanel = new JPanel();
        tabbedPane.addTab(BUNDLE.getString("metatag.extraartwork"), null, artworkPanel, null); //$NON-NLS-1$
        artworkPanel.setLayout(new FormLayout(
                new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150px:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("50px:grow(2)"),
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("50px:grow(2)"), FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("200px:grow(2)"), FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("default:grow"), }));
        {
            JLabel lblLogoT = new JLabel(BUNDLE.getString("mediafiletype.logo")); //$NON-NLS-1$
            artworkPanel.add(lblLogoT, "2, 2");
        }
        {
            lblLogo = new ImageLabel();
            lblLogo.setAlternativeText(BUNDLE.getString("image.notfound.logo")); //$NON-NLS-1$
            lblLogo.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.LOGO,
                            movieList.getDefaultArtworkScrapers(), lblLogo, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblLogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblLogo, "2, 4, fill, fill");
        }
        {
            final JLabel lblClearlogoT = new JLabel(BUNDLE.getString("mediafiletype.clearlogo")); //$NON-NLS-1$
            artworkPanel.add(lblClearlogoT, "4, 2");
        }
        {
            lblClearlogo = new ImageLabel();
            lblClearlogo.setAlternativeText(BUNDLE.getString("image.notfound.clearlogo")); //$NON-NLS-1$
            lblClearlogo.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(),
                            ImageType.CLEARLOGO, movieList.getDefaultArtworkScrapers(), lblClearlogo, null,
                            null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblClearlogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblClearlogo, "4, 4, fill, fill");
        }
        {
            JLabel lblBannerT = new JLabel(BUNDLE.getString("mediafiletype.banner")); //$NON-NLS-1$
            artworkPanel.add(lblBannerT, "2, 6");
        }
        {
            lblBanner = new ImageLabel();
            lblBanner.setAlternativeText(BUNDLE.getString("image.notfound.banner")); //$NON-NLS-1$
            lblBanner.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.BANNER,
                            movieList.getDefaultArtworkScrapers(), lblBanner, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblBanner.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblBanner, "2, 8, 3, 1, fill, fill");
        }

        {
            JLabel lblClearartT = new JLabel("ClearArt");
            artworkPanel.add(lblClearartT, "2, 10");
        }
        {
            lblClearart = new ImageLabel();
            lblClearart.setAlternativeText(BUNDLE.getString("image.notfound.clearart")); //$NON-NLS-1$
            lblClearart.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.CLEARART,
                            movieList.getDefaultArtworkScrapers(), lblClearart, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblClearart.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblClearart, "2, 12, fill, fill");
        }
        {
            JLabel lblThumbT = new JLabel("Thumb");
            artworkPanel.add(lblThumbT, "4, 10");
        }
        {
            lblThumb = new ImageLabel();
            lblThumb.setAlternativeText(BUNDLE.getString("image.notfound.thumb")); //$NON-NLS-1$
            lblThumb.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.THUMB,
                            movieList.getDefaultArtworkScrapers(), lblThumb, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblThumb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblThumb, "4, 12, fill, fill");
        }
        {
            JLabel lblDiscT = new JLabel("Disc");
            artworkPanel.add(lblDiscT, "6, 10");
        }
        {
            lblDisc = new ImageLabel();
            lblDisc.setAlternativeText(BUNDLE.getString("image.notfound.disc")); //$NON-NLS-1$
            lblDisc.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.DISC,
                            movieList.getDefaultArtworkScrapers(), lblDisc, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblDisc.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblDisc, "6, 12, fill, fill");
        }
    }

    /**
     * Media Files
     */
    {
        mediaFilesPanel = new MediaFileEditorPanel(mediaFiles);
        tabbedPane.addTab(BUNDLE.getString("metatag.mediafiles"), null, mediaFilesPanel, null); //$NON-NLS-1$
    }

    /**
     * Button pane
     */
    {
        JPanel bottomPane = new JPanel();
        getContentPane().add(bottomPane, BorderLayout.SOUTH);
        bottomPane.setLayout(new FormLayout(
                new ColumnSpec[] { ColumnSpec.decode("371px:grow"), FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.LINE_GAP_ROWSPEC, }));

        JPanel buttonPane = new JPanel();
        bottomPane.add(buttonPane, "2, 2, left, top");
        EqualsLayout layout = new EqualsLayout(5);
        layout.setMinWidth(100);
        buttonPane.setLayout(layout);
        {
            JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$
            buttonPane.add(okButton, "2, 1, fill, top");
            okButton.setAction(new ChangeMovieAction());
            okButton.setActionCommand("OK");
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$
            buttonPane.add(cancelButton, "4, 1, fill, top");
            cancelButton.setAction(new DiscardAction());
            cancelButton.setActionCommand("Cancel");
        }
        if (inQueue) {
            JButton btnAbort = new JButton(BUNDLE.getString("Button.abortqueue")); //$NON-NLS-1$
            btnAbort.setAction(new AbortQueueAction());
            buttonPane.add(btnAbort, "6, 1, fill, top");
        }

    }
    initDataBindings();

    {
        int year = 0;
        try {
            year = Integer.parseInt(movieToEdit.getYear());
        } catch (Exception ignored) {
        }

        SimpleDateFormat dateFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.MEDIUM);

        for (Certification cert : Certification
                .getCertificationsforCountry(MovieModuleManager.MOVIE_SETTINGS.getCertificationCountry())) {
            cbCertification.addItem(cert);
        }

        tfTitle.setText(movieToEdit.getTitle());
        tfOriginalTitle.setText(movieToEdit.getOriginalTitle());
        tfSorttitle.setText(movieToEdit.getSortTitle());
        tpTagline.setText(movieToEdit.getTagline());
        tpPlot.setText(movieToEdit.getPlot());
        tpPlot.setCaretPosition(0);
        tfDirector.setText(movieToEdit.getDirector());
        tfWriter.setText(movieToEdit.getWriter());
        lblPoster.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.POSTER));
        tfProductionCompanies.setText(movieToEdit.getProductionCompany());
        spRuntime.setValue(movieToEdit.getRuntime());
        cbEdition.setSelectedItem(movieToEdit.getEdition());

        tfSpokenLanguages.setText(movieToEdit.getSpokenLanguages());
        tfCountry.setText(movieToEdit.getCountry());
        spYear.setValue(year);
        cbCertification.setSelectedItem(movieToEdit.getCertification());

        lblMoviePath.setText(movieToEdit.getPath());
        lblLogo.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.LOGO));
        lblClearlogo.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.CLEARLOGO));
        lblClearart.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.CLEARART));
        lblThumb.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.THUMB));
        lblDisc.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.DISCART));
        lblBanner.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.BANNER));

        for (MovieActor origCast : movieToEdit.getActors()) {
            MovieActor actor = new MovieActor();
            actor.setName(origCast.getName());
            actor.setCharacter(origCast.getCharacter());
            actor.setThumbUrl(origCast.getThumbUrl());
            cast.add(actor);
        }

        for (MovieProducer origProducer : movieToEdit.getProducers()) {
            MovieProducer producer = new MovieProducer();
            producer.setName(origProducer.getName());
            producer.setRole(origProducer.getRole());
            producer.setThumbUrl(origProducer.getThumbUrl());
            producers.add(producer);
        }

        for (MediaGenres genre : movieToEdit.getGenres()) {
            genres.add(genre);
        }

        for (MovieTrailer trailer : movieToEdit.getTrailer()) {
            trailers.add(trailer);
        }

        for (String tag : movieToEdit.getTags()) {
            if (StringUtils.isNotBlank(tag)) {
                tags.add(tag);
            }
        }

        extrathumbs.addAll(movieToEdit.getExtraThumbs());
        extrafanarts.addAll(movieToEdit.getExtraFanarts());
        for (MovieSet movieSet : movieList.getSortedMovieSetList()) {
            cbMovieSet.addItem(movieSet);
            if (movieToEdit.getMovieSet() == movieSet) {
                cbMovieSet.setSelectedItem(movieSet);
            }
        }
    }
    // adjust columnn titles - we have to do it this way - thx to windowbuilder pro
    tableActors.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableActors.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$
    tableProducers.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableProducers.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$

    tableTrailer.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.nfo")); //$NON-NLS-1$
    tableTrailer.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableTrailer.getColumnModel().getColumn(2).setHeaderValue(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
    tableTrailer.getColumnModel().getColumn(3).setHeaderValue(BUNDLE.getString("metatag.quality")); //$NON-NLS-1$
    tableTrailer.getColumnModel().getColumn(4).setHeaderValue(BUNDLE.getString("metatag.url")); //$NON-NLS-1$

    // adjust table columns
    tableTrailer.getColumnModel().getColumn(0).setMaxWidth(55);

    // implement listener to simulate button group
    tableTrailer.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            // click on the checkbox
            if (arg0.getColumn() == 0) {
                int row = arg0.getFirstRow();
                MovieTrailer changedTrailer = trailers.get(row);
                // if flag inNFO was changed, change all other trailers flags
                if (changedTrailer.getInNfo()) {
                    for (MovieTrailer trailer : trailers) {
                        if (trailer != changedTrailer) {
                            trailer.setInNfo(Boolean.FALSE);
                        }
                    }
                }
            }
        }
    });
}

From source file:net.sourceforge.squirrel_sql.client.preferences.UpdatePreferencesPanel.java

private JPanel createUpdateSitePanel() {
    JPanel pnl = new JPanel(new GridBagLayout());
    pnl.setBorder(BorderFactory.createTitledBorder(i18n.UPDATE_SITE_BORDER_LABEL));

    ItemListener urlUpdateItemListener = new UrlItemListener();
    DocumentListener urlDocumentListener = new UrlDocumentListener();
    final GridBagConstraints gbc = new GridBagConstraints();

    setSeparatorConstraints(gbc, 0);//from   www. ja  v  a 2 s.c o  m
    gbc.gridwidth = 1;
    gbc.weightx = 0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    siteTypeLabel = new JLabel(i18n.SITE_TYPE_LABEL, JLabel.RIGHT);
    pnl.add(siteTypeLabel, gbc);

    // Site type

    setSeparatorConstraints(gbc, 0);
    gbc.gridx = 1;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    pnl.add(getSiteTypePanel(), gbc);

    setSeparatorConstraints(gbc, 1);
    pnl.add(getSep(), gbc);

    // Update server name

    setLabelConstraints(gbc, 2);
    _serverLabel = new JLabel(i18n.SERVER, SwingConstants.RIGHT);
    pnl.add(_serverLabel, gbc);

    setFieldConstraints(gbc, 2);
    _updateServerName.getDocument().addDocumentListener(urlDocumentListener);
    pnl.add(_updateServerName, gbc);

    // Update server port

    setLabelConstraints(gbc, 3);
    _portLabel = new JLabel(i18n.PORT, SwingConstants.RIGHT);
    pnl.add(_portLabel, gbc);

    setFieldConstraints(gbc, 3);
    _updateServerPort.getDocument().addDocumentListener(urlDocumentListener);
    pnl.add(_updateServerPort, gbc);

    // Path to release.xml

    setLabelConstraints(gbc, 4);
    _pathLabel = new JLabel(i18n.PATH, SwingConstants.RIGHT);
    pnl.add(_pathLabel, gbc);

    setFieldConstraints(gbc, 4);
    _updateServerPath.getDocument().addDocumentListener(urlDocumentListener);
    pnl.add(_updateServerPath, gbc);

    // Channnel combo-box

    setLabelConstraints(gbc, 5);
    _channelLabel = new JLabel(i18n.CHANNEL, SwingConstants.RIGHT);
    pnl.add(_channelLabel, gbc);

    setFieldConstraints(gbc, 5);
    gbc.fill = GridBagConstraints.NONE;
    _updateServerChannel.addItemListener(urlUpdateItemListener);
    pnl.add(_updateServerChannel, gbc);

    // URL text field

    setLabelConstraints(gbc, 6);
    _urlLabel = new JLabel(i18n.URL, SwingConstants.RIGHT);
    pnl.add(_urlLabel, gbc);

    setFieldConstraints(gbc, 6);
    updateUrl();
    pnl.add(_updateUrl, gbc);

    setFieldConstraints(gbc, 7);
    JLabel lblProxy = new JLabel(s_stringMgr.getString("UpdatePreferencesPanel.proxyHintHtml"));
    lblProxy.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lblProxy.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            _prefrenceTabActvivationListener.activateTabForClass(ProxyPreferenceTabComponent.class);
        }
    });
    pnl.add(lblProxy, gbc);

    // Test Connection Button Panel (Both the button and the status label

    setFieldConstraints(gbc, 8);

    Box buttonBox = Box.createHorizontalBox();
    buttonBox.add(_testConnectionButton);
    buttonBox.add(Box.createHorizontalStrut(20));
    buttonBox.add(_testConnectionStatusLabel);
    _testConnectionButton.addActionListener(new TestConnectionButtonListener());
    pnl.add(buttonBox, gbc);

    // Separator

    setSeparatorConstraints(gbc, 9);
    pnl.add(getSep(), gbc);

    // Local update directory

    setLabelConstraints(gbc, 10);
    _localPathLabel = new JLabel(i18n.LOCAL_PATH, SwingConstants.RIGHT);
    pnl.add(_localPathLabel, gbc);

    setFieldConstraints(gbc, 10);
    pnl.add(_localPath, gbc);
    return pnl;
}

From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java

public MindMapPanel(final MindMapPanelController controller) {
    super(null);//w ww  .ja va  2s  .  c o  m
    this.textEditorPanel.setLayout(new BorderLayout(0, 0));
    this.controller = controller;

    this.config = new MindMapPanelConfig(controller.provideConfigForMindMapPanel(this), false);

    this.textEditor.setMargin(new Insets(5, 5, 5, 5));
    this.textEditor.setBorder(BorderFactory.createEtchedBorder());
    this.textEditor.setTabSize(4);
    this.textEditor.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(final KeyEvent e) {
            switch (e.getKeyCode()) {
            case KeyEvent.VK_ENTER: {
                e.consume();
            }
                break;
            case KeyEvent.VK_TAB: {
                if ((e.getModifiers() & ALL_SUPPORTED_MODIFIERS) == 0) {
                    e.consume();
                    final Topic edited = elementUnderEdit.getModel();
                    final int[] topicPosition = edited.getPositionPath();
                    endEdit(true);
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            final Topic theTopic = model.findForPositionPath(topicPosition);
                            if (theTopic != null) {
                                makeNewChildAndStartEdit(theTopic, null);
                            }
                        }
                    });
                }
            }
                break;
            default:
                break;
            }
        }

        @Override
        public void keyTyped(final KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                if ((e.getModifiers() & ALL_SUPPORTED_MODIFIERS) == 0) {
                    e.consume();
                    endEdit(true);
                } else {
                    e.consume();
                    textEditor.insert("\n", textEditor.getCaretPosition()); //NOI18N
                }
            }
        }

        @Override
        public void keyReleased(final KeyEvent e) {
            if (config.isKeyEvent(MindMapPanelConfig.KEY_CANCEL_EDIT, e)) {
                e.consume();
                final Topic edited = elementUnderEdit == null ? null : elementUnderEdit.getModel();
                endEdit(false);
                if (edited != null && edited.canBeLost()) {
                    deleteTopics(edited);
                    if (pathToPrevTopicBeforeEdit != null) {
                        final int[] path = pathToPrevTopicBeforeEdit;
                        pathToPrevTopicBeforeEdit = null;
                        SwingUtilities.invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                final Topic topic = model.findForPositionPath(path);
                                if (topic != null) {
                                    select(topic, false);
                                }
                            }
                        });
                    }
                }
            }
        }
    });

    this.textEditor.getDocument().addDocumentListener(new DocumentListener() {

        private void updateEditorPanelSize(final Dimension newSize) {
            final Dimension editorPanelMinSize = textEditorPanel.getMinimumSize();
            final Dimension newDimension = new Dimension(Math.max(editorPanelMinSize.width, newSize.width),
                    Math.max(editorPanelMinSize.height, newSize.height));
            textEditorPanel.setSize(newDimension);
            textEditorPanel.repaint();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            updateEditorPanelSize(textEditor.getPreferredSize());
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            updateEditorPanelSize(textEditor.getPreferredSize());
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateEditorPanelSize(textEditor.getPreferredSize());
        }
    });
    this.textEditorPanel.add(this.textEditor, BorderLayout.CENTER);

    super.setOpaque(true);

    final KeyAdapter keyAdapter = new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            if (config.isKeyEvent(MindMapPanelConfig.KEY_ADD_CHILD_AND_START_EDIT, e)) {
                if (!selectedTopics.isEmpty()) {
                    makeNewChildAndStartEdit(selectedTopics.get(0), null);
                }
            } else if (config.isKeyEvent(MindMapPanelConfig.KEY_ADD_SIBLING_AND_START_EDIT, e)) {
                if (!hasActiveEditor() && hasOnlyTopicSelected()) {
                    final Topic baseTopic = selectedTopics.get(0);
                    makeNewChildAndStartEdit(baseTopic.getParent() == null ? baseTopic : baseTopic.getParent(),
                            baseTopic);
                }
            } else if (config.isKeyEvent(MindMapPanelConfig.KEY_FOCUS_ROOT_OR_START_EDIT, e)) {
                if (!hasSelectedTopics()) {
                    select(getModel().getRoot(), false);
                } else if (hasOnlyTopicSelected()) {
                    startEdit((AbstractElement) selectedTopics.get(0).getPayload());
                }
            }
        }

        @Override
        public void keyReleased(final KeyEvent e) {
            if (config.isKeyEvent(MindMapPanelConfig.KEY_DELETE_TOPIC, e)) {
                e.consume();
                deleteSelectedTopics();
            } else if (config.isKeyEventDetected(e, MindMapPanelConfig.KEY_FOCUS_MOVE_LEFT,
                    MindMapPanelConfig.KEY_FOCUS_MOVE_RIGHT, MindMapPanelConfig.KEY_FOCUS_MOVE_UP,
                    MindMapPanelConfig.KEY_FOCUS_MOVE_DOWN)) {
                e.consume();
                processMoveFocusByKey(e);
            }
        }
    };

    this.setFocusTraversalKeysEnabled(false);

    final MindMapPanel theInstance = this;

    final MouseAdapter adapter = new MouseAdapter() {

        @Override
        public void mouseEntered(final MouseEvent e) {
            setCursor(Cursor.getDefaultCursor());
        }

        @Override
        public void mouseMoved(final MouseEvent e) {
            if (!controller.isMouseMoveProcessingAllowed(theInstance)) {
                return;
            }
            final AbstractElement element = findTopicUnderPoint(e.getPoint());
            if (element == null) {
                setCursor(Cursor.getDefaultCursor());
                setToolTipText(null);
            } else {
                final ElementPart part = element.findPartForPoint(e.getPoint());
                setCursor(part == ElementPart.ICONS || part == ElementPart.COLLAPSATOR
                        ? Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)
                        : Cursor.getDefaultCursor());
                if (part == ElementPart.ICONS) {
                    final Extra<?> extra = element.getIconBlock().findExtraForPoint(
                            e.getPoint().getX() - element.getBounds().getX(),
                            e.getPoint().getY() - element.getBounds().getY());
                    if (extra != null) {
                        setToolTipText(makeHtmlTooltipForExtra(extra));
                    } else {
                        setToolTipText(null);
                    }
                } else {
                    setToolTipText(null);
                }
            }
        }

        @Override
        public void mousePressed(final MouseEvent e) {
            if (!controller.isMouseClickProcessingAllowed(theInstance)) {
                return;
            }
            try {
                if (e.isPopupTrigger()) {
                    mouseDragSelection = null;
                    MindMap theMap = model;
                    AbstractElement element = null;
                    if (theMap != null) {
                        element = findTopicUnderPoint(e.getPoint());
                    }
                    processPopUp(e.getPoint(), element);
                    e.consume();
                } else {
                    endEdit(elementUnderEdit != null);
                    mouseDragSelection = null;
                }
            } catch (Exception ex) {
                LOGGER.error("Error during mousePressed()", ex);
            }
        }

        @Override
        public void mouseReleased(final MouseEvent e) {
            if (!controller.isMouseClickProcessingAllowed(theInstance)) {
                return;
            }
            try {
                if (draggedElement != null) {
                    draggedElement.updatePosition(e.getPoint());
                    if (endDragOfElement(draggedElement, destinationElement)) {
                        updateView(true);
                    }
                } else if (mouseDragSelection != null) {
                    final List<Topic> covered = mouseDragSelection.getAllSelectedElements(model);
                    if (e.isShiftDown()) {
                        for (final Topic m : covered) {
                            select(m, false);
                        }
                    } else if (e.isControlDown()) {
                        for (final Topic m : covered) {
                            select(m, true);
                        }
                    } else {
                        removeAllSelection();
                        for (final Topic m : covered) {
                            select(m, false);
                        }
                    }
                } else if (e.isPopupTrigger()) {
                    mouseDragSelection = null;
                    MindMap theMap = model;
                    AbstractElement element = null;
                    if (theMap != null) {
                        element = findTopicUnderPoint(e.getPoint());
                    }
                    processPopUp(e.getPoint(), element);
                    e.consume();
                }
            } catch (Exception ex) {
                LOGGER.error("Error during mouseReleased()", ex);
            } finally {
                mouseDragSelection = null;
                draggedElement = null;
                destinationElement = null;
                repaint();
            }
        }

        @Override
        public void mouseDragged(final MouseEvent e) {
            if (!controller.isMouseMoveProcessingAllowed(theInstance)) {
                return;
            }
            scrollRectToVisible(new Rectangle(e.getX(), e.getY(), 1, 1));

            if (!popupMenuActive) {
                if (draggedElement == null && mouseDragSelection == null) {
                    final AbstractElement elementUnderMouse = findTopicUnderPoint(e.getPoint());
                    if (elementUnderMouse == null) {
                        MindMap theMap = model;
                        if (theMap != null) {
                            final AbstractElement element = findTopicUnderPoint(e.getPoint());
                            if (controller.isSelectionAllowed(theInstance) && element == null) {
                                mouseDragSelection = new MouseSelectedArea(e.getPoint());
                            }
                        }
                    } else if (controller.isElementDragAllowed(theInstance)) {
                        if (elementUnderMouse.isMoveable()) {
                            selectedTopics.clear();

                            final Point mouseOffset = new Point(
                                    (int) Math
                                            .round(e.getPoint().getX() - elementUnderMouse.getBounds().getX()),
                                    (int) Math
                                            .round(e.getPoint().getY() - elementUnderMouse.getBounds().getY()));
                            draggedElement = new DraggedElement(elementUnderMouse, config, mouseOffset,
                                    e.isControlDown() || e.isMetaDown() ? DraggedElement.Modifier.MAKE_JUMP
                                            : DraggedElement.Modifier.NONE);
                            draggedElement.updatePosition(e.getPoint());
                            findDestinationElementForDragged();
                        } else {
                            draggedElement = null;
                        }
                        repaint();
                    }
                } else if (mouseDragSelection != null) {
                    if (controller.isSelectionAllowed(theInstance)) {
                        mouseDragSelection.update(e);
                    } else {
                        mouseDragSelection = null;
                    }
                    repaint();
                } else if (draggedElement != null) {
                    if (controller.isElementDragAllowed(theInstance)) {
                        draggedElement.updatePosition(e.getPoint());
                        findDestinationElementForDragged();
                    } else {
                        draggedElement = null;
                    }
                    repaint();
                }
            } else {
                mouseDragSelection = null;
            }
        }

        @Override
        public void mouseWheelMoved(final MouseWheelEvent e) {
            if (controller.isMouseWheelProcessingAllowed(theInstance)) {
                mouseDragSelection = null;
                draggedElement = null;

                final MindMapPanelConfig theConfig = config;

                if (!e.isConsumed() && (theConfig != null
                        && ((e.getModifiers() & theConfig.getScaleModifiers()) == theConfig
                                .getScaleModifiers()))) {
                    endEdit(elementUnderEdit != null);

                    setScale(
                            Math.max(0.3d, Math.min(getScale() + (SCALE_STEP * -e.getWheelRotation()), 10.0d)));

                    updateView(false);
                    e.consume();
                } else {
                    sendToParent(e);
                }
            }
        }

        @Override
        public void mouseClicked(final MouseEvent e) {
            if (!controller.isMouseClickProcessingAllowed(theInstance)) {
                return;
            }
            mouseDragSelection = null;
            draggedElement = null;

            MindMap theMap = model;
            AbstractElement element = null;
            if (theMap != null) {
                element = findTopicUnderPoint(e.getPoint());
            }

            if (element != null) {
                final ElementPart part = element.findPartForPoint(e.getPoint());
                if (part == ElementPart.COLLAPSATOR) {
                    removeAllSelection();

                    if (element.isCollapsed()) {
                        ((AbstractCollapsableElement) element).setCollapse(false);
                        if ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
                            ((AbstractCollapsableElement) element).collapseAllFirstLevelChildren();
                        }
                    } else {
                        ((AbstractCollapsableElement) element).setCollapse(true);
                    }
                    invalidate();
                    fireNotificationMindMapChanged();
                    repaint();
                } else if (part != ElementPart.ICONS && e.getClickCount() > 1) {
                    startEdit(element);
                } else if (part == ElementPart.ICONS) {
                    final Extra<?> extra = element.getIconBlock().findExtraForPoint(
                            e.getPoint().getX() - element.getBounds().getX(),
                            e.getPoint().getY() - element.getBounds().getY());
                    if (extra != null) {
                        fireNotificationClickOnExtra(element.getModel(), e.getClickCount(), extra);
                    }
                } else {
                    if (!e.isControlDown()) {
                        // only
                        removeAllSelection();
                        select(element.getModel(), false);
                    } else // group
                    if (selectedTopics.isEmpty()) {
                        select(element.getModel(), false);
                    } else {
                        select(element.getModel(), true);
                    }
                }
            }
        }
    };

    addMouseWheelListener(adapter);
    addMouseListener(adapter);
    addMouseMotionListener(adapter);
    addKeyListener(keyAdapter);

    this.textEditorPanel.setVisible(false);
    this.add(this.textEditorPanel);
}

From source file:org.tinymediamanager.ui.tvshows.dialogs.TvShowEpisodeEditorDialog.java

/**
 * Instantiates a new tv show episode scrape dialog.
 * //from   ww w .  ja  v a  2 s  .c o  m
 * @param episode
 *          the episode
 * @param inQueue
 *          the in queue
 */
public TvShowEpisodeEditorDialog(TvShowEpisode episode, boolean inQueue) {
    super(BUNDLE.getString("tvshowepisode.scrape"), "tvShowEpisodeScraper"); //$NON-NLS-1$
    setBounds(5, 5, 964, 632);

    for (MediaFile mf : episode.getMediaFiles()) {
        mediaFiles.add(new MediaFile(mf));
    }

    this.episodeToEdit = episode;
    getContentPane().setLayout(new BorderLayout());

    {
        JPanel panelFilename = new JPanel();
        getContentPane().add(panelFilename, BorderLayout.NORTH);
        panelFilename.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("15px"),
                        FormFactory.RELATED_GAP_ROWSPEC, }));

        JLabel lblFilenameT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$
        panelFilename.add(lblFilenameT, "2, 2, left, top");

        lblFilename = new JLabel("");
        TmmFontHelper.changeFont(lblFilename, 1.166, Font.BOLD);
        panelFilename.add(lblFilename, "5, 2, left, top");
    }

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.NORTH);
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    /**
     * DetailsPanel
     */
    {
        JPanel detailsPanel = new JPanel();
        tabbedPane.addTab(BUNDLE.getString("metatag.details"), detailsPanel); //$NON-NLS-1$
        detailsPanel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("40dlu:grow"),
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("20dlu"),
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("30dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"),
                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("35dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, }));

        JLabel lblTitle = new JLabel(BUNDLE.getString("metatag.title")); //$NON-NLS-1$
        detailsPanel.add(lblTitle, "2, 4, right, default");

        tfTitle = new JTextField();
        detailsPanel.add(tfTitle, "4, 4, 19, 1");
        tfTitle.setColumns(10);

        JLabel lblSeason = new JLabel(BUNDLE.getString("metatag.season")); //$NON-NLS-1$
        detailsPanel.add(lblSeason, "2, 6, right, default");

        spSeason = new JSpinner();
        detailsPanel.add(spSeason, "4, 6");

        JLabel lblEpisode = new JLabel(BUNDLE.getString("metatag.episode")); //$NON-NLS-1$
        detailsPanel.add(lblEpisode, "8, 6, right, default");

        spEpisode = new JSpinner();
        detailsPanel.add(spEpisode, "10, 6");

        JLabel lblDvdSeason = new JLabel(BUNDLE.getString("metatag.dvdseason")); //$NON-NLS-1$
        detailsPanel.add(lblDvdSeason, "2, 8, right, default");

        spDvdSeason = new JSpinner();
        detailsPanel.add(spDvdSeason, "4, 8");

        JLabel lblDvdEpisode = new JLabel(BUNDLE.getString("metatag.dvdepisode")); //$NON-NLS-1$
        detailsPanel.add(lblDvdEpisode, "8, 8, right, default");

        spDvdEpisode = new JSpinner();
        detailsPanel.add(spDvdEpisode, "10, 8");

        JLabel lblDvdOrder = new JLabel(BUNDLE.getString("metatag.dvdorder")); //$NON-NLS-1$
        detailsPanel.add(lblDvdOrder, "14, 8, right, default");

        cbDvdOrder = new JCheckBox("");
        detailsPanel.add(cbDvdOrder, "16, 8");
        cbDvdOrder.setSelected(episodeToEdit.isDvdOrder());

        JLabel lblDisplaySeason = new JLabel(BUNDLE.getString("metatag.displayseason")); //$NON-NLS-1$
        detailsPanel.add(lblDisplaySeason, "2, 10, right, default");

        spDisplaySeason = new JSpinner();
        detailsPanel.add(spDisplaySeason, "4, 10");

        JLabel lblDisplayEpisode = new JLabel(BUNDLE.getString("metatag.displayepisode")); //$NON-NLS-1$
        detailsPanel.add(lblDisplayEpisode, "8, 10, right, default");

        spDisplayEpisode = new JSpinner();
        detailsPanel.add(spDisplayEpisode, "10, 10");

        JLabel lblRating = new JLabel(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$
        detailsPanel.add(lblRating, "2, 12, right, default");

        spRating = new JSpinner();
        detailsPanel.add(spRating, "4, 12");

        JLabel lblFirstAired = new JLabel(BUNDLE.getString("metatag.aired")); //$NON-NLS-1$
        detailsPanel.add(lblFirstAired, "8, 12, right, default");

        dpFirstAired = new DatePicker(episode.getFirstAired());
        detailsPanel.add(dpFirstAired, "10, 12, 3, 1, fill, default");

        JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$
        detailsPanel.add(lblWatched, "2, 14, right, default");

        chckbxWatched = new JCheckBox("");
        detailsPanel.add(chckbxWatched, "4, 14");

        JLabel lblDateAdded = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$
        detailsPanel.add(lblDateAdded, "8, 14, right, default");

        spDateAdded = new JSpinner(new SpinnerDateModel());
        detailsPanel.add(spDateAdded, "10, 14, 3, 1, fill, default");

        JLabel lblMediasource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
        detailsPanel.add(lblMediasource, "2, 16, right, default");

        cbMediaSource = new JComboBox(MediaSource.values());
        detailsPanel.add(cbMediaSource, "4, 16, 4, 1, fill, default");

        JLabel lblPlot = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$
        detailsPanel.add(lblPlot, "2, 18, right, top");

        JScrollPane scrollPane = new JScrollPane();
        detailsPanel.add(scrollPane, "4, 18, 13, 1, fill, fill");

        taPlot = new JTextArea();
        taPlot.setLineWrap(true);
        taPlot.setWrapStyleWord(true);
        scrollPane.setViewportView(taPlot);

        lblThumb = new ImageLabel();
        lblThumb.setAlternativeText(BUNDLE.getString("image.notfound.thumb")); //$NON-NLS-1$
        lblThumb.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                Path file = TmmUIHelper.selectFile(BUNDLE.getString("image.choose")); //$NON-NLS-1$
                if (file != null && Utils.isRegularFile(file)) {
                    String fileName = file.toAbsolutePath().toString();
                    lblThumb.setImageUrl("file:/" + fileName);
                }
            }
        });
        lblThumb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        detailsPanel.add(lblThumb, "20, 6, 3, 13");

        JLabel lblDirector = new JLabel(BUNDLE.getString("metatag.director")); //$NON-NLS-1$
        detailsPanel.add(lblDirector, "2, 20, right, default");

        tfDirector = new JTextField();
        tfDirector.setText((String) null);
        tfDirector.setColumns(10);
        detailsPanel.add(tfDirector, "4, 20, 13, 1, fill, default");

        JLabel lblWriter = new JLabel(BUNDLE.getString("metatag.writer")); //$NON-NLS-1$
        detailsPanel.add(lblWriter, "2, 22, right, default");

        tfWriter = new JTextField();
        tfWriter.setText((String) null);
        tfWriter.setColumns(10);
        detailsPanel.add(tfWriter, "4, 22, 13, 1, fill, default");

        JLabel lblGuests = new JLabel(BUNDLE.getString("metatag.guests")); //$NON-NLS-1$
        detailsPanel.add(lblGuests, "2, 24, right, top");

        JScrollPane scrollPaneGuests = new JScrollPane();
        detailsPanel.add(scrollPaneGuests, "4, 24, 13, 7, fill, fill");

        tableGuests = new JTable();
        tableGuests.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
        scrollPaneGuests.setViewportView(tableGuests);

        JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$
        detailsPanel.add(lblTags, "20, 24, default, top");

        JScrollPane scrollPaneTags = new JScrollPane();
        detailsPanel.add(scrollPaneTags, "22, 24, 1, 5, fill, fill");

        listTags = new JList();
        scrollPaneTags.setViewportView(listTags);

        JButton btnAddActor = new JButton("");
        btnAddActor.setMargin(new Insets(2, 2, 2, 2));
        btnAddActor.setAction(new AddActorAction());
        btnAddActor.setIcon(IconManager.LIST_ADD);
        detailsPanel.add(btnAddActor, "2, 26, right, top");

        JButton btnAddTag = new JButton("");
        btnAddTag.setMargin(new Insets(2, 2, 2, 2));
        btnAddTag.setAction(new AddTagAction());
        btnAddTag.setIcon(IconManager.LIST_ADD);
        detailsPanel.add(btnAddTag, "20, 26, right, top");

        JButton btnRemoveActor = new JButton("");
        btnRemoveActor.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveActor.setAction(new RemoveActorAction());
        btnRemoveActor.setIcon(IconManager.LIST_REMOVE);
        detailsPanel.add(btnRemoveActor, "2, 28, right, top");

        JButton btnRemoveTag = new JButton("");
        btnRemoveTag.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveTag.setAction(new RemoveTagAction());
        btnRemoveTag.setIcon(IconManager.LIST_REMOVE);
        detailsPanel.add(btnRemoveTag, "20, 28, right, top");

        cbTags = new AutocompleteComboBox(tvShowList.getTagsInEpisodes().toArray());
        cbTags.setEditable(true);
        detailsPanel.add(cbTags, "22, 30, fill, default");
    }

    /**
     * Media Files panel
     */
    {
        mediaFilesPanel = new MediaFileEditorPanel(mediaFiles);
        tabbedPane.addTab(BUNDLE.getString("metatag.mediafiles"), null, mediaFilesPanel, null); //$NON-NLS-1$
    }

    {
        JPanel bottomPanel = new JPanel();
        getContentPane().add(bottomPanel, BorderLayout.SOUTH);

        bottomPanel.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                        FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("25px"),
                        FormFactory.RELATED_GAP_ROWSPEC, }));

        cbScraper = new MediaScraperComboBox(tvShowList.getAvailableMediaScrapers());
        MediaScraper defaultScraper = tvShowList.getDefaultMediaScraper();
        cbScraper.setSelectedItem(defaultScraper);
        bottomPanel.add(cbScraper, "2, 2, fill, default");

        JButton btnScrape = new JButton(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$
        btnScrape.setPreferredSize(new Dimension(100, 23));
        btnScrape.setMaximumSize(new Dimension(0, 0));
        btnScrape.setMinimumSize(new Dimension(100, 23));
        btnScrape.setActionCommand("Scrape");
        btnScrape.addActionListener(this);
        bottomPanel.add(btnScrape, "4, 2, left, fill");

        JButton btnSearch = new JButton(BUNDLE.getString("tvshowepisodechooser.search")); //$NON-NLS-1$
        btnSearch.setActionCommand("Search");
        btnSearch.addActionListener(this);
        btnSearch.setIcon(IconManager.SEARCH);
        bottomPanel.add(btnSearch, "6, 2, left, fill");
        {
            JPanel buttonPane = new JPanel();
            bottomPanel.add(buttonPane, "8, 2, fill, fill");
            EqualsLayout layout = new EqualsLayout(5);
            layout.setMinWidth(100);
            buttonPane.setLayout(layout);
            JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$
            okButton.setToolTipText(BUNDLE.getString("tvshow.change"));
            okButton.setIcon(IconManager.APPLY);
            buttonPane.add(okButton);
            okButton.setActionCommand("OK");
            okButton.addActionListener(this);

            JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$
            cancelButton.setToolTipText(BUNDLE.getString("edit.discard"));
            cancelButton.setIcon(IconManager.CANCEL);
            buttonPane.add(cancelButton);
            cancelButton.setActionCommand("Cancel");
            cancelButton.addActionListener(this);

            if (inQueue) {
                JButton abortButton = new JButton(BUNDLE.getString("Button.abortqueue")); //$NON-NLS-1$
                abortButton.setToolTipText(BUNDLE.getString("tvshow.edit.abortqueue.desc")); //$NON-NLS-1$
                abortButton.setIcon(IconManager.PROCESS_STOP);
                buttonPane.add(abortButton);
                abortButton.setActionCommand("Abort");
                abortButton.addActionListener(this);
            }
        }
    }

    initDataBindings();

    // fill data
    {
        MediaFile mediaFile = episodeToEdit.getMediaFiles().get(0);
        lblFilename.setText(mediaFile.getFileAsPath().toString());
        tfTitle.setText(episodeToEdit.getTitle());

        spSeason.setModel(new SpinnerNumberModel(episodeToEdit.getAiredSeason(), -1, Integer.MAX_VALUE, 1));
        spEpisode.setModel(new SpinnerNumberModel(episodeToEdit.getAiredEpisode(), -1, Integer.MAX_VALUE, 1));
        spDvdSeason.setModel(new SpinnerNumberModel(episodeToEdit.getDvdSeason(), -1, Integer.MAX_VALUE, 1));
        spDvdEpisode.setModel(new SpinnerNumberModel(episodeToEdit.getDvdEpisode(), -1, Integer.MAX_VALUE, 1));
        spDisplaySeason
                .setModel(new SpinnerNumberModel(episodeToEdit.getDisplaySeason(), -1, Integer.MAX_VALUE, 1));
        spDisplayEpisode
                .setModel(new SpinnerNumberModel(episodeToEdit.getDisplayEpisode(), -1, Integer.MAX_VALUE, 1));
        spDateAdded.setValue(episodeToEdit.getDateAdded());

        lblThumb.setImagePath(episodeToEdit.getArtworkFilename(MediaFileType.THUMB));
        spRating.setModel(new SpinnerNumberModel(episodeToEdit.getRating(), 0.0, 10.0, 0.1));
        spRating.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                voteCount = 1;
            }
        });
        voteCount = episodeToEdit.getVotes();
        chckbxWatched.setSelected(episodeToEdit.isWatched());
        taPlot.setText(episodeToEdit.getPlot());
        taPlot.setCaretPosition(0);
        tfDirector.setText(episodeToEdit.getDirector());
        tfWriter.setText(episodeToEdit.getWriter());
        cbMediaSource.setSelectedItem(episodeToEdit.getMediaSource());

        for (TvShowActor origCast : episodeToEdit.getGuests()) {
            TvShowActor actor = new TvShowActor();
            actor.setName(origCast.getName());
            actor.setCharacter(origCast.getCharacter());
            actor.setThumbUrl(origCast.getThumbUrl());
            cast.add(actor);
        }

        for (String tag : episodeToEdit.getTags()) {
            tags.add(tag);
        }
    }

    // adjust table columns
    tableGuests.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableGuests.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$

}

From source file:op.care.nursingprocess.PnlNursingProcess.java

private JPanel createNPPanel(final NursingProcess np) {
    /***/*from w w  w. ja va 2  s. c  o m*/
     *                          _        ____ ____  _  _     _   _ ____
     *       ___ _ __ ___  __ _| |_ ___ / ___|  _ \| || |   | \ | |  _ \
     *      / __| '__/ _ \/ _` | __/ _ \ |   | |_) | || |_  |  \| | |_) |
     *     | (__| | |  __/ (_| | ||  __/ |___|  __/|__   _| | |\  |  __/
     *      \___|_|  \___|\__,_|\__\___|\____|_|      |_|   |_| \_|_|
     *
     */
    if (!contenPanelMap.containsKey(np)) {
        String title = "<html><table border=\"0\">";

        if (!np.getCommontags().isEmpty()) {
            title += "<tr>" + "    <td colspan=\"2\">"
                    + CommontagsTools.getAsHTML(np.getCommontags(), SYSConst.html_16x16_tagPurple_internal)
                    + "</td>" + "  </tr>";
        }

        title += "<tr valign=\"top\">" + "<td width=\"280\" align=\"left\">" + np.getPITAsHTML() + "</td>"
                + "<td width=\"500\" align=\"left\">" + (np.isClosed() ? "<s>" : "") + np.getContentAsHTML()
                + (np.isClosed() ? "</s>" : "") + "</td></tr>";
        title += "</table>" + "</html>";

        DefaultCPTitle cptitle = new DefaultCPTitle(title, null);
        cptitle.getButton().setVerticalTextPosition(SwingConstants.TOP);

        if (!np.getAttachedFilesConnections().isEmpty()) {
            /***
             *      _     _         _____ _ _
             *     | |__ | |_ _ __ |  ___(_) | ___  ___
             *     | '_ \| __| '_ \| |_  | | |/ _ \/ __|
             *     | |_) | |_| | | |  _| | | |  __/\__ \
             *     |_.__/ \__|_| |_|_|   |_|_|\___||___/
             *
             */
            final JButton btnFiles = new JButton(Integer.toString(np.getAttachedFilesConnections().size()),
                    SYSConst.icon22greenStar);
            btnFiles.setToolTipText(SYSTools.xx("misc.btnfiles.tooltip"));
            btnFiles.setForeground(Color.BLUE);
            btnFiles.setHorizontalTextPosition(SwingUtilities.CENTER);
            btnFiles.setFont(SYSConst.ARIAL18BOLD);
            btnFiles.setPressedIcon(SYSConst.icon22Pressed);
            btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT);
            btnFiles.setAlignmentY(Component.TOP_ALIGNMENT);
            btnFiles.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnFiles.setContentAreaFilled(false);
            btnFiles.setBorder(null);
            btnFiles.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent actionEvent) {
                    Closure fileHandleClosure = np.isClosed() ? null : new Closure() {
                        @Override
                        public void execute(Object o) {
                            EntityManager em = OPDE.createEM();
                            final NursingProcess myNP = em.find(NursingProcess.class, np.getID());
                            em.close();
                            // Refresh Display
                            valuecache.get(np.getCategory()).remove(np);
                            contenPanelMap.remove(np);
                            valuecache.get(myNP.getCategory()).add(myNP);
                            Collections.sort(valuecache.get(myNP.getCategory()));

                            createCP4(myNP.getCategory());
                            buildPanel();
                        }
                    };
                    new DlgFiles(np, fileHandleClosure);
                }
            });
            btnFiles.setEnabled(OPDE.isFTPworking());
            cptitle.getRight().add(btnFiles);
        }

        if (!np.getAttachedQProcessConnections().isEmpty()) {
            /***
             *      _     _         ____
             *     | |__ | |_ _ __ |  _ \ _ __ ___   ___ ___  ___ ___
             *     | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __|
             *     | |_) | |_| | | |  __/| | | (_) | (_|  __/\__ \__ \
             *     |_.__/ \__|_| |_|_|   |_|  \___/ \___\___||___/___/
             *
             */
            final JButton btnProcess = new JButton(Integer.toString(np.getAttachedQProcessConnections().size()),
                    SYSConst.icon22redStar);
            btnProcess.setToolTipText(SYSTools.xx("misc.btnprocess.tooltip"));
            btnProcess.setForeground(Color.YELLOW);
            btnProcess.setHorizontalTextPosition(SwingUtilities.CENTER);
            btnProcess.setFont(SYSConst.ARIAL18BOLD);
            btnProcess.setPressedIcon(SYSConst.icon22Pressed);
            btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT);
            btnProcess.setAlignmentY(Component.TOP_ALIGNMENT);
            btnProcess.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnProcess.setContentAreaFilled(false);
            btnProcess.setBorder(null);
            btnProcess.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent actionEvent) {
                    new DlgProcessAssign(np, new Closure() {
                        @Override
                        public void execute(Object o) {
                            if (o == null) {
                                return;
                            }
                            Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o;

                            ArrayList<QProcess> assigned = result.getFirst();
                            ArrayList<QProcess> unassigned = result.getSecond();

                            EntityManager em = OPDE.createEM();

                            try {
                                em.getTransaction().begin();

                                em.lock(em.merge(resident), LockModeType.OPTIMISTIC);
                                final NursingProcess myNP = em.merge(np);
                                em.lock(myNP, LockModeType.OPTIMISTIC_FORCE_INCREMENT);

                                ArrayList<SYSNP2PROCESS> attached = new ArrayList<SYSNP2PROCESS>(
                                        myNP.getAttachedQProcessConnections());
                                for (SYSNP2PROCESS linkObject : attached) {
                                    if (unassigned.contains(linkObject.getQProcess())) {
                                        linkObject.getQProcess().getAttachedNReportConnections()
                                                .remove(linkObject);
                                        linkObject.getNursingProcess().getAttachedQProcessConnections()
                                                .remove(linkObject);
                                        em.merge(new PReport(
                                                SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": "
                                                        + myNP.getTitle() + " ID: " + myNP.getID(),
                                                PReportTools.PREPORT_TYPE_REMOVE_ELEMENT,
                                                linkObject.getQProcess()));
                                        em.remove(linkObject);
                                    }
                                }
                                attached.clear();

                                for (QProcess qProcess : assigned) {
                                    java.util.List<QProcessElement> listElements = qProcess.getElements();
                                    if (!listElements.contains(myNP)) {
                                        QProcess myQProcess = em.merge(qProcess);
                                        SYSNP2PROCESS myLinkObject = em
                                                .merge(new SYSNP2PROCESS(myQProcess, myNP));
                                        em.merge(new PReport(
                                                SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": "
                                                        + myNP.getTitle() + " ID: " + myNP.getID(),
                                                PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess));
                                        qProcess.getAttachedNursingProcessesConnections().add(myLinkObject);
                                        myNP.getAttachedQProcessConnections().add(myLinkObject);
                                    }
                                }

                                em.getTransaction().commit();

                                // Refresh Display
                                valuecache.get(np.getCategory()).remove(np);
                                contenPanelMap.remove(np);
                                valuecache.get(myNP.getCategory()).add(myNP);
                                Collections.sort(valuecache.get(myNP.getCategory()));

                                createCP4(myNP.getCategory());
                                buildPanel();

                            } catch (OptimisticLockException ole) {
                                OPDE.warn(ole);
                                if (em.getTransaction().isActive()) {
                                    em.getTransaction().rollback();
                                }
                                if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                                    OPDE.getMainframe().emptyFrame();
                                    OPDE.getMainframe().afterLogin();
                                } else {
                                    reloadDisplay();
                                }
                            } catch (RollbackException ole) {
                                if (em.getTransaction().isActive()) {
                                    em.getTransaction().rollback();
                                }
                                if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                                    OPDE.getMainframe().emptyFrame();
                                    OPDE.getMainframe().afterLogin();
                                }
                                OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
                            } catch (Exception e) {
                                if (em.getTransaction().isActive()) {
                                    em.getTransaction().rollback();
                                }
                                OPDE.fatal(e);
                            } finally {
                                em.close();
                            }

                        }
                    });
                }
            });
            btnProcess.setEnabled(OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID));
            cptitle.getRight().add(btnProcess);
        }

        if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.PRINT, internalClassID)) {
            /***
             *      _     _         ____       _       _
             *     | |__ | |_ _ __ |  _ \ _ __(_)_ __ | |_
             *     | '_ \| __| '_ \| |_) | '__| | '_ \| __|
             *     | |_) | |_| | | |  __/| |  | | | | | |_
             *     |_.__/ \__|_| |_|_|   |_|  |_|_| |_|\__|
             *
             */
            JButton btnPrint = new JButton(SYSConst.icon22print2);
            btnPrint.setContentAreaFilled(false);
            btnPrint.setBorder(null);
            btnPrint.setPressedIcon(SYSConst.icon22print2Pressed);
            btnPrint.setAlignmentX(Component.RIGHT_ALIGNMENT);
            btnPrint.setAlignmentY(Component.TOP_ALIGNMENT);
            btnPrint.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent actionEvent) {
                    SYSFilesTools.print(NursingProcessTools.getAsHTML(np, true, true, true, true), true);
                }
            });

            cptitle.getRight().add(btnPrint);
            //                cptitle.getTitleButton().setVerticalTextPosition(SwingConstants.TOP);
        }

        /***
         *      __  __
         *     |  \/  | ___ _ __  _   _
         *     | |\/| |/ _ \ '_ \| | | |
         *     | |  | |  __/ | | | |_| |
         *     |_|  |_|\___|_| |_|\__,_|
         *
         */
        final JButton btnMenu = new JButton(SYSConst.icon22menu);
        btnMenu.setPressedIcon(SYSConst.icon22Pressed);
        btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT);
        btnMenu.setAlignmentY(Component.TOP_ALIGNMENT);
        btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnMenu.setContentAreaFilled(false);
        btnMenu.setBorder(null);
        btnMenu.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JidePopup popup = new JidePopup();
                popup.setMovable(false);
                popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS));
                popup.setOwner(btnMenu);
                popup.removeExcludedComponent(btnMenu);
                JPanel pnl = getMenu(np);
                popup.getContentPane().add(pnl);
                popup.setDefaultFocusComponent(pnl);

                GUITools.showPopup(popup, SwingConstants.WEST);
            }
        });

        btnMenu.setEnabled(!np.isClosed());
        cptitle.getButton().setIcon(getIcon(np));

        cptitle.getRight().add(btnMenu);
        cptitle.getMain().setBackground(getColor(np.getCategory())[SYSConst.light2]);
        cptitle.getMain().setOpaque(true);
        contenPanelMap.put(np, cptitle.getMain());
    }

    return contenPanelMap.get(np);
}

From source file:org.yccheok.jstock.gui.portfolio.DividendSummaryJDialog.java

private void jLabel2MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseEntered
    if (this.dividendSummary == null || this.dividendSummary.getTotal() <= 0.0) {
        this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    } else {//w w w  .ja v a 2  s  .  com
        this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    }
}

From source file:com.limegroup.gnutella.gui.GUIUtils.java

/**
 * Returns a <code>MouseListener</code> that changes the cursor and
 * notifies <code>actionListener</code> on click.
 */// ww w  .  jav a 2  s  . c  o  m
public static MouseListener getURLInputListener(final ActionListener actionListener) {
    return new MouseAdapter() {
        public void mouseEntered(MouseEvent e) {
            JComponent comp = (JComponent) e.getComponent();
            comp.getTopLevelAncestor().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        }

        public void mouseExited(MouseEvent e) {
            JComponent comp = (JComponent) e.getComponent();
            comp.getTopLevelAncestor().setCursor(Cursor.getDefaultCursor());
        }

        public void mouseClicked(MouseEvent e) {
            actionListener.actionPerformed(new ActionEvent(e.getComponent(), 0, null));
        }
    };
}