Example usage for javax.swing JScrollPane setViewportView

List of usage examples for javax.swing JScrollPane setViewportView

Introduction

In this page you can find the example usage for javax.swing JScrollPane setViewportView.

Prototype

public void setViewportView(Component view) 

Source Link

Document

Creates a viewport if necessary and then sets its view.

Usage

From source file:com.orange.atk.graphAnalyser.LectureJATKResult.java

/** This method is called from within the constructor to
 * initialize the form./* ww  w.  ja v  a 2  s . c  om*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
    jListGraph = new JList(listModel);
    jComboBoxLeft = new JComboBox(comboModelLeft);
    jComboBoxRight = new JComboBox(comboModelRight);
    jListMarker = new JList(listModelMarker);
    jTable2 = new javax.swing.JTable();
    jMenu1 = new javax.swing.JMenu();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

    jComboBoxLeft.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jComboBoxLeftActionPerformed(evt);
        }
    });

    jComboBoxRight.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jComboBoxRightActionPerformed(evt);
        }
    });

    jTable2.setModel(modeltable);

    jMenu1.setText("File");

    JMenuItem jMenuItem1 = new JMenuItem();
    jMenuItem1.setText("Open Directory");
    jMenuItem1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            openDirectoryAction(evt);
        }
    });

    JMenuItem jMenuItem2 = new JMenuItem();
    jMenuItem2.setText("Add a reference Graph");
    jMenuItem2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            jMenuItemaddGraphActionPerformed(evt);
        }
    });

    JMenuItem jMenuItem3 = new JMenuItem();
    jMenuItem3.setText("set Graph color");
    jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemChangecolorActionPerformed(evt);
        }
    });

    JMenuItem jMenuItem4 = new JMenuItem();
    jMenuItem4.setText("save config file");
    jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemSaveConfigFileActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem1);
    jMenu1.add(jMenuItem2);
    jMenu1.add(jMenuItem3);
    jMenu1.add(jMenuItem4);

    JMenuBar jMenuBar1 = new JMenuBar();
    jMenuBar1.add(jMenu1);

    setJMenuBar(jMenuBar1);

    //organise JFRAME
    JPanel mainpanel = (JPanel) getContentPane();
    mainpanel.setLayout(new BorderLayout());

    mainpanel.add(chartPanel, BorderLayout.CENTER);

    JPanel toolPanel = new JPanel();
    toolPanel.setLayout(new FlowLayout());

    toolPanel.add(jComboBoxLeft);

    Box graphbox = Box.createVerticalBox();
    graphbox.add(new JLabel("List of Graph "));
    JScrollPane jspaneGraph = new JScrollPane();
    jspaneGraph.setViewportView(jListGraph);
    jspaneGraph.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jspaneGraph.setPreferredSize(new Dimension(150, 100));

    graphbox.add(jspaneGraph);
    //      graphbox.setBorder(BorderFactory.createLineBorder(Color.black));
    toolPanel.add(graphbox);

    Box markerbox = Box.createVerticalBox();
    markerbox.add(new JLabel("List of Marker"));
    JScrollPane jspaneMarker = new JScrollPane();
    jspaneMarker.setViewportView(jListMarker);
    jspaneMarker.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jspaneMarker.setPreferredSize(new Dimension(150, 100));
    markerbox.add(jspaneMarker);
    //      markerbox.setBorder(BorderFactory.createLineBorder(Color.black));
    toolPanel.add(markerbox);

    JScrollPane jspane = new JScrollPane();
    jspane.setViewportView(jTable2);
    jspane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jspane.setPreferredSize(new Dimension(300, 100));
    toolPanel.add(jspane);
    toolPanel.add(jComboBoxRight);

    mainpanel.add(toolPanel, BorderLayout.NORTH);

    pack();
}

From source file:fr.pasteque.pos.sales.restaurant.JTicketsBagRestaurantMap.java

/** Creates new form JTicketsBagRestaurant */
public JTicketsBagRestaurantMap(AppView app, TicketsEditor panelticket) {

    super(app, panelticket);

    dlReceipts = new DataLogicReceipts();
    dlSales = new DataLogicSales();

    m_restaurantmap = new JTicketsBagRestaurant(app, this);
    m_PlaceCurrent = null;/* www.  ja va 2  s  . c o  m*/
    m_PlaceClipboard = null;
    customer = null;
    this.floors = new ArrayList<Floor>();
    this.places = new HashMap<String, List<Place>>();
    try {
        ServerLoader loader = new ServerLoader();
        ServerLoader.Response r = loader.read("PlacesAPI", "getAll");
        if (r.getStatus().equals(ServerLoader.Response.STATUS_OK)) {
            JSONArray a = r.getArrayContent();
            for (int i = 0; i < a.length(); i++) {
                JSONObject oFloor = a.getJSONObject(i);
                Floor f = new Floor(oFloor);
                this.floors.add(f);
                this.places.put(f.getID(), new ArrayList<Place>());
                JSONArray aPlaces = oFloor.getJSONArray("places");
                for (int j = 0; j < aPlaces.length(); j++) {
                    Place p = new Place(aPlaces.getJSONObject(j));
                    this.places.get(f.getID()).add(p);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    initComponents();

    // add the Floors containers
    if (this.floors.size() > 1) {
        // A tab container for 2 or more floors
        JTabbedPane jTabFloors = new JTabbedPane();
        jTabFloors.applyComponentOrientation(getComponentOrientation());
        jTabFloors.setBorder(new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5)));
        jTabFloors.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
        jTabFloors.setFocusable(false);
        jTabFloors.setRequestFocusEnabled(false);
        m_jPanelMap.add(jTabFloors, BorderLayout.CENTER);

        for (Floor f : this.floors) {
            f.getContainer().applyComponentOrientation(getComponentOrientation());
            JScrollPane jScrCont = new JScrollPane();
            jScrCont.applyComponentOrientation(getComponentOrientation());
            JPanel jPanCont = new JPanel();
            jPanCont.applyComponentOrientation(getComponentOrientation());

            jTabFloors.addTab(f.getName(), f.getIcon(), jScrCont);
            jScrCont.setViewportView(jPanCont);
            jPanCont.add(f.getContainer());
        }
    } else if (this.floors.size() == 1) {
        // Just a frame for 1 floor
        Floor f = this.floors.get(0);
        f.getContainer().applyComponentOrientation(getComponentOrientation());

        JPanel jPlaces = new JPanel();
        jPlaces.applyComponentOrientation(getComponentOrientation());
        jPlaces.setLayout(new BorderLayout());
        jPlaces.setBorder(new javax.swing.border.CompoundBorder(
                new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5)),
                new javax.swing.border.TitledBorder(f.getName())));

        JScrollPane jScrCont = new JScrollPane();
        jScrCont.applyComponentOrientation(getComponentOrientation());
        JPanel jPanCont = new JPanel();
        jPanCont.applyComponentOrientation(getComponentOrientation());

        // jPlaces.setLayout(new FlowLayout());           
        m_jPanelMap.add(jPlaces, BorderLayout.CENTER);
        jPlaces.add(jScrCont, BorderLayout.CENTER);
        jScrCont.setViewportView(jPanCont);
        jPanCont.add(f.getContainer());
    }

    // Add all the Table buttons.
    for (Floor f : this.floors) {
        List<Place> places = this.places.get(f.getID());
        for (Place pl : places) {
            f.getContainer().add(pl.getButton());
            pl.setButtonBounds();
            pl.getButton().addActionListener(new MyActionListener(pl));
        }
    }

    // Add the reservations panel
    m_jreservations = new JTicketsBagRestaurantRes(app, this);
    add(m_jreservations, "res");
}

From source file:ca.uhn.hl7v2.testpanel.ui.AddMessageDialog.java

/**
 * Create the dialog./*from www.  j ava2  s  .  c  om*/
 */
public AddMessageDialog(Controller theController) {
    myController = theController;

    setMinimumSize(new Dimension(450, 400));
    setPreferredSize(new Dimension(450, 400));
    setSize(new Dimension(450, 400));
    setResizable(false);
    setMaximumSize(new Dimension(450, 400));
    setTitle("Add Message");
    setBounds(100, 100, 450, 401);
    getContentPane().setLayout(new BorderLayout());
    mycontentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(mycontentPanel, BorderLayout.CENTER);
    GridBagLayout gbl_contentPanel = new GridBagLayout();
    gbl_contentPanel.columnWidths = new int[] { 0, 0 };
    gbl_contentPanel.rowHeights = new int[] { 0, 0, 0 };
    gbl_contentPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_contentPanel.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE };
    mycontentPanel.setLayout(gbl_contentPanel);
    {
        JPanel panel = new JPanel();
        panel.setBorder(
                new TitledBorder(null, "Message Type", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        GridBagConstraints gbc_panel = new GridBagConstraints();
        gbc_panel.weighty = 1.0;
        gbc_panel.insets = new Insets(0, 0, 5, 0);
        gbc_panel.fill = GridBagConstraints.BOTH;
        gbc_panel.gridx = 0;
        gbc_panel.gridy = 0;
        mycontentPanel.add(panel, gbc_panel);
        GridBagLayout gbl_panel = new GridBagLayout();
        gbl_panel.columnWidths = new int[] { 0, 0, 0 };
        gbl_panel.rowHeights = new int[] { 0, 0, 0 };
        gbl_panel.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
        gbl_panel.rowWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
        panel.setLayout(gbl_panel);
        {
            JLabel lblVersion = new JLabel("Version");
            GridBagConstraints gbc_lblVersion = new GridBagConstraints();
            gbc_lblVersion.insets = new Insets(0, 0, 5, 5);
            gbc_lblVersion.gridx = 0;
            gbc_lblVersion.gridy = 0;
            panel.add(lblVersion, gbc_lblVersion);
        }
        {
            JLabel lblType = new JLabel("Type");
            GridBagConstraints gbc_lblType = new GridBagConstraints();
            gbc_lblType.insets = new Insets(0, 0, 5, 0);
            gbc_lblType.gridx = 1;
            gbc_lblType.gridy = 0;
            panel.add(lblType, gbc_lblType);
        }
        {
            JScrollPane scrollPane = new JScrollPane();
            scrollPane.setViewportBorder(null);
            GridBagConstraints gbc_scrollPane = new GridBagConstraints();
            gbc_scrollPane.weighty = 1.0;
            gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
            gbc_scrollPane.fill = GridBagConstraints.BOTH;
            gbc_scrollPane.gridx = 0;
            gbc_scrollPane.gridy = 1;
            panel.add(scrollPane, gbc_scrollPane);
            {
                myVersionList = new JList();
                myVersionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                scrollPane.setViewportView(myVersionList);
            }
        }
        {
            JScrollPane scrollPane = new JScrollPane();
            scrollPane.setViewportBorder(null);
            GridBagConstraints gbc_scrollPane = new GridBagConstraints();
            gbc_scrollPane.weighty = 1.0;
            gbc_scrollPane.weightx = 1.0;
            gbc_scrollPane.fill = GridBagConstraints.BOTH;
            gbc_scrollPane.gridx = 1;
            gbc_scrollPane.gridy = 1;
            panel.add(scrollPane, gbc_scrollPane);
            {
                myMessageTypeList = new JList();
                myMessageTypeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                scrollPane.setViewportView(myMessageTypeList);
            }
        }
    }
    {
        JPanel panel = new JPanel();
        panel.setBorder(new TitledBorder(null, "Options", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        GridBagConstraints gbc_panel = new GridBagConstraints();
        gbc_panel.fill = GridBagConstraints.BOTH;
        gbc_panel.gridx = 0;
        gbc_panel.gridy = 1;
        mycontentPanel.add(panel, gbc_panel);
        GridBagLayout gbl_panel = new GridBagLayout();
        gbl_panel.columnWidths = new int[] { 0, 0, 0 };
        gbl_panel.rowHeights = new int[] { 0, 0 };
        gbl_panel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
        gbl_panel.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
        panel.setLayout(gbl_panel);
        {
            JLabel lblEncoding = new JLabel("Encoding");
            GridBagConstraints gbc_lblEncoding = new GridBagConstraints();
            gbc_lblEncoding.insets = new Insets(0, 0, 0, 5);
            gbc_lblEncoding.gridx = 0;
            gbc_lblEncoding.gridy = 0;
            panel.add(lblEncoding, gbc_lblEncoding);
        }
        {
            JPanel panel_1 = new JPanel();
            panel_1.setBorder(null);
            GridBagConstraints gbc_panel_1 = new GridBagConstraints();
            gbc_panel_1.anchor = GridBagConstraints.WEST;
            gbc_panel_1.fill = GridBagConstraints.VERTICAL;
            gbc_panel_1.gridx = 1;
            gbc_panel_1.gridy = 0;
            panel.add(panel_1, gbc_panel_1);
            {
                myEr7Radio = new JRadioButton("ER7");
                myEr7Radio.setSelected(true);
                encodingButtonGroup.add(myEr7Radio);
                panel_1.add(myEr7Radio);
            }
            {
                JRadioButton myXmlRadio = new JRadioButton("XML");
                encodingButtonGroup.add(myXmlRadio);
                panel_1.add(myXmlRadio);
            }
        }
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton okButton = new JButton("OK");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    try {
                        String version = (String) myVersionList.getSelectedValue();
                        String fullType = (String) myMessageTypeList.getSelectedValue();
                        String structure = myTypesToStructures.get(fullType);
                        String[] fullTypeBits = fullType.split("\\^");
                        String type = fullTypeBits[0];
                        String trigger = fullTypeBits[1];

                        Hl7V2EncodingTypeEnum encoding = myEr7Radio.isSelected() ? Hl7V2EncodingTypeEnum.ER_7
                                : Hl7V2EncodingTypeEnum.XML;
                        myController.addMessage(version, type, trigger, structure, encoding);
                    } finally {
                        setVisible(false);
                    }
                }
            });
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    AddMessageDialog.this.setVisible(false);
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }

    initLocal();
}

From source file:com.view.TradeWindow.java

private void TraderBlockOrdersActionPerformed(java.awt.event.ActionEvent evt) {
    TableModel dtm = (TableModel) TraderIncomingRequestsTable.getModel();
    int nRow = dtm.getRowCount();
    int nCol = dtm.getColumnCount();
    Object[][] tableData = new Object[nRow][nCol];
    ArrayList<SingleOrder> parsedOrders = new ArrayList();
    ControllerBlockOrders control = new ControllerBlockOrders();

    for (int i = 0; i < nRow; i++) {
        for (int j = 0; j < nCol; j++) {
            tableData[i][j] = dtm.getValueAt(i, j);
        }// w w  w  .  j  a v  a2s.co  m
        SingleOrder o = new SingleOrder();
        o.SingleOrderMakeBlocks(tableData[i]);
        parsedOrders.add(o);
    }
    singleOrderLists = control.MakeBlock(parsedOrders);
    showMessageDialog(null, "Blocks have been successfully completed.");
    //dtm.setRowCount(0);
    TraderPlatformBlockedRequests.setLayout(new BorderLayout());
    int count = 1;
    ArrayList<JScrollPane> paneList = new ArrayList<JScrollPane>();
    for (ArrayList<SingleOrder> b : singleOrderLists) {
        JTable jTable = new JTable();
        jTable.setModel(CTraderBlockOrder.getTableModel(b));
        Dimension d = jTable.getPreferredSize();
        // System.out.println(d);
        int rows = jTable.getRowCount();
        // System.out.println(rows);
        JScrollPane jPane = new JScrollPane();
        jPane.setPreferredSize(new Dimension(d.width, jTable.getRowHeight() * rows + 50));
        jPane.add(jTable);
        jPane.setViewportView(jTable);
        paneList.add(jPane);
        count++;
    }

    test.add(blockOptions);
    int i = 0;
    for (final JScrollPane j : paneList) {
        //   JButton btn = new JButton();
        //  btn.setText("Split Block");
        //     btn.setName(""+i);

        JPanel cPanel = new JPanel();
        /*  btn.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            JViewport viewport = j.getViewport(); 
            final JTable mytable = (JTable)viewport.getView();
            final ArrayList<Integer> index = new ArrayList<Integer>();
            for(int row = 0;row<mytable.getRowCount();row++){
                  if((boolean)mytable.getValueAt(row, 11)){
                     index.add(row);
                  }
            }
             SplitBlockActionPerformed(evt,index,cPanel,test);
         }
          });*/
        JCheckBox check = new JCheckBox();
        JLabel label = new JLabel();
        label.setText("Select Block");
        check.setName("" + i);
        check.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SelectBlockActionPerformed(evt);
            }
        });
        JPanel splitOptions = new JPanel();
        splitOptions.add(label);
        splitOptions.add(check);
        splitOptions.setName("splitOpt");
        //  splitOptions.add(btn);
        cPanel.setName("cPanel" + i);
        cPanel.add(splitOptions);
        cPanel.add(j);
        cPanel.setLayout(new BoxLayout(cPanel, BoxLayout.Y_AXIS));
        test.add(cPanel);
        cPanelList.add(cPanel);
        i++;
    }

    test.setLayout(new BoxLayout(test, BoxLayout.Y_AXIS));
    JScrollPane p = new JScrollPane(test);
    p.setName("ParentP");
    TraderPlatformBlockedRequests.add(p);
    TraderPlatformBlockedRequests.validate();
    TraderPlatformTabbedPane.setSelectedIndex(TraderPlatformTabbedPane.getSelectedIndex() + 1);

}

From source file:com.smart.aqimonitor.client.AqiMonitor.java

/**
 * Create the frame.//from w ww . j av  a2s.  com
 */
public AqiMonitor() {
    refSelf = this;
    setPreferredSize(new Dimension(640, 480));
    setTitle("\u7A7A\u6C14\u8D28\u91CF\u76D1\u6D4B");
    setIconImage(Toolkit.getDefaultToolkit()
            .getImage(AqiMonitor.class.getResource("/lombok/installer/eclipse/STS.png")));
    setMinimumSize(new Dimension(640, 480));
    setMaximumSize(new Dimension(1024, 768));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 636, 412);
    contentPane = new JPanel();
    contentPane.setPreferredSize(new Dimension(640, 480));
    contentPane.setMinimumSize(new Dimension(640, 480));
    contentPane.setMaximumSize(new Dimension(1024, 768));
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JPanel mainPanel = new JPanel();
    contentPane.add(mainPanel, BorderLayout.CENTER);
    mainPanel.setLayout(new BorderLayout(0, 0));

    JPanel contentPanel = new JPanel();
    mainPanel.add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));

    JScrollPane scrollPane = new JScrollPane();
    scrollPane
            .setViewportBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    contentPanel.add(scrollPane, BorderLayout.CENTER);

    textPane = new AqiTextPane();
    textPane.addInputMethodListener(new InputMethodListener() {

        public void caretPositionChanged(InputMethodEvent event) {

        }

        public void inputMethodTextChanged(InputMethodEvent event) {
            textPane.setCaretPosition(document.getLength() + 1);
        }
    });
    textPane.setEditable(false);
    textPane.setOpaque(false);
    textPane.setForeground(Color.BLACK);
    scrollPane.setViewportView(textPane);
    document = textPane.getStyledDocument();

    document.addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            if (e.getDocument() == document) {
                textPane.setCaretPosition(document.getLength());
            }
        }
    });

    JPanel buttonPanel = new JPanel();
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    buttonPanel.setLayout(new BorderLayout(0, 0));

    JLabel lblTipsLabel = new JLabel(
            "Tips\uFF1A\u6587\u4EF6\u4FDD\u5B58\u683C\u5F0Fcsv\u53EF\u7528Excel\u6253\u5F00");
    lblTipsLabel.setForeground(Color.BLUE);
    buttonPanel.add(lblTipsLabel, BorderLayout.WEST);

    JPanel panel = new JPanel();
    buttonPanel.add(panel, BorderLayout.CENTER);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JButton btnRetrieve = new JButton("\u624B\u52A8\u83B7\u53D6\u6570\u636E");
    panel.add(btnRetrieve);
    btnRetrieve.setVerticalAlignment(SwingConstants.BOTTOM);

    JButton btnNewButton = new JButton("\u5173\u4E8E");
    btnNewButton.setToolTipText("\u5173\u4E8E");
    btnNewButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JTextArea textArea = new JTextArea(
                    "\n        csv\n\n        smartstudio@foxmail.com");
            textArea.setColumns(35);
            textArea.setRows(6);
            textArea.setLineWrap(true);// 
            textArea.setEditable(false);// 
            textArea.setOpaque(false);
            JOptionPane.showMessageDialog(contentPane, textArea, "", JOptionPane.PLAIN_MESSAGE);
        }
    });

    JButton btnSetting = new JButton("\u8BBE\u7F6E");
    btnSetting.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            Point parentPos = refSelf.getLocation();

            AqiSettingDialog settingDialog = new AqiSettingDialog(refSelf, pm25InDetailJob.getAqiParser());
            settingDialog.setModal(true);
            settingDialog.setLocation(parentPos.x + 100, parentPos.y + 150);
            settingDialog.init();
            settingDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            settingDialog.setVisible(true);
        }
    });

    JButton btnExportDir = new JButton("\u67E5\u770B\u6570\u636E");
    btnExportDir.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {

                String[] cmd = new String[5];

                String filePath = pm25InDetailJob.getAqiParser().getFilePath();
                File file = new File(filePath);
                if (!file.exists()) {
                    FileUtil.makeDir(file);
                }
                if (!file.isDirectory()) {
                    JOptionPane.showMessageDialog(contentPane, "", "",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }

                cmd[0] = "cmd";
                cmd[1] = "/c";
                cmd[2] = "start";
                cmd[3] = " ";
                cmd[4] = pm25InDetailJob.getAqiParser().getFilePath();

                Runtime.getRuntime().exec(cmd);

            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });
    panel.add(btnExportDir);
    panel.add(btnSetting);
    panel.add(btnNewButton);
    btnRetrieve.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (!isRetrieving) {
                isRetrieving = true;
                Thread firstRun = new Thread(new Runnable() {

                    @Override
                    public void run() {
                        pm25InDetailJob.refresh();
                        isRetrieving = false;
                    }
                });

                firstRun.start();
            }
        }
    });

    init();
}

From source file:kr.ac.kaist.swrc.jhannanum.demo.GUIDemo.java

/**
 * Returns the panel for the work flow.//ww  w  . ja va  2s .c  om
 * 
 * @return the panel for the work flow
 */
private JComponent createWorkflow() {
    JPanel workflowPanel = new JPanel(new GridLayout(1, 3));

    listModelMajor2 = new DefaultListModel();
    listModelMajor3 = new DefaultListModel();
    listModelSupplement1 = new DefaultListModel();
    listModelSupplement2 = new DefaultListModel();
    listModelSupplement3 = new DefaultListModel();

    listPluginMajor2 = new JList(listModelMajor2);
    listPluginMajor3 = new JList(listModelMajor3);
    listPluginSupplement1 = new JList(listModelSupplement1);
    listPluginSupplement2 = new JList(listModelSupplement2);
    listPluginSupplement3 = new JList(listModelSupplement3);

    // phase1
    JPanel phasePanel = new JPanel(new GridLayout(1, 1));
    phasePanel.setBorder(BorderFactory.createTitledBorder("Phase1. Plain Text Processing"));
    JPanel listPanel = new JPanel(new GridLayout(1, 1));
    listPanel.setBorder(BorderFactory.createTitledBorder("Supplement Plug-in"));
    JScrollPane scroll = new JScrollPane();
    scroll.setViewportView(listPluginSupplement1);
    listPanel.add(scroll);
    phasePanel.add(listPanel);
    workflowPanel.add(phasePanel);

    // phase2
    phasePanel = new JPanel(new GridLayout(1, 2));
    phasePanel.setBorder(BorderFactory.createTitledBorder("Phase2. Morphological Analysis"));
    listPanel = new JPanel(new GridLayout(1, 1));
    listPanel.setBorder(BorderFactory.createTitledBorder("Major Plug-in"));
    scroll = new JScrollPane();
    scroll.setViewportView(listPluginMajor2);
    listPanel.add(scroll);
    phasePanel.add(listPanel);

    listPanel = new JPanel(new GridLayout(1, 1));
    listPanel.setBorder(BorderFactory.createTitledBorder("Supplement Plug-in"));
    scroll = new JScrollPane();
    scroll.setViewportView(listPluginSupplement2);
    listPanel.add(scroll);
    phasePanel.add(listPanel);

    workflowPanel.add(phasePanel);

    // phase3
    phasePanel = new JPanel(new GridLayout(1, 2));
    phasePanel.setBorder(BorderFactory.createTitledBorder("Phase3. Part Of Speech Tagging"));
    listPanel = new JPanel(new GridLayout(1, 1));
    listPanel.setBorder(BorderFactory.createTitledBorder("Major Plug-in"));
    scroll = new JScrollPane();
    scroll.setViewportView(listPluginMajor3);
    listPanel.add(scroll);
    phasePanel.add(listPanel);

    listPanel = new JPanel(new GridLayout(1, 1));
    listPanel.setBorder(BorderFactory.createTitledBorder("Supplement Plug-in"));
    scroll = new JScrollPane();
    scroll.setViewportView(listPluginSupplement3);
    listPanel.add(scroll);
    phasePanel.add(listPanel);

    workflowPanel.add(phasePanel);

    /////////////////////////////////////////////////////////////////////////////////////

    JPanel controlPanel = new JPanel(new GridLayout(4, 1));
    controlPanel.setBorder(BorderFactory.createTitledBorder("Workflow Control"));
    buttonActivate = new JButton("Activate the workflow");
    buttonAnalysis = new JButton("Analyze Text");
    buttonReset = new JButton("Close the workflow");

    JPanel threadPanel = new JPanel(new GridLayout(1, 1));
    radioMultiThread = new JRadioButton("Mutli-thread Mode", true);
    radioSingleThread = new JRadioButton("Single-thread Mode", false);
    threadPanel.setBorder(BorderFactory.createTitledBorder("Thread Mode"));
    threadPanel.add(radioMultiThread);
    threadPanel.add(radioSingleThread);
    ButtonGroup groupThread = new ButtonGroup();
    groupThread.add(radioMultiThread);
    groupThread.add(radioSingleThread);

    controlPanel.add(threadPanel);
    controlPanel.add(buttonActivate);
    controlPanel.add(buttonAnalysis);
    controlPanel.add(buttonReset);

    buttonAnalysis.setEnabled(false);
    buttonReset.setEnabled(false);

    /////////////////////////////////////////////////////////////////////////////////////

    JPanel pluginInfoPanel = new JPanel(new GridLayout(1, 1));
    pluginInfoPanel.setBorder(BorderFactory.createTitledBorder("Plug-in Information"));
    areaPluginInfo = new JTextArea();
    areaPluginInfo.setLineWrap(true);
    scroll = new JScrollPane();
    scroll.setViewportView(areaPluginInfo);
    pluginInfoPanel.add(scroll);

    JPanel infoPanel = new JPanel(new GridLayout(1, 2));
    infoPanel.add(pluginInfoPanel);
    infoPanel.add(controlPanel);

    JPanel panel = new JPanel(new GridLayout(2, 1));
    workflowPanel.setBorder(BorderFactory.createTitledBorder("HanNanum Workflow"));
    panel.add(workflowPanel);
    panel.add(infoPanel);

    return panel;
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.PanelDescricaoImagens.java

private void initComponentsEscalavel(ArrayList<FerramentaDescricaoModel> erros) {
    Ferramenta_Imagens.carregaTexto(TokenLang.LANG);
    JPanel regraFonteBtn = new JPanel();
    regraFonteBtn.setLayout(new BorderLayout());

    textAreaSourceCode = new G_TextAreaSourceCode();
    textAreaSourceCode.setTipoHTML();//from   w ww .j  av  a2s  .co  m
    new OnChange(textAreaSourceCode, this);

    // parentFrame.setTitle("Associador de rtulos");
    tableLinCod = new TabelaDescricao(this, erros);
    arTextPainelCorrecao = new ArTextPainelCorrecao(this);

    // scrollPaneCorrecaoLabel = new ConteudoCorrecaoLabel();
    analiseSistematica = new JButton();
    salvar = new JButton();
    abrir = new JButton();
    cancelar = new JButton();
    strConteudoalt = new String();
    // panelLegenda = new JPanel();
    btnSalvar = new JMenuItem(GERAL.BTN_SALVAR);

    pnRegra = new JPanel();
    lbRegras1 = new JLabel();
    lbRegras2 = new JLabel();
    pnSetaDescricao = new JPanel();
    spTextoDescricao = new JScrollPane();
    tArParticipRotulo = new TArParticipRotulo(this);
    conteudoDoAlt = new JTextArea();
    pnListaErros = new JPanel();
    scrollPanetabLinCod = new JScrollPane();
    /**
     * Mostra pro usurio a imagem que est sem descrio
     */
    imagemSemDesc = new XHTMLPanel();

    pnBotoes = new JPanel();
    salvar.setEnabled(false);
    salvaAlteracoes = TxtBuffer.getInstanciaSalvaAlteracoes(textAreaSourceCode.getTextPane(), salvar,
            new JMenuItem(), parentFrame);
    adicionar = new JButton();
    aplicar = new JButton();
    conteudoParticRotulo = new ArrayList<String>();
    analiseSistematica.setEnabled(false);
    // setJMenuBar(this.criaMenuBar());
    // ======== this ========
    // setTitle("Associe explicitamente os r\u00f3tulos aos respectivos
    // controles:");

    setBackground(CoresDefault.getCorPaineis());
    Container contentPane = this;// ??
    contentPane.setLayout(new GridLayout(2, 1));

    // ======== pnRegra ========
    {
        pnRegra.setBorder(criaBorda(Ferramenta_Imagens.TITULO_REGRA));
        pnRegra.setLayout(new GridLayout(2, 1));
        pnRegra.add(lbRegras1);
        lbRegras1.setText(Ferramenta_Imagens.REGRAP1);
        lbRegras2.setText(Ferramenta_Imagens.REGRAP2);
        lbRegras1.setHorizontalAlignment(SwingConstants.CENTER);
        lbRegras2.setHorizontalAlignment(SwingConstants.CENTER);
        pnRegra.add(lbRegras1);
        pnRegra.add(lbRegras2);
        pnRegra.setPreferredSize(new Dimension(700, 60));
    }

    // G_URLIcon.setIcon(lbTemp,
    // "http://pitecos.blogs.sapo.pt/arquivo/pai%20natal%20o5.%20jpg.jpg");
    JScrollPane sp = new JScrollPane();

    sp.setViewportView(imagemSemDesc);
    sp.setPreferredSize(new Dimension(500, 300));

    // ======== pnDescricao ========

    // ---- Salvar ----
    salvar.setText(Ferramenta_Imagens.BTN_SALVAR);
    salvar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            salvarActionPerformed(e);
        }
    });

    salvar.setToolTipText(Ferramenta_Imagens.DICA_SALVAR);
    salvar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_SALVAR);
    salvar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_SALVAR);
    salvar.setBounds(10, 0, 150, 25);

    abrir.setText(Ferramenta_Imagens.BTN_ABRIR);
    abrir.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AbrirActionPerformed(e);
        }
    });

    abrir.setToolTipText(Ferramenta_Imagens.DICA_ABRIR_HTML);
    abrir.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_ABRIR_HTML);
    abrir.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_ABRIR_HTML);
    abrir.setBounds(165, 0, 150, 25);

    cancelar.setText(Ferramenta_Imagens.TELA_ANTERIOR);
    cancelar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            CancelarActionPerformed(e);
        }
    });

    cancelar.setToolTipText(Ferramenta_Imagens.DICA_TELA_ANTERIOR);
    cancelar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_TELA_ANTERIOR);
    cancelar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.TELA_ANTERIOR);
    cancelar.setBounds(320, 0, 150, 25);

    analiseSistematica.setText(GERAL.ANALISE_SISTEMATICA);
    analiseSistematica.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            buttonAction = e;
            Thread t = new Thread(new Runnable() {
                public void run() {
                    PainelStatusBar.showProgTarReq();
                    parentFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
                    analiseSistematicaActionPerformed(buttonAction);
                    parentFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    PainelStatusBar.hideProgTarReq();
                }
            });
            t.setPriority(9);
            t.start();

        }
    });

    analiseSistematica.setToolTipText(GERAL.DICA_ANALISE_SISTEMATICA);
    analiseSistematica.getAccessibleContext().setAccessibleDescription(GERAL.DICA_ANALISE_SISTEMATICA);
    analiseSistematica.getAccessibleContext().setAccessibleName(GERAL.DICA_ANALISE_SISTEMATICA);
    analiseSistematica.setBounds(480, 0, 150, 25);
    // ======== pnParticRotulo ========

    pnSetaDescricao.setBorder(criaBorda(Ferramenta_Imagens.TITULO_DIGITE_O_ALT));
    GridBagConstraints cons = new GridBagConstraints();
    GridBagLayout layout = new GridBagLayout();
    cons.fill = GridBagConstraints.BOTH;
    cons.weighty = 1;
    cons.weightx = 0.80;

    pnSetaDescricao.setLayout(layout);
    cons.anchor = GridBagConstraints.SOUTHEAST;
    cons.insets = new Insets(0, 0, 0, 10);
    conteudoDoAlt.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent arg0) {
        }

        public void keyTyped(KeyEvent arg0) {
        }

        public void keyReleased(KeyEvent arg0) {
            if (conteudoDoAlt.getText().length() == 0) {
                System.out.println("conteudo vazio");
                aplicar.setEnabled(false);

            } else if (tableLinCod.getSelectedRow() != -1) {
                System.out.println("com conteudo");
                aplicar.setEnabled(true);

            }
        }
    });
    // ======== spParticRotulo ========
    {
        spTextoDescricao.setViewportView(conteudoDoAlt);
    }

    // lbRegras1.setText(Reparo_Imagens.REGRAP2);
    // lbRegras1.setHorizontalAlignment(SwingConstants.CENTER);

    // pnRegra.add(lbRegras1);

    pnSetaDescricao.add(spTextoDescricao, cons);
    cons.weightx = 0.20;
    pnSetaDescricao.setPreferredSize(new Dimension(400, 60));

    // ======== pnListaErros ========
    {

        pnListaErros.setBorder(criaBorda(Ferramenta_Imagens.LISTA_ERROS));
        pnListaErros.setLayout(new BorderLayout());
        // ======== scrollPanetabLinCod ========
        {
            scrollPanetabLinCod.setViewportView(tableLinCod);
        }
        pnListaErros.add(scrollPanetabLinCod, BorderLayout.CENTER);
    }
    // ======== pnBotoes ========
    {

        // pnBotoes.setBorder(criaBorda(""));

        pnBotoes.setLayout(null);
        // ---- adicionar ----
        adicionar.setText(Ferramenta_Imagens.BTN_ADICIONAR);
        adicionar.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                adicionarActionPerformed(e);
            }
        });

        adicionar.setToolTipText(Ferramenta_Imagens.DICA_ADICIONAR);
        adicionar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_ADICIONAR);
        adicionar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_ADICIONAR);
        adicionar.setBounds(10, 5, 150, 25);
        // pnBotoes.add(adicionar);

        // ---- aplicarRotulo ----
        aplicar.setEnabled(false);
        aplicar.setText(Ferramenta_Imagens.BTN_APLICAR);
        aplicar.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

                aplicarRotuloActionPerformed(e);
            }
        });

        aplicar.setToolTipText(Ferramenta_Imagens.DICA_APLICAR);
        aplicar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_APLICAR);
        aplicar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_APLICAR);
        aplicar.setBounds(10, 5, 150, 25);
        pnBotoes.add(aplicar);
    }

    /*
     * Colocar os controles
     */
    pnRegra.setBackground(CoresDefault.getCorPaineis());
    regraFonteBtn.add(pnRegra, BorderLayout.NORTH);
    textAreaSourceCode.setBorder(criaBorda(""));
    textAreaSourceCode.setBackground(CoresDefault.getCorPaineis());

    JSplitPane splitPane = null;

    Dimension minimumSize = new Dimension(0, 0);
    // JScrollPane ajudaScrollPane = new
    // JScrollPane(ajuda,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    sp.setMinimumSize(minimumSize);
    sp.setPreferredSize(new Dimension(150, 90));
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp, textAreaSourceCode);
    splitPane.setOneTouchExpandable(true);
    // splitPane.set
    // splitPane.setDividerLocation(0.95);
    int w = parentFrame.getWidth();
    int s = w / 4;
    splitPane.setDividerLocation(s);

    // regraFonteBtn.add(scrollPaneCorrecaoLabel, BorderLayout.CENTER);
    regraFonteBtn.add(splitPane, BorderLayout.CENTER);
    pnBotoes.setPreferredSize(new Dimension(600, 35));
    pnBotoes.setBackground(CoresDefault.getCorPaineis());
    // regraFonteBtn.add(pnBotoes, BorderLayout.SOUTH);
    regraFonteBtn.setBackground(CoresDefault.getCorPaineis());
    contentPane.add(regraFonteBtn);

    JPanel textoErrosBtn = new JPanel();
    textoErrosBtn.setLayout(new BorderLayout());
    pnSetaDescricao.setBackground(CoresDefault.getCorPaineis());
    pnSetaDescricao.add(pnBotoes, cons);
    textoErrosBtn.add(pnSetaDescricao, BorderLayout.NORTH);

    textoErrosBtn.add(pnListaErros, BorderLayout.CENTER);
    JPanel pnSalvarCancelar = new JPanel();
    pnSalvarCancelar.setLayout(null);
    pnSalvarCancelar.setPreferredSize(new Dimension(600, 35));
    pnSalvarCancelar.add(salvar);
    pnSalvarCancelar.add(abrir);
    pnSalvarCancelar.add(cancelar);
    if (!original) {
        reverter = new JButton("Reverter");
        reverter.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                setVisible(false);
                TxtBuffer.setContent(TxtBuffer.getContentOriginal());
                parentFrame.showPainelFerramentaImgPArq(TxtBuffer.getContentOriginal(), enderecoPagina);
                setVisible(true);
            }
        });
        //reverter.setActionCommand("Reverter");
        reverter.setText(TradPainelRelatorio.REVERTER);
        reverter.setToolTipText(TradPainelRelatorio.DICA_REVERTER);
        reverter.getAccessibleContext().setAccessibleDescription(TradPainelRelatorio.DICA_REVERTER);
        reverter.getAccessibleContext().setAccessibleName(TradPainelRelatorio.DICA_REVERTER);
        if (EstadoSilvinha.conteudoEmPainelResumo) {
            reverter.setBounds(640, 0, 150, 25);
        } else {
            reverter.setBounds(480, 0, 150, 25);
        }
        pnSalvarCancelar.add(reverter);
    }

    if (EstadoSilvinha.conteudoEmPainelResumo) {
        pnSalvarCancelar.add(analiseSistematica);
    }
    pnSalvarCancelar.setBackground(CoresDefault.getCorPaineis());
    textoErrosBtn.add(pnSalvarCancelar, BorderLayout.SOUTH);
    pnListaErros.setBackground(CoresDefault.getCorPaineis());
    textoErrosBtn.add(pnListaErros, BorderLayout.CENTER);
    if (tableLinCod.getRowCount() == 0)
        tableLinCod.addLinha(0, 0, GERAL.DOC_SEM_ERROS);
    contentPane.setBackground(CoresDefault.getCorPaineis());
    contentPane.add(textoErrosBtn);

    this.setVisible(true);

}

From source file:br.unicamp.cst.util.MindViewer.java

private DefaultTreeModel createTreeModelGUI(JScrollPane scrollPane, List<Codelet> codelets, String title) {
    DefaultTreeModel treeCodelets = TreeViewerUtil.createTreeModel(codelets, title, TreeElement.ICON_CODELETS);

    JTree jtTree = new JTree(treeCodelets);
    jtTree.setCellRenderer(new RendererJTree());
    TreeViewerUtil.expandAllNodes(jtTree);
    scrollPane.setViewportView(jtTree);

    return treeCodelets;
}

From source file:com.litt.core.security.license.gui.ConfigPanel.java

/**
 * Create the panel./*from   w  ww  .j av a2  s  . co  m*/
 */
public ConfigPanel(final Gui gui) {
    GridBagLayout gbl_configPanel = new GridBagLayout();
    gbl_configPanel.columnWidths = new int[] { 0, 0, 0, 0 };
    gbl_configPanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    gbl_configPanel.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
    gbl_configPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
            Double.MIN_VALUE };
    this.setLayout(gbl_configPanel);

    JLabel label_18 = new JLabel("?");
    GridBagConstraints gbc_label_18 = new GridBagConstraints();
    gbc_label_18.insets = new Insets(0, 0, 5, 5);
    gbc_label_18.anchor = GridBagConstraints.EAST;
    gbc_label_18.gridx = 0;
    gbc_label_18.gridy = 0;
    this.add(label_18, gbc_label_18);

    comboBox_config = new JComboBox();
    comboBox_config.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                try {
                    LicenseConfig licenseConfig = (LicenseConfig) e.getItem();
                    File licenseFile = new File(licenseConfig.getLicenseFilePath());
                    currentLicenseConfig = licenseConfig;
                    loadLicense(licenseFile);
                    gui.setCurrentLicenseConfig(currentLicenseConfig);
                } catch (Exception e1) {
                    JOptionPane.showMessageDialog(self, e1.getMessage());
                }
            }
        }
    });
    GridBagConstraints gbc_comboBox_config = new GridBagConstraints();
    gbc_comboBox_config.insets = new Insets(0, 0, 5, 5);
    gbc_comboBox_config.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox_config.gridx = 1;
    gbc_comboBox_config.gridy = 0;
    this.add(comboBox_config, gbc_comboBox_config);

    JButton button_3 = new JButton("?");
    button_3.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

            try {
                comboBox_config.removeAllItems();

                File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml");

                Document document = XmlUtils.readXml(configFile);
                Element rootE = document.getRootElement();
                List productList = rootE.elements();
                for (int i = 0; i < productList.size(); i++) {
                    Element productE = (Element) productList.get(i);
                    String productCode = productE.attributeValue("code");

                    List customerList = productE.elements();
                    for (int j = 0; j < customerList.size(); j++) {
                        Element customerE = (Element) customerList.get(j);
                        String customerCode = customerE.attributeValue("code");

                        LicenseConfig licenseConfig = new LicenseConfig();
                        licenseConfig.setProductCode(productCode);
                        licenseConfig.setCustomerCode(customerCode);
                        licenseConfig.setLicenseId(customerE.elementText("licenseId"));
                        licenseConfig.setEncryptedLicense(customerE.elementText("encryptedLicense"));
                        licenseConfig.setRootFilePath(Gui.HOME_PATH);
                        licenseConfig.setLicenseFilePath(Gui.HOME_PATH + File.separator + productCode
                                + File.separator + customerCode + File.separator + "license.xml");
                        licenseConfig.setPriKeyFilePath(
                                Gui.HOME_PATH + File.separator + productCode + File.separator + "private.key");
                        licenseConfig.setPubKeyFilePath(
                                Gui.HOME_PATH + File.separator + productCode + File.separator + "license.key");
                        comboBox_config.addItem(licenseConfig);
                        if (i == 0 && j == 0) {
                            File licenseFile = new File(licenseConfig.getLicenseFilePath());
                            currentLicenseConfig = licenseConfig;
                            loadLicense(licenseFile);
                            gui.setCurrentLicenseConfig(currentLicenseConfig);

                            btnDelete.setEnabled(true);
                        }
                    }
                }

            } catch (Exception e1) {
                e1.printStackTrace();
                JOptionPane.showMessageDialog(self, e1.getMessage());
            }

        }
    });

    btnDelete = new JButton();
    btnDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (currentLicenseConfig != null) {
                try {
                    String productCode = currentLicenseConfig.getProductCode();
                    String customerCode = currentLicenseConfig.getCustomerCode();
                    //congfig.xml
                    File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml");
                    Document document = XmlUtils.readXml(configFile);

                    Element customerNode = (Element) document.selectSingleNode(
                            "//product[@code='" + productCode + "']/customer[@code='" + customerCode + "']");
                    if (customerNode != null) {
                        customerNode.detach();
                        XmlUtils.writeXml(configFile, document);
                    }
                    //                  
                    File licensePathFile = new File(currentLicenseConfig.getLicenseFilePath());
                    if (licensePathFile.exists()) {
                        FileUtils.deleteDirectory(licensePathFile.getParentFile());
                    }

                    //comboboxitem
                    comboBox_config.removeItemAt(comboBox_config.getSelectedIndex());
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                if (comboBox_config.getItemCount() <= 0) {
                    btnDelete.setEnabled(false);
                }

            }
        }
    });
    btnDelete.setEnabled(false);
    btnDelete.setIcon(new ImageIcon(ConfigPanel.class.getResource("/images/icon_delete.png")));
    GridBagConstraints gbc_btnDelete = new GridBagConstraints();
    gbc_btnDelete.insets = new Insets(0, 0, 5, 0);
    gbc_btnDelete.gridx = 2;
    gbc_btnDelete.gridy = 0;
    add(btnDelete, gbc_btnDelete);
    GridBagConstraints gbc_button_3 = new GridBagConstraints();
    gbc_button_3.insets = new Insets(0, 0, 5, 5);
    gbc_button_3.gridx = 1;
    gbc_button_3.gridy = 1;
    this.add(button_3, gbc_button_3);

    JLabel lblid = new JLabel("?ID");
    GridBagConstraints gbc_lblid = new GridBagConstraints();
    gbc_lblid.anchor = GridBagConstraints.EAST;
    gbc_lblid.insets = new Insets(0, 0, 5, 5);
    gbc_lblid.gridx = 0;
    gbc_lblid.gridy = 2;
    this.add(lblid, gbc_lblid);

    textField_licenseId = new JTextField();
    GridBagConstraints gbc_textField_licenseId = new GridBagConstraints();
    gbc_textField_licenseId.insets = new Insets(0, 0, 5, 5);
    gbc_textField_licenseId.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_licenseId.gridx = 1;
    gbc_textField_licenseId.gridy = 2;
    this.add(textField_licenseId, gbc_textField_licenseId);
    textField_licenseId.setColumns(10);

    JLabel label = new JLabel("?");
    GridBagConstraints gbc_label = new GridBagConstraints();
    gbc_label.anchor = GridBagConstraints.EAST;
    gbc_label.insets = new Insets(0, 0, 5, 5);
    gbc_label.gridx = 0;
    gbc_label.gridy = 3;
    add(label, gbc_label);

    comboBox_licenseType = new JComboBox(MapComboBoxModel.getLicenseTypeOptions().toArray());
    GridBagConstraints gbc_comboBox_licenseType = new GridBagConstraints();
    gbc_comboBox_licenseType.insets = new Insets(0, 0, 5, 5);
    gbc_comboBox_licenseType.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox_licenseType.gridx = 1;
    gbc_comboBox_licenseType.gridy = 3;
    add(comboBox_licenseType, gbc_comboBox_licenseType);

    JLabel label_23 = new JLabel("???");
    GridBagConstraints gbc_label_23 = new GridBagConstraints();
    gbc_label_23.anchor = GridBagConstraints.EAST;
    gbc_label_23.insets = new Insets(0, 0, 5, 5);
    gbc_label_23.gridx = 0;
    gbc_label_23.gridy = 4;
    this.add(label_23, gbc_label_23);

    textField_productName = new JTextField();
    GridBagConstraints gbc_textField_productName = new GridBagConstraints();
    gbc_textField_productName.insets = new Insets(0, 0, 5, 5);
    gbc_textField_productName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_productName.gridx = 1;
    gbc_textField_productName.gridy = 4;
    this.add(textField_productName, gbc_textField_productName);
    textField_productName.setColumns(10);

    JLabel label_24 = new JLabel("???");
    GridBagConstraints gbc_label_24 = new GridBagConstraints();
    gbc_label_24.anchor = GridBagConstraints.EAST;
    gbc_label_24.insets = new Insets(0, 0, 5, 5);
    gbc_label_24.gridx = 0;
    gbc_label_24.gridy = 5;
    this.add(label_24, gbc_label_24);

    textField_companyName = new JTextField();
    GridBagConstraints gbc_textField_companyName = new GridBagConstraints();
    gbc_textField_companyName.insets = new Insets(0, 0, 5, 5);
    gbc_textField_companyName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_companyName.gridx = 1;
    gbc_textField_companyName.gridy = 5;
    this.add(textField_companyName, gbc_textField_companyName);
    textField_companyName.setColumns(10);

    JLabel label_25 = new JLabel("??");
    GridBagConstraints gbc_label_25 = new GridBagConstraints();
    gbc_label_25.anchor = GridBagConstraints.EAST;
    gbc_label_25.insets = new Insets(0, 0, 5, 5);
    gbc_label_25.gridx = 0;
    gbc_label_25.gridy = 6;
    this.add(label_25, gbc_label_25);

    textField_customerName = new JTextField();
    GridBagConstraints gbc_textField_customerName = new GridBagConstraints();
    gbc_textField_customerName.insets = new Insets(0, 0, 5, 5);
    gbc_textField_customerName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_customerName.gridx = 1;
    gbc_textField_customerName.gridy = 6;
    this.add(textField_customerName, gbc_textField_customerName);
    textField_customerName.setColumns(10);

    JLabel label_26 = new JLabel("");
    GridBagConstraints gbc_label_26 = new GridBagConstraints();
    gbc_label_26.anchor = GridBagConstraints.EAST;
    gbc_label_26.insets = new Insets(0, 0, 5, 5);
    gbc_label_26.gridx = 0;
    gbc_label_26.gridy = 7;
    this.add(label_26, gbc_label_26);

    textField_version = new JTextField();
    GridBagConstraints gbc_textField_version = new GridBagConstraints();
    gbc_textField_version.insets = new Insets(0, 0, 5, 5);
    gbc_textField_version.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_version.gridx = 1;
    gbc_textField_version.gridy = 7;
    this.add(textField_version, gbc_textField_version);
    textField_version.setColumns(10);

    JLabel label_27 = new JLabel("");
    GridBagConstraints gbc_label_27 = new GridBagConstraints();
    gbc_label_27.insets = new Insets(0, 0, 5, 5);
    gbc_label_27.gridx = 0;
    gbc_label_27.gridy = 8;
    this.add(label_27, gbc_label_27);

    datePicker_expiredDate = new DatePicker(new Date(), "yyyy-MM-dd", null, null);
    //datePicker_expiredDate.setTimePanleVisible(false);
    GridBagConstraints gbc_datePicker_expiredDate = new GridBagConstraints();
    gbc_datePicker_expiredDate.anchor = GridBagConstraints.WEST;
    gbc_datePicker_expiredDate.insets = new Insets(0, 0, 5, 5);
    gbc_datePicker_expiredDate.gridx = 1;
    gbc_datePicker_expiredDate.gridy = 8;
    this.add(datePicker_expiredDate, gbc_datePicker_expiredDate);

    JButton button_5 = new JButton("");
    button_5.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

            if (currentLicenseConfig != null) {
                try {
                    File priKeyFile = new File(currentLicenseConfig.getPriKeyFilePath());
                    File licenseFile = new File(currentLicenseConfig.getLicenseFilePath());

                    //??
                    License license = new License();
                    license.setLicenseId(textField_licenseId.getText());
                    license.setLicenseType(
                            ((MapComboBoxModel) comboBox_licenseType.getSelectedItem()).getValue().toString());
                    license.setProductName(textField_productName.getText());
                    license.setCompanyName(textField_companyName.getText());
                    license.setCustomerName(textField_customerName.getText());
                    license.setVersion(Version.parseVersion(textField_version.getText()));
                    license.setCreateDate(new Date());
                    license.setExpiredDate(Utility.parseDate(datePicker_expiredDate.getText()));

                    //????
                    DigitalSignatureTool utils = new DigitalSignatureTool("DSA");
                    utils.readPriKey(priKeyFile.getAbsolutePath()); //??
                    String signedData = utils.sign(license.toString()); //??????
                    license.setSignature(signedData);

                    LicenseManager.writeLicense(license, licenseFile);
                    //config.xml
                    String licenseContent = XmlUtils.readXml(licenseFile).asXML();
                    //DES
                    ISecurity security = new DESTool(currentLicenseConfig.getLicenseId(), Algorithm.BLOWFISH);
                    licenseContent = security.encrypt(licenseContent);

                    txt_encryptContent.setText(licenseContent);
                    currentLicenseConfig.setEncryptedLicense(licenseContent);
                    System.out.println(licenseContent);
                    File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml");

                    XMLConfiguration config = new XMLConfiguration(configFile);
                    config.setAutoSave(true);

                    config.setProperty("product.customer.encryptedLicense", licenseContent);

                    //??zip?
                    File customerPath = licenseFile.getParentFile();
                    //???license?????
                    File licensePath = new File(customerPath.getParent(), "license");
                    if (!licensePath.exists() && !licensePath.isDirectory()) {
                        licensePath.mkdir();
                    } else {
                        FileUtils.cleanDirectory(licensePath);
                    }

                    //?
                    FileUtils.copyDirectory(customerPath, licensePath);
                    String currentTime = FormatDateTime.formatDateTimeNum(new Date());
                    ZipUtils.zip(licensePath, new File(licensePath.getParentFile(),
                            currentLicenseConfig.getCustomerCode() + "-" + currentTime + ".zip"));

                    //license
                    FileUtils.deleteDirectory(licensePath);

                    JOptionPane.showMessageDialog(self, "??");
                } catch (Exception e1) {
                    e1.printStackTrace();
                    JOptionPane.showMessageDialog(self, e1.getMessage());
                }
            } else {
                JOptionPane.showMessageDialog(self, "???");
            }
        }
    });
    GridBagConstraints gbc_button_5 = new GridBagConstraints();
    gbc_button_5.insets = new Insets(0, 0, 5, 5);
    gbc_button_5.gridx = 1;
    gbc_button_5.gridy = 9;
    this.add(button_5, gbc_button_5);

    JScrollPane scrollPane = new JScrollPane();
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.gridx = 1;
    gbc_scrollPane.gridy = 10;
    this.add(scrollPane, gbc_scrollPane);

    txt_encryptContent = new JTextArea();
    txt_encryptContent.setLineWrap(true);
    scrollPane.setViewportView(txt_encryptContent);

    //      txt_encryptContent = new JTextArea(20, 20);
    //      GridBagConstraints gbc_6 = new GridBagConstraints();
    //      gbc_6.gridx = 1;
    //      gbc_6.gridy = 10;
    //      this.add(txt_encryptContent, gbc_6);

}

From source file:com.vgi.mafscaling.ClosedLoop.java

private void createAfrDataTables(JScrollPane aprScrollPane) {
    JPanel aprRunPanel = new JPanel();
    aprScrollPane.setViewportView(aprRunPanel);
    GridBagLayout gbl_aprRunPanel = new GridBagLayout();
    gbl_aprRunPanel.columnWidths = new int[] { 0, 0 };
    gbl_aprRunPanel.rowHeights = new int[] { 0, 0, 0, 0, 0 };
    gbl_aprRunPanel.columnWeights = new double[] { 0.0, 1.0 };
    gbl_aprRunPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 1.0 };
    aprRunPanel.setLayout(gbl_aprRunPanel);

    afr1Table = createAfrDataTable(aprRunPanel, Afr1TableName, 0);
    afr2Table = createAfrDataTable(aprRunPanel, Afr2TableName, 2);
}