Example usage for java.awt Cursor getPredefinedCursor

List of usage examples for java.awt Cursor getPredefinedCursor

Introduction

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

Prototype

public static Cursor getPredefinedCursor(int type) 

Source Link

Document

Returns a cursor object with the specified predefined type.

Usage

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

/**
 * This method is called from within the constructor to
 * initialize the form./*from  www . j a  v  a  2  s . com*/
 * 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() {
    jPanel5 = new JPanel();
    lblTopic = new JLabel();
    txtStichwort = new JTextField();
    lblCat = new JLabel();
    cmbKategorie = new JComboBox<>();
    panel4 = new JPanel();
    lblSituation = new JLabel();
    btnPopoutSituation = new JButton();
    jScrollPane3 = new JScrollPane();
    txtSituation = new JTextArea();
    panel5 = new JPanel();
    lblGoal = new JLabel();
    btnPopoutGoal = new JButton();
    jScrollPane1 = new JScrollPane();
    txtZiele = new JTextArea();
    lblFirstRevision = new JLabel();
    jdcKontrolle = new JDateChooser();
    panel2 = new JPanel();
    jspPlanung = new JScrollPane();
    tblPlanung = new JTable();
    panel3 = new JPanel();
    btnAddIntervention = new JButton();
    panel1 = new JPanel();
    btnCancel = new JButton();
    btnSave = new JButton();

    //======== this ========
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout("14dlu, $lcgap, 280dlu:grow, $ugap, pref, $lcgap, 14dlu",
            "fill:14dlu, $lgap, fill:default:grow, $rgap, pref, $lgap, 14dlu"));

    //======== jPanel5 ========
    {
        jPanel5.setLayout(new FormLayout("default, $lcgap, default:grow",
                "fill:default, $rgap, default, 2*($lgap, fill:default:grow), $lgap, 70dlu, $lgap, pref"));

        //---- lblTopic ----
        lblTopic.setFont(new Font("Arial", Font.PLAIN, 14));
        lblTopic.setText("Stichwort");
        jPanel5.add(lblTopic, CC.xy(1, 1, CC.DEFAULT, CC.TOP));

        //---- txtStichwort ----
        txtStichwort.setFont(new Font("Arial", Font.BOLD, 20));
        txtStichwort.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                txtStichwortFocusGained(e);
            }
        });
        jPanel5.add(txtStichwort, CC.xy(3, 1));

        //---- lblCat ----
        lblCat.setFont(new Font("Arial", Font.PLAIN, 14));
        lblCat.setText("Kategorie");
        jPanel5.add(lblCat, CC.xy(1, 3));

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

        //======== panel4 ========
        {
            panel4.setLayout(new BorderLayout());

            //---- lblSituation ----
            lblSituation.setFont(new Font("Arial", Font.PLAIN, 14));
            lblSituation.setText("Situation");
            panel4.add(lblSituation, BorderLayout.CENTER);

            //---- btnPopoutSituation ----
            btnPopoutSituation.setText(null);
            btnPopoutSituation.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/popup.png")));
            btnPopoutSituation.setBorderPainted(false);
            btnPopoutSituation.setContentAreaFilled(false);
            btnPopoutSituation
                    .setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/pressed.png")));
            btnPopoutSituation.setBorder(null);
            btnPopoutSituation.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnPopoutSituation.addActionListener(e -> btnPopoutSituationActionPerformed(e));
            panel4.add(btnPopoutSituation, BorderLayout.EAST);
        }
        jPanel5.add(panel4, CC.xy(1, 5, CC.DEFAULT, CC.TOP));

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

            //---- txtSituation ----
            txtSituation.setColumns(20);
            txtSituation.setLineWrap(true);
            txtSituation.setRows(5);
            txtSituation.setWrapStyleWord(true);
            txtSituation.setFont(new Font("Arial", Font.PLAIN, 14));
            txtSituation.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    txtSituationFocusGained(e);
                }
            });
            jScrollPane3.setViewportView(txtSituation);
        }
        jPanel5.add(jScrollPane3, CC.xy(3, 5));

        //======== panel5 ========
        {
            panel5.setLayout(new BorderLayout());

            //---- lblGoal ----
            lblGoal.setFont(new Font("Arial", Font.PLAIN, 14));
            lblGoal.setText("Ziele");
            panel5.add(lblGoal, BorderLayout.CENTER);

            //---- btnPopoutGoal ----
            btnPopoutGoal.setText(null);
            btnPopoutGoal.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/popup.png")));
            btnPopoutGoal.setBorderPainted(false);
            btnPopoutGoal.setContentAreaFilled(false);
            btnPopoutGoal
                    .setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/pressed.png")));
            btnPopoutGoal.setBorder(null);
            btnPopoutGoal.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnPopoutGoal.addActionListener(e -> btnPopoutGoalActionPerformed(e));
            panel5.add(btnPopoutGoal, BorderLayout.EAST);
        }
        jPanel5.add(panel5, CC.xy(1, 7, CC.DEFAULT, CC.TOP));

        //======== jScrollPane1 ========
        {

            //---- txtZiele ----
            txtZiele.setColumns(20);
            txtZiele.setLineWrap(true);
            txtZiele.setRows(5);
            txtZiele.setWrapStyleWord(true);
            txtZiele.setFont(new Font("Arial", Font.PLAIN, 14));
            txtZiele.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    txtZieleFocusGained(e);
                }
            });
            jScrollPane1.setViewportView(txtZiele);
        }
        jPanel5.add(jScrollPane1, CC.xy(3, 7));

        //---- lblFirstRevision ----
        lblFirstRevision.setFont(new Font("Arial", Font.PLAIN, 14));
        lblFirstRevision.setText("Erste Kontrolle am");
        jPanel5.add(lblFirstRevision, CC.xy(1, 11));

        //---- jdcKontrolle ----
        jdcKontrolle.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel5.add(jdcKontrolle, CC.xy(3, 11));
    }
    contentPane.add(jPanel5, CC.xy(3, 3, CC.DEFAULT, CC.FILL));

    //======== panel2 ========
    {
        panel2.setLayout(new FormLayout("default:grow", "default, $lgap, default"));

        //======== jspPlanung ========
        {
            jspPlanung.addComponentListener(new ComponentAdapter() {
                @Override
                public void componentResized(ComponentEvent e) {
                    jspPlanungComponentResized(e);
                }
            });

            //---- tblPlanung ----
            tblPlanung.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" }));
            tblPlanung.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
            tblPlanung.addMouseListener(new MouseAdapter() {
                @Override
                public void mousePressed(MouseEvent e) {
                    tblPlanungMousePressed(e);
                }
            });
            jspPlanung.setViewportView(tblPlanung);
        }
        panel2.add(jspPlanung, CC.xy(1, 1));

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

            //---- btnAddIntervention ----
            btnAddIntervention.setText(null);
            btnAddIntervention.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
            btnAddIntervention.setContentAreaFilled(false);
            btnAddIntervention.setBorderPainted(false);
            btnAddIntervention.setBorder(null);
            btnAddIntervention
                    .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
            btnAddIntervention.addActionListener(e -> btnAddInterventionActionPerformed(e));
            panel3.add(btnAddIntervention);
        }
        panel2.add(panel3, CC.xy(1, 3));
    }
    contentPane.add(panel2, CC.xy(5, 3));

    //======== panel1 ========
    {
        panel1.setLayout(new HorizontalLayout(5));

        //---- btnCancel ----
        btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
        btnCancel.setText(null);
        btnCancel.addActionListener(e -> btnCancelActionPerformed(e));
        panel1.add(btnCancel);

        //---- btnSave ----
        btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
        btnSave.setText(null);
        btnSave.addActionListener(e -> btnSaveActionPerformed(e));
        panel1.add(btnSave);
    }
    contentPane.add(panel1, CC.xy(5, 5, CC.RIGHT, CC.DEFAULT));
    setSize(1145, 695);
    setLocationRelativeTo(getOwner());
}

From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java

private void rebuildChart() {
    if (listModel.getSize() < 2) {
        JOptionPane.showMessageDialog(this, "Select 2 compounds.", "Error", JOptionPane.OK_OPTION);
        err = true;//from  www  .  j av  a  2 s  . c  o  m
        return;
    }
    if (listModel.getSize() > 2) {
        JOptionPane.showMessageDialog(this, "Select only 2 compounds.", "Error", JOptionPane.OK_OPTION);
        return;
    }
    double T = Double.parseDouble(temperature.getText());
    if (T <= 0) {
        JOptionPane.showMessageDialog(this, "Invalid Temperature.", "Error", JOptionPane.OK_OPTION);
        return;
    }

    COSMOSAC cosmosac = (COSMOSAC) modelBox.getSelectedItem();
    COSMOSACCompound comps[] = new COSMOSACCompound[2];
    try {
        comps[0] = db.getComp((String) listModel.getElementAt(0));
        comps[1] = db.getComp((String) listModel.getElementAt(1));
        cosmosac.setComponents(comps);
    } catch (Exception e1) {
        e1.printStackTrace();
        return;
    }
    if (comps[0] == null || comps[1] == null)
        return;

    cosmosac.setSigmaHB(Double.parseDouble(sigmaHB.getText()));
    cosmosac.setSigmaHB2(Double.parseDouble(sigmaHB2.getText()));
    cosmosac.setSigmaHB3(Double.parseDouble(sigmaHB3.getText()));
    //      cosmosac.setSigmaHBUpper(Double.parseDouble(sigmaHBUpper.getText()));
    cosmosac.setCHB(Double.parseDouble(chargeHB.getText()));
    cosmosac.setSigmaDisp(Double.parseDouble(sigmaDisp.getText()));
    cosmosac.setCDisp(Double.parseDouble(chargeDisp.getText()));
    cosmosac.setBeta(Double.parseDouble(beta.getText()));
    cosmosac.setFpol(Double.parseDouble(fpol.getText()));
    cosmosac.setAnorm(Double.parseDouble(anorm.getText()));
    cosmosac.parametersChanged();

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    //      cosmosac.setParameters(cavityVolume, c1.charge, sigma);

    cosmosac.setTemperature(T);

    // testing several compositions
    XYSeriesCollection dataset = new XYSeriesCollection();
    int n = 20;
    XYSeries lnGamma1 = new XYSeries(comps[0].name);
    XYSeries lnGamma2 = new XYSeries(comps[1].name);
    XYSeries ge_RT = new XYSeries("gE/RT");

    for (int i = 0; i <= n; ++i) {
        z[0] = (double) i / n;
        z[1] = 1 - z[0];
        cosmosac.setComposition(z);
        cosmosac.activityCoefficient(lnGamma);

        lnGamma1.add(z[0], lnGamma[0]);
        lnGamma2.add(z[0], lnGamma[1]);
        ge_RT.add(z[0], z[0] * lnGamma[0] + z[1] * lnGamma[1]);

        if (z[0] == 0) {
            lnGammaInf1Label.setText(String.format("%6.3g", lnGamma[0]));
            gammaInf1Label.setText(String.format("%6.3g", Math.exp(lnGamma[0])));
        }
        if (z[1] == 0) {
            lnGammaInf2Label.setText(String.format("%6.3g", lnGamma[1]));
            gammaInf2Label.setText(String.format("%6.3g", Math.exp(lnGamma[1])));
        }
    }
    dataset.addSeries(lnGamma1);
    dataset.addSeries(lnGamma2);
    dataset.addSeries(ge_RT);

    plot.setDataset(dataset);

    // now the segment gamma
    dataset = new XYSeriesCollection();
    double[][] seggamma = cosmosac.getPureSegmentGamma();

    n = comps[0].charge.length;
    XYSeries g1 = new XYSeries(comps[0].name);
    XYSeries g2 = new XYSeries(comps[1].name);
    XYSeries g1s = new XYSeries(comps[0].name + " * sigma");
    XYSeries g2s = new XYSeries(comps[1].name + " * sigma");

    for (int j = 0; j < n; ++j) {
        g1.add(comps[0].charge[j], Math.log(seggamma[0][j]));
        g2.add(comps[1].charge[j], Math.log(seggamma[1][j]));
        g1s.add(comps[0].charge[j], comps[0].area[j] * (Math.log(seggamma[1][j]) - Math.log(seggamma[0][j])));
        g2s.add(comps[1].charge[j], comps[1].area[j] * (Math.log(seggamma[0][j]) - Math.log(seggamma[1][j])));
    }
    dataset.addSeries(g1);
    dataset.addSeries(g2);
    dataset.addSeries(g1s);
    dataset.addSeries(g2s);
    plotSegGamma.setDataset(dataset);

    // adjust the plot properties
    plotSegGamma.getDomainAxis().setAutoRange(false);
    plotSegGamma.getDomainAxis().setRange(new Range(-0.025, 0.025));
    XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plotSegGamma.getRenderer();
    r.setSeriesStroke(0, new BasicStroke(2.5f));
    r.setSeriesStroke(1, new BasicStroke(2.5f));
    BasicStroke dashed = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 6.0f }, 0.0f);

    r.setSeriesStroke(2, dashed);
    r.setSeriesStroke(3, dashed);
    r.setSeriesPaint(0, Color.RED);
    r.setSeriesPaint(1, Color.BLUE);
    r.setSeriesPaint(2, Color.RED);
    r.setSeriesPaint(3, Color.BLUE);
    //      plotSegGamma.setRenderer(stepRenderer);
    //      plotSegGamma.setRenderer(3, stepRenderer);

    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

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

/**
 * This method is called from within the constructor to
 * initialize the form./*  ww w.ja  v  a  2s  .  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=" 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./*w w w  .  j av  a2  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="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;//w w w  . j  a  v a  2s.  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./* w  ww  .  java 2  s.  c o 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 w  w  w.  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:org.tinymediamanager.ui.movies.settings.MovieSettingsPanel.java

/**
 * Instantiates a new movie settings panel.
 *//*from  www .  ja  v  a 2  s . com*/
public MovieSettingsPanel() {
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC,
                    RowSpec.decode("default:grow"), }));

    JPanel panelGeneral = new JPanel();
    panelGeneral.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.general"), TitledBorder.LEADING, //$NON-NLS-1$
            TitledBorder.TOP, null, null));
    add(panelGeneral, "2, 2, fill, fill");
    panelGeneral.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.UNRELATED_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, }));

    JLabel lblVisiblecolumns = new JLabel(BUNDLE.getString("Settings.movie.visiblecolumns")); //$NON-NLS-1$
    panelGeneral.add(lblVisiblecolumns, "2, 2, right, default");

    chckbxYear = new JCheckBox(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
    panelGeneral.add(chckbxYear, "4, 2");

    chckbxRating = new JCheckBox(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$
    panelGeneral.add(chckbxRating, "6, 2");

    chckbxNfo = new JCheckBox(BUNDLE.getString("metatag.nfo")); //$NON-NLS-1$
    panelGeneral.add(chckbxNfo, "8, 2");

    chckbxMetadata = new JCheckBox(BUNDLE.getString("tmm.metadata")); //$NON-NLS-1$
    panelGeneral.add(chckbxMetadata, "10, 2");

    chckbxDateAdded = new JCheckBox(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$
    panelGeneral.add(chckbxDateAdded, "12, 2");

    chckbxImages = new JCheckBox(BUNDLE.getString("metatag.images")); //$NON-NLS-1$
    panelGeneral.add(chckbxImages, "4, 4");

    chckbxTrailer = new JCheckBox(BUNDLE.getString("metatag.trailer")); //$NON-NLS-1$
    panelGeneral.add(chckbxTrailer, "6, 4");

    chckbxSubtitles = new JCheckBox(BUNDLE.getString("metatag.subtitles")); //$NON-NLS-1$
    panelGeneral.add(chckbxSubtitles, "8, 4");

    chckbxWatched = new JCheckBox(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$
    panelGeneral.add(chckbxWatched, "10, 4");

    JLabel lblSaveUiFilter = new JLabel(BUNDLE.getString("Settings.movie.persistuifilter")); //$NON-NLS-1$
    panelGeneral.add(lblSaveUiFilter, "2, 6, right, default");

    chckbxSaveUiFilter = new JCheckBox("");
    panelGeneral.add(chckbxSaveUiFilter, "4, 6");

    JSeparator separator_4 = new JSeparator();
    panelGeneral.add(separator_4, "2, 8, 11, 1");

    JLabel lblImageCache = new JLabel(BUNDLE.getString("Settings.imagecacheimport"));
    panelGeneral.add(lblImageCache, "2, 10, right, default");

    chckbxImageCache = new JCheckBox(BUNDLE.getString("Settings.imagecacheimporthint")); //$NON-NLS-1$
    TmmFontHelper.changeFont(chckbxImageCache, 0.833);
    panelGeneral.add(chckbxImageCache, "4, 10, 7, 1");

    JLabel lblRuntimeFromMedia = new JLabel(BUNDLE.getString("Settings.runtimefrommediafile"));
    panelGeneral.add(lblRuntimeFromMedia, "2, 12, right, default");

    chckbxRuntimeFromMf = new JCheckBox("");
    panelGeneral.add(chckbxRuntimeFromMf, "4, 12");

    JSeparator separator = new JSeparator();
    panelGeneral.add(separator, "2, 14, 11, 1");

    final JLabel lblAutomaticRename = new JLabel(BUNDLE.getString("Settings.movie.automaticrename")); //$NON-NLS-1$
    panelGeneral.add(lblAutomaticRename, "2, 16, right, default");

    chckbxRename = new JCheckBox(BUNDLE.getString("Settings.movie.automaticrename.desc")); //$NON-NLS-1$
    panelGeneral.add(chckbxRename, "4, 16, 7, 1");

    JLabel lblTraktTv = new JLabel(BUNDLE.getString("Settings.trakt"));//$NON-NLS-1$
    panelGeneral.add(lblTraktTv, "2, 18");

    chckbxTraktTv = new JCheckBox("");
    panelGeneral.add(chckbxTraktTv, "4, 18");

    JButton btnClearTraktTvMovies = new JButton(BUNDLE.getString("Settings.trakt.clearmovies"));//$NON-NLS-1$
    btnClearTraktTvMovies.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int confirm = JOptionPane.showOptionDialog(null,
                    BUNDLE.getString("Settings.trakt.clearmovies.hint"),
                    BUNDLE.getString("Settings.trakt.clearmovies"), JOptionPane.YES_NO_OPTION, //$NON-NLS-1$
                    JOptionPane.QUESTION_MESSAGE, null, null, null);
            if (confirm == JOptionPane.YES_OPTION) {
                TmmTask task = new ClearTraktTvTask(true, false);
                TmmTaskManager.getInstance().addUnnamedTask(task);
            }
        }
    });
    panelGeneral.add(btnClearTraktTvMovies, "6, 18, 3, 1, left, default");

    JPanel panelMovieDataSources = new JPanel();

    panelMovieDataSources.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.movie.datasource"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelMovieDataSources, "2, 4, 3, 1, fill, fill");
    panelMovieDataSources.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("150dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150dlu:grow(2)"),
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("100px:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, }));

    JLabel lblDataSource = new JLabel(BUNDLE.getString("Settings.source")); //$NON-NLS-1$
    panelMovieDataSources.add(lblDataSource, "2, 2, 5, 1");

    JLabel lblIngore = new JLabel(BUNDLE.getString("Settings.ignore")); //$NON-NLS-1$
    panelMovieDataSources.add(lblIngore, "12, 2");

    JScrollPane scrollPaneDataSources = new JScrollPane();
    panelMovieDataSources.add(scrollPaneDataSources, "2, 4, 5, 1, fill, fill");

    listDataSources = new JList<>();
    scrollPaneDataSources.setViewportView(listDataSources);

    JPanel panelMovieSourcesButtons = new JPanel();
    panelMovieDataSources.add(panelMovieSourcesButtons, "8, 4, fill, top");
    panelMovieSourcesButtons
            .setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] {
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, }));

    JButton btnAdd = new JButton(IconManager.LIST_ADD);
    btnAdd.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$
    btnAdd.setMargin(new Insets(2, 2, 2, 2));
    btnAdd.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.datasource.folderchooser")); //$NON-NLS-1$
            if (file != null && Files.isDirectory(file)) {
                settings.addMovieDataSources(file.toAbsolutePath().toString());
            }
        }
    });

    panelMovieSourcesButtons.add(btnAdd, "1, 1, fill, top");

    JButton btnRemove = new JButton(IconManager.LIST_REMOVE);
    btnRemove.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$
    btnRemove.setMargin(new Insets(2, 2, 2, 2));
    btnRemove.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            int row = listDataSources.getSelectedIndex();
            if (row != -1) { // nothing selected
                String path = MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource().get(row);
                String[] choices = { BUNDLE.getString("Button.continue"), BUNDLE.getString("Button.abort") }; //$NON-NLS-1$
                int decision = JOptionPane.showOptionDialog(null,
                        String.format(BUNDLE.getString("Settings.movie.datasource.remove.info"), path),
                        BUNDLE.getString("Settings.datasource.remove"), JOptionPane.YES_NO_OPTION,
                        JOptionPane.PLAIN_MESSAGE, null, choices, BUNDLE.getString("Button.abort")); //$NON-NLS-1$
                if (decision == 0) {
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    MovieModuleManager.MOVIE_SETTINGS.removeMovieDataSources(path);
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            }
        }
    });
    panelMovieSourcesButtons.add(btnRemove, "1, 3, fill, top");

    JScrollPane scrollPaneIgnore = new JScrollPane();
    panelMovieDataSources.add(scrollPaneIgnore, "12, 4, fill, fill");

    listIgnore = new JList<>();
    scrollPaneIgnore.setViewportView(listIgnore);

    JPanel panelIgnoreButtons = new JPanel();
    panelMovieDataSources.add(panelIgnoreButtons, "14, 4, fill, fill");
    panelIgnoreButtons.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] {
            FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, }));

    JButton btnAddIgnore = new JButton(IconManager.LIST_ADD);
    btnAddIgnore.setToolTipText(BUNDLE.getString("Settings.addignore")); //$NON-NLS-1$
    btnAddIgnore.setMargin(new Insets(2, 2, 2, 2));
    btnAddIgnore.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.ignore")); //$NON-NLS-1$
            if (file != null && Files.isDirectory(file)) {
                settings.addMovieSkipFolder(file.toAbsolutePath().toString());
            }
        }
    });
    panelIgnoreButtons.add(btnAddIgnore, "1, 1");

    JButton btnRemoveIgnore = new JButton(IconManager.LIST_REMOVE);
    btnRemoveIgnore.setToolTipText(BUNDLE.getString("Settings.removeignore")); //$NON-NLS-1$
    btnRemoveIgnore.setMargin(new Insets(2, 2, 2, 2));
    btnRemoveIgnore.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int row = listIgnore.getSelectedIndex();
            if (row != -1) { // nothing selected
                String ingore = settings.getMovieSkipFolders().get(row);
                settings.removeMovieSkipFolder(ingore);
            }
        }
    });
    panelIgnoreButtons.add(btnRemoveIgnore, "1, 3");

    JPanel panel = new JPanel();
    panelMovieDataSources.add(panel, "2, 8, 13, 1, fill, fill");
    panel.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("20dlu"),
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, },
            new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, }));

    JLabel lblNfoFormat = new JLabel(BUNDLE.getString("Settings.nfoFormat"));
    panel.add(lblNfoFormat, "1, 1, right, default");

    cbNfoFormat = new JComboBox(MovieConnectors.values());
    panel.add(cbNfoFormat, "3, 1, fill, default");

    JLabel lblNfoFileNaming = new JLabel(BUNDLE.getString("Settings.nofFileNaming")); //$NON-NLS-1$
    panel.add(lblNfoFileNaming, "7, 1, right, default");

    cbMovieNfoFilename1 = new JCheckBox(BUNDLE.getString("Settings.moviefilename") + ".nfo"); //$NON-NLS-1$
    panel.add(cbMovieNfoFilename1, "9, 1");

    cbMovieNfoFilename2 = new JCheckBox("movie.nfo");
    panel.add(cbMovieNfoFilename2, "9, 2");
    cbMovieNfoFilename2.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            checkChanges();
        }
    });

    cbMovieNfoFilename3 = new JCheckBox(BUNDLE.getString("Settings.nfo.discstyle")); //$NON-NLS-1$
    panel.add(cbMovieNfoFilename3, "9, 3");
    cbMovieNfoFilename3.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            checkChanges();
        }
    });

    final JLabel lblCertificationStyle = new JLabel(BUNDLE.getString("Settings.certificationformat")); //$NON-NLS-1$
    panel.add(lblCertificationStyle, "1, 5, right, default");

    cbCertificationStyle = new JComboBox();
    panel.add(cbCertificationStyle, "3, 5, 7, 1, fill, default");

    JPanel panelBadWords = new JPanel();
    panelBadWords.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.movie.badwords"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelBadWords, "4, 2, fill, fill");
    panelBadWords.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));

    JTextPane txtpntBadWordsHint = new JTextPane();
    txtpntBadWordsHint.setBackground(UIManager.getColor("Panel.background"));
    txtpntBadWordsHint.setText(BUNDLE.getString("Settings.movie.badwords.hint")); //$NON-NLS-1$
    TmmFontHelper.changeFont(txtpntBadWordsHint, 0.833);
    panelBadWords.add(txtpntBadWordsHint, "2, 2, 3, 1, fill, default");

    JScrollPane scpBadWords = new JScrollPane();
    panelBadWords.add(scpBadWords, "2, 4, fill, fill");

    listBadWords = new JList<>();
    scpBadWords.setViewportView(listBadWords);

    JButton btnRemoveBadWord = new JButton(IconManager.LIST_REMOVE);
    btnRemoveBadWord.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$
    btnRemoveBadWord.setMargin(new Insets(2, 2, 2, 2));
    btnRemoveBadWord.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            int row = listBadWords.getSelectedIndex();
            if (row != -1) {
                String badWord = MovieModuleManager.MOVIE_SETTINGS.getBadWords().get(row);
                MovieModuleManager.MOVIE_SETTINGS.removeBadWord(badWord);
            }
        }
    });
    panelBadWords.add(btnRemoveBadWord, "4, 4, default, bottom");

    tfAddBadword = new JTextField();
    tfAddBadword.setColumns(10);
    panelBadWords.add(tfAddBadword, "2, 6, fill, default");

    JButton btnAddBadWord = new JButton(IconManager.LIST_ADD);
    btnAddBadWord.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$
    btnAddBadWord.setMargin(new Insets(2, 2, 2, 2));
    btnAddBadWord.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (StringUtils.isNotEmpty(tfAddBadword.getText())) {
                MovieModuleManager.MOVIE_SETTINGS.addBadWord(tfAddBadword.getText());
                tfAddBadword.setText("");
            }
        }
    });
    panelBadWords.add(btnAddBadWord, "4, 6");

    initDataBindings();

    {
        // NFO filenames
        List<MovieNfoNaming> movieNfoFilenames = settings.getMovieNfoFilenames();
        if (movieNfoFilenames.contains(MovieNfoNaming.FILENAME_NFO)) {
            cbMovieNfoFilename1.setSelected(true);
        }
        if (movieNfoFilenames.contains(MovieNfoNaming.MOVIE_NFO)) {
            cbMovieNfoFilename2.setSelected(true);
        }
        if (movieNfoFilenames.contains(MovieNfoNaming.DISC_NFO)) {
            cbMovieNfoFilename3.setSelected(true);
        }

        if (!Globals.isDonator()) {
            chckbxTraktTv.setSelected(false);
            chckbxTraktTv.setEnabled(false);
            btnClearTraktTvMovies.setEnabled(false);
        }

        // set default certification style
        cbNfoFormat.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                if (cbNfoFormat.getSelectedItem() == MovieConnectors.MP) {
                    for (int i = 0; i < cbCertificationStyle.getItemCount(); i++) {
                        CertificationStyleWrapper wrapper = cbCertificationStyle.getItemAt(i);
                        if (wrapper.style == CertificationStyle.TECHNICAL) {
                            cbCertificationStyle.setSelectedItem(wrapper);
                            break;
                        }
                    }
                } else if (cbNfoFormat.getSelectedItem() == MovieConnectors.XBMC
                        || cbNfoFormat.getSelectedItem() == MovieConnectors.KODI) {
                    for (int i = 0; i < cbCertificationStyle.getItemCount(); i++) {
                        CertificationStyleWrapper wrapper = cbCertificationStyle.getItemAt(i);
                        if (wrapper.style == CertificationStyle.LARGE) {
                            cbCertificationStyle.setSelectedItem(wrapper);
                            break;
                        }
                    }
                }
            }
        });

        // certification examples
        for (CertificationStyle style : CertificationStyle.values()) {
            CertificationStyleWrapper wrapper = new CertificationStyleWrapper();
            wrapper.style = style;
            cbCertificationStyle.addItem(wrapper);
            if (style == settings.getMovieCertificationStyle()) {
                cbCertificationStyle.setSelectedItem(wrapper);
            }
        }

        cbCertificationStyle.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                checkChanges();
            }
        });

        // item listener
        cbMovieNfoFilename1.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                checkChanges();
            }
        });
    }

}

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

public MindMapPanel(final MindMapPanelController controller) {
    super(null);// w  ww .ja v  a2 s . co  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:AltiConsole.AltiConsoleMainScreen.java

public AltiConfigData retrieveAltiConfig() {
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    AltiConfigData Alticonfig = null;//from w ww  .j  av a  2s  .co  m
    Alticonfig = new AltiConfigData();

    if (Serial.getConnected() == false) {
        boolean ret = false;
        ret = ConnectToAlti();
        if (!ret) {
            System.out.println("retrieveAltiConfig - Data retrieval timed out1\n");
            this.setCursor(Cursor.getDefaultCursor());
            return null;
        }
    }
    Serial.clearInput();
    //Serial.DataReady = false;
    Serial.setDataReady(false);
    // send command to switch off the continuity test
    Serial.writeData("b;\n");
    System.out.println("b;\n");
    long timeOut = 10000;
    if (UserPref.getRetrievalTimeout() != null && UserPref.getRetrievalTimeout() != "")
        timeOut = Long.decode(UserPref.getRetrievalTimeout());
    long startTime = System.currentTimeMillis();
    //while (!Serial.getDataReady()) {
    while (true) {
        long currentTime = System.currentTimeMillis();
        if (Serial.getDataReady())
            break;
        if ((currentTime - startTime) > timeOut) {
            // This is some sort of data retrieval timeout
            System.out.println("retrieveAltiConfig - Data retrieval timed out2\n");
            if (Serial.getDataReady())
                System.out.println("Data is true\n");
            else
                System.out.println("Data is false\n");
            JOptionPane.showMessageDialog(null, trans.get("AltiConsoleMainScreen.dataTimeOut") + "0",
                    trans.get("AltiConsoleMainScreen.ConnectionError"), JOptionPane.ERROR_MESSAGE);
            this.setCursor(Cursor.getDefaultCursor());

            return null;
        }
    }
    if (Serial.AltiCfg != null) {
        System.out.println("Reading altimeter config\n");
        System.out.println(Serial.AltiCfg.getUnits() + "\n");
        Alticonfig = Serial.AltiCfg;

    }
    this.setCursor(Cursor.getDefaultCursor());
    return Alticonfig;
}