Example usage for javax.swing.text DefaultCaret setUpdatePolicy

List of usage examples for javax.swing.text DefaultCaret setUpdatePolicy

Introduction

In this page you can find the example usage for javax.swing.text DefaultCaret setUpdatePolicy.

Prototype

public void setUpdatePolicy(int policy) 

Source Link

Document

Sets the caret movement policy on the document updates.

Usage

From source file:Main.java

/**
 * sets text of textComp without moving its caret.
 *
 * @param textComp  text component whose text needs to be set
 * @param text      text to be set. null will be treated as empty string
 *///from   w w  w. j a  va2  s  .c  o m
public static void setText(JTextComponent textComp, String text) {
    if (text == null)
        text = "";

    if (textComp.getCaret() instanceof DefaultCaret) {
        DefaultCaret caret = (DefaultCaret) textComp.getCaret();
        int updatePolicy = caret.getUpdatePolicy();
        caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
        try {
            textComp.setText(text);
        } finally {
            caret.setUpdatePolicy(updatePolicy);
        }
    } else {
        int mark = textComp.getCaret().getMark();
        int dot = textComp.getCaretPosition();
        try {
            textComp.setText(text);
        } finally {
            int len = textComp.getDocument().getLength();
            if (mark > len)
                mark = len;
            if (dot > len)
                dot = len;
            textComp.setCaretPosition(mark);
            if (dot != mark)
                textComp.moveCaretPosition(dot);
        }
    }
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    panel.setLayout(new BorderLayout());
    setContentPane(panel);//from w  w  w .ja  v a  2  s.c o  m
    JTextPane textA = new JTextPane();
    textA.setName("text");
    textA.setContentType("text/html");
    DefaultCaret caret = (DefaultCaret) textA.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    JScrollPane filler = new JScrollPane(textA, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    JTextPane textB = new JTextPane();
    textB.setName("text" + "_T");
    textB.setFont(textA.getFont());
    DefaultCaret caret_T = (DefaultCaret) textB.getCaret();
    caret_T.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    JScrollPane filler_T = new JScrollPane(textB, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    panel.add(filler, BorderLayout.NORTH);
    panel.add(filler_T, BorderLayout.CENTER);
    pack();
}

From source file:de.dakror.virtualhub.server.ServerFrame.java

public void init() {
    initFiles();/* w  w  w.ja va2 s.  com*/

    logArea = new JTextArea();
    logArea.setWrapStyleWord(true);
    logArea.setEditable(false);
    logArea.setLineWrap(true);
    DefaultCaret caret = (DefaultCaret) logArea.getCaret();
    caret.setSelectionVisible(false);
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    wrap = new JScrollPane(logArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    setContentPane(wrap);

    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("Aktionen");
    menu.add(new JMenuItem(
            new AbstractAction("Protokoll leeren", new ImageIcon(getClass().getResource("/img/trash.png"))) {
                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    logArea.setText("");
                    log("Protokoll geleert.");
                }
            }));
    menu.add(logEnabled = new JCheckBoxMenuItem("Protokoll aktiviert",
            new ImageIcon(getClass().getResource("/img/log.png")), true));
    menu.add(packetLogEnabled = new JCheckBoxMenuItem("Paketverkehr protokollieren",
            new ImageIcon(getClass().getResource("/img/traffic.png")), false));
    menu.addSeparator();
    menu.add(new JMenuItem(new AbstractAction("Backup-Einstellungen",
            new ImageIcon(getClass().getResource("/img/backup_edit.png"))) {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                BackupEditDialog.show();
            } catch (JSONException e1) {
                e1.printStackTrace();
            }
        }
    }));

    menuBar.add(menu);
    setJMenuBar(menuBar);
}

From source file:com.clank.launcher.swing.MessageLog.java

private void initComponents() {
    if (colorEnabled) {
        JTextPane text = new JTextPane() {
            @Override/*w w  w.j a  va2 s  . c  om*/
            public boolean getScrollableTracksViewportWidth() {
                return true;
            }
        };
        this.textComponent = text;
    } else {
        JTextArea text = new JTextArea();
        this.textComponent = text;
        text.setLineWrap(true);
        text.setWrapStyleWord(true);
    }

    textComponent.setFont(new JLabel().getFont());
    textComponent.setEditable(false);
    textComponent.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
    DefaultCaret caret = (DefaultCaret) textComponent.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    document = textComponent.getDocument();
    document.addDocumentListener(new LimitLinesDocumentListener(numLines, true));

    JScrollPane scrollText = new JScrollPane(textComponent);
    scrollText.setBorder(null);
    scrollText.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollText.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    add(scrollText, BorderLayout.CENTER);
}

From source file:org.astrojournal.gui.AJMainGUI.java

/**
 * Set AstroJournal jTextPane. This is the output panel.
 * /*from  w  w  w.j  a  va  2 s . co m*/
 * @return the jScrollPane containing jTextPane.
 */
private JScrollPane setJTextPane() {
    // Create the text area containing the program text output
    textPane = new JTextPane();
    // Move the JScrollPane to the bottom automatically.
    DefaultCaret caret = (DefaultCaret) textPane.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    textPane.setEditable(false);

    // Now attach the log appender necessary for redirecting the log
    // messages into the JTextPane
    JTextPaneAppender.addJTextPane(textPane);

    // Let's add a scroll pane
    return new JScrollPane(textPane);
}

From source file:com.net2plan.gui.utils.onlineSimulationPane.OnlineSimulationPane.java

private JPanel configureSimulationControlPanel() {
    pan_simulationController = new JPanel(new MigLayout("fill, insets 0 0 0 0"));
    pan_simulationController/*from www.j a  va2  s  .co m*/
            .setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Simulation controller"));

    simInfo = new JTextArea();
    simInfo.setFont(new JLabel().getFont());
    DefaultCaret caret = (DefaultCaret) simInfo.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);

    toolbar = new JToolBar();

    btn_run = new JButton("Run");
    btn_run.addActionListener(this);
    btn_run.setToolTipText("Execute the simulation [CTRL + U]");
    btn_step = new JButton("Step");
    btn_step.addActionListener(this);
    btn_step.setToolTipText("Execute the next scheduled event and pause");
    btn_pause = new JButton("Pause/Continue");
    btn_pause.addActionListener(this);
    btn_pause.setToolTipText("Pause the simulation (if active) or continue (if paused)");
    btn_stop = new JButton("Stop");
    btn_stop.addActionListener(this);
    btn_stop.setToolTipText("Stop the simulation (it cannot be resumed later)");
    btn_reset = new JButton("Reset");
    btn_reset.addActionListener(this);
    btn_reset.setToolTipText(
            "After stopping the simulation, resets the design to the initial simulation design");
    chk_refresh = new JCheckBox("Refresh");
    chk_refresh.setSelected(true);

    btn_viewEventList = new JButton("View FEL");
    btn_viewEventList.setToolTipText("View future event list (FEL)");
    btn_viewEventList.addActionListener(this);

    toolbar.setFloatable(false);
    toolbar.setRollover(true);
    toolbar.add(btn_run);
    toolbar.add(btn_step);
    toolbar.add(btn_pause);
    toolbar.add(btn_stop);
    toolbar.add(btn_reset);
    toolbar.addSeparator();
    toolbar.add(chk_refresh);
    toolbar.add(Box.createHorizontalGlue());
    toolbar.add(btn_viewEventList);

    pan_simulationController.add(toolbar, "dock north");
    pan_simulationController.add(new JScrollPane(simInfo), "grow");

    return pan_simulationController;
}

From source file:com.nwn.NwnUpdaterHomeView.java

/**
 * This method is called from within the constructor to initialize the
 * form. WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 *///from   www.  ja v  a2s.c o  m
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    btnStartUpdate = new javax.swing.JButton();
    btnClose = new javax.swing.JButton();
    cmbServerList = new javax.swing.JComboBox();
    progressBarOverall = new javax.swing.JProgressBar();
    jScrollPane2 = new javax.swing.JScrollPane();
    txtOutput = new javax.swing.JTextArea();
    DefaultCaret caret = (DefaultCaret) txtOutput.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    jLabel1 = new javax.swing.JLabel();
    btnRemoveServer = new javax.swing.JButton();
    btnAddServer = new javax.swing.JButton();
    txtNwnDir = new javax.swing.JTextField();
    jLabel2 = new javax.swing.JLabel();
    btnSelectNwnDir = new javax.swing.JButton();
    progressBarTask = new javax.swing.JProgressBar();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("NWN Server Updater");

    btnStartUpdate.setText("Update");
    btnStartUpdate.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnStartUpdateActionPerformed(evt);
        }
    });

    btnClose.setText("Close");
    btnClose.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnCloseActionPerformed(evt);
        }
    });

    txtOutput.setEditable(false);
    txtOutput.setBackground(new java.awt.Color(0, 0, 0));
    txtOutput.setColumns(20);
    txtOutput.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    txtOutput.setForeground(new java.awt.Color(0, 255, 0));
    txtOutput.setLineWrap(true);
    txtOutput.setRows(5);
    txtOutput.setText(
            "NWN Server Updater \nversion: 4.00\nBy: Skipper Warlock\nMay the work of DM Ronin stay undead forever.");
    txtOutput.setWrapStyleWord(true);
    txtOutput.setCaretColor(new java.awt.Color(0, 255, 0));
    txtOutput.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    jScrollPane2.setViewportView(txtOutput);

    jLabel1.setText("Server:");

    btnRemoveServer.setText("Remove");
    btnRemoveServer.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnRemoveServerActionPerformed(evt);
        }
    });

    btnAddServer.setText("Add");
    btnAddServer.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAddServerActionPerformed(evt);
        }
    });

    txtNwnDir.setText("C:\\NeverwinterNights\\NWN");

    jLabel2.setText("NWN Dir:");

    btnSelectNwnDir.setText("Browse");
    btnSelectNwnDir.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnSelectNwnDirActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane2)
                    .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1).addComponent(jLabel2))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup().addComponent(txtNwnDir)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(btnSelectNwnDir))
                                    .addComponent(cmbServerList, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                            layout.createSequentialGroup().addComponent(btnAddServer)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(btnRemoveServer))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(progressBarTask, javax.swing.GroupLayout.Alignment.LEADING,
                                            javax.swing.GroupLayout.PREFERRED_SIZE, 401,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(progressBarOverall, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            401, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnStartUpdate)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnClose)))
                    .addContainerGap()));

    layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { btnClose, btnStartUpdate });

    layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { btnAddServer, btnRemoveServer });

    layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { progressBarOverall, progressBarTask });

    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cmbServerList, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnRemoveServer).addComponent(btnAddServer))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNwnDir, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2).addComponent(btnSelectNwnDir))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 374,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                    .addComponent(progressBarTask, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(progressBarOverall, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(btnStartUpdate, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnClose, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    layout.linkSize(javax.swing.SwingConstants.VERTICAL,
            new java.awt.Component[] { progressBarOverall, progressBarTask });

    pack();
}

From source file:mydropbox.MyDropboxSwing.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*from w w w.  ja  v a  2s.com*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed"
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    sign_in = new javax.swing.JButton();
    log_out = new javax.swing.JButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTree1 = new javax.swing.JTree(root);
    jProgressBar1 = new javax.swing.JProgressBar();
    sync = new javax.swing.JButton();
    username = new javax.swing.JTextField();
    password = new javax.swing.JPasswordField();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    reload = new javax.swing.JButton();
    jScrollPane2 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    jLabel3 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("My Dropbox");

    sign_in.setText("Login");
    sign_in.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            sign_inActionPerformed(evt);
        }
    });

    log_out.setText("Watcher");
    log_out.setToolTipText("");
    log_out.setEnabled(false);
    log_out.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            log_outActionPerformed(evt);
        }
    });

    jScrollPane1.setEnabled(false);

    jTree1.setEnabled(false);
    javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root");
    jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
    jScrollPane1.setViewportView(jTree1);

    jProgressBar1.setEnabled(false);

    sync.setEnabled(false);
    sync.setText("Sync");

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

    jLabel1.setText("Username");

    jLabel2.setText("Password");

    reload.setEnabled(false);
    reload.setText("Reload");
    reload.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            reloadActionPerformed(evt);
        }
    });
    reload.setVisible(false);
    sync.setVisible(false);
    jTextArea1.setEnabled(false);
    jTextArea1.setColumns(20);
    jTextArea1.setRows(5);
    DefaultCaret defaultCaret = (DefaultCaret) jTextArea1.getCaret();
    defaultCaret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    jScrollPane2.setViewportView(jTextArea1);

    jLabel3.setText("History");

    jButton1.setText("Show File Delete");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    jButton2.setText("Show File Revision");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
            .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup().addGroup(layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 60,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(167, 167, 167).addComponent(jLabel2,
                                            javax.swing.GroupLayout.PREFERRED_SIZE, 58,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                    .addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, 202,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(25, 25, 25)
                                    .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, 134,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(sign_in, javax.swing.GroupLayout.PREFERRED_SIZE, 66,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18).addComponent(log_out).addGap(44, 44, 44)
                                    .addComponent(reload, javax.swing.GroupLayout.PREFERRED_SIZE, 73,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18).addComponent(sync,
                                            javax.swing.GroupLayout.PREFERRED_SIZE, 73,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGap(39, 39, 39)
                            .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 152,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(62, 89, Short.MAX_VALUE))
                    .addGroup(
                            layout.createSequentialGroup().addComponent(jLabel3).addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane2).addComponent(jScrollPane1)))
            .addGroup(layout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton1).addGap(18, 18, 18).addComponent(jButton2).addGap(142, 142, 142)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel1).addComponent(jLabel2))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(sign_in).addComponent(log_out)
                                    .addComponent(reload, javax.swing.GroupLayout.PREFERRED_SIZE, 33,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(sync, javax.swing.GroupLayout.PREFERRED_SIZE, 33,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup().addGap(34, 34, 34).addComponent(jProgressBar1,
                            javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 99,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel3)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 259,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton1).addComponent(jButton2))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    setBounds(0, 0, 900, 534);
}

From source file:e3fraud.gui.MainWindow.java

public MainWindow() {
    super(new BorderLayout(5, 5));

    extended = false;/*  www . j  a v a 2 s. c o m*/

    //Create the log first, because the action listeners
    //need to refer to it.
    log = new JTextArea(10, 50);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);
    logScrollPane = new JScrollPane(log);
    DefaultCaret caret = (DefaultCaret) log.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    //        create the progress bar
    progressBar = new JProgressBar(0, 100);
    progressBar.setValue(progressBar.getMinimum());
    progressBar.setVisible(false);
    progressBar.setStringPainted(true);
    //Create the settings pane
    generationSettingLabel = new JLabel("Generate:");
    SpinnerModel collusionsSpinnerModel = new SpinnerNumberModel(1, 0, 3, 1);
    collusionSettingsPanel = new JPanel(new FlowLayout()) {
        @Override
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    // collusionSettingsPanel.setLayout(new BoxLayout(collusionSettingsPanel, BoxLayout.X_AXIS));
    collusionsButton = new JSpinner(collusionsSpinnerModel);
    collusionsLabel = new JLabel("collusion(s)");
    collusionSettingsPanel.add(collusionsButton);
    collusionSettingsPanel.add(collusionsLabel);

    rankingSettingLabel = new JLabel("Rank by:");
    lossButton = new JRadioButton("loss");
    lossButton.setToolTipText("Sort sub-ideal models based on loss for Target of Assessment (high -> low)");
    gainButton = new JRadioButton("gain");
    gainButton.setToolTipText(
            "Sort sub-ideal models based on gain of any actor except Target of Assessment (high -> low)");
    lossGainButton = new JRadioButton("loss + gain");
    lossGainButton.setToolTipText(
            "Sort sub-ideal models based on loss for Target of Assessment and, if equal, on gain of any actor except Target of Assessment");
    //gainLossButton = new JRadioButton("gain + loss");
    lossGainButton.setSelected(true);
    rankingGroup = new ButtonGroup();
    rankingGroup.add(lossButton);
    rankingGroup.add(gainButton);
    rankingGroup.add(lossGainButton);
    //rankingGroup.add(gainLossButton);
    groupingSettingLabel = new JLabel("Group by:");
    groupingButton = new JCheckBox("collusion");
    groupingButton.setToolTipText(
            "Groups sub-ideal models based on the pair of actors colluding before ranking them");
    groupingButton.setSelected(false);
    refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(this);

    settingsPanel = new JPanel();
    settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS));
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(generationSettingLabel);
    collusionSettingsPanel.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(collusionSettingsPanel);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    rankingSettingLabel.setAlignmentY(TOP_ALIGNMENT);
    settingsPanel.add(rankingSettingLabel);
    settingsPanel.add(lossButton);
    settingsPanel.add(gainButton);
    settingsPanel.add(lossGainButton);
    //settingsPanel.add(gainLossButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(groupingSettingLabel);
    settingsPanel.add(groupingButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(refreshButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 20)));
    progressBar.setPreferredSize(
            new Dimension(settingsPanel.getSize().width, progressBar.getPreferredSize().height));
    settingsPanel.add(progressBar);

    //Create the result tree
    root = new DefaultMutableTreeNode("No models to display");
    treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel);
    //tree.setUI(new CustomTreeUI());
    tree.setCellRenderer(new CustomTreeCellRenderer(tree));
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setLargeModel(true);
    resultScrollPane = new JScrollPane(tree);
    tree.addTreeSelectionListener(treeSelectionListener);

    //tree.setShowsRootHandles(true);
    //Create a file chooser for saving
    sfc = new JFileChooser();
    FileFilter jpegFilter = new FileNameExtensionFilter("JPEG image", new String[] { "jpg", "jpeg" });
    sfc.addChoosableFileFilter(jpegFilter);
    sfc.setFileFilter(jpegFilter);

    //Create a file chooser for loading
    fc = new JFileChooser();
    FileFilter rdfFilter = new FileNameExtensionFilter("RDF file", "RDF");
    fc.addChoosableFileFilter(rdfFilter);
    fc.setFileFilter(rdfFilter);

    //Create the open button.  
    openButton = new JButton("Load model", createImageIcon("images/Open24.png"));
    openButton.addActionListener(this);
    openButton.setToolTipText("Load a e3value model");

    //Create the ideal graph button. 
    idealGraphButton = new JButton("Show ideal graph", createImageIcon("images/Plot.png"));
    idealGraphButton.setToolTipText("Display ideal profitability graph");
    idealGraphButton.addActionListener(this);

    Dimension thinButtonDimension = new Dimension(15, 420);

    //Create the expand subideal graph button. 
    expandButton = new JButton(">");
    expandButton.setPreferredSize(thinButtonDimension);
    expandButton.setMargin(new Insets(0, 0, 0, 0));
    expandButton.setToolTipText("Expand to show non-ideal profitability graph for selected model");
    expandButton.addActionListener(this);

    //Create the collapse sub-ideal graph button. 
    collapseButton = new JButton("<");
    collapseButton.setPreferredSize(thinButtonDimension);
    collapseButton.setMargin(new Insets(0, 0, 0, 0));
    collapseButton.setToolTipText("Collapse non-ideal profitability graph for selected model");
    collapseButton.addActionListener(this);

    //Create the generation button. 
    generateButton = new JButton("Generate sub-ideal models", createImageIcon("images/generate.png"));
    generateButton.addActionListener(this);
    generateButton.setToolTipText("Generate sub-ideal models for the e3value model currently loaded");

    //Create the chart panel
    chartPane = new JPanel();
    chartPane.setLayout(new FlowLayout(FlowLayout.LEFT));
    chartPane.add(expandButton);

    //For layout purposes, put the buttons in a separate panel
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(openButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(20, 0)));
    buttonPanel.add(generateButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPanel.add(idealGraphButton);

    //Add the buttons, the ranking options, the result list and the log to this panel.
    add(buttonPanel, BorderLayout.PAGE_START);
    add(settingsPanel, BorderLayout.LINE_START);
    add(resultScrollPane, BorderLayout.CENTER);

    add(logScrollPane, BorderLayout.PAGE_END);
    add(chartPane, BorderLayout.LINE_END);
    //and make a nice border around it
    setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));
}

From source file:com.mirth.connect.client.ui.NotificationDialog.java

private void initComponents() {
    setLayout(new MigLayout("insets 12", "[]", "[fill][]"));

    notificationPanel = new JPanel();
    notificationPanel.setLayout(new MigLayout("insets 0 0 0 0, fill", "[200!][]", "[25!]0[]"));
    notificationPanel.setBackground(UIConstants.BACKGROUND_COLOR);

    archiveAll = new JLabel("Archive All");
    archiveAll.setForeground(java.awt.Color.blue);
    archiveAll.setText("<html><u>Archive All</u></html>");
    archiveAll.setToolTipText("Archive all notifications below.");
    archiveAll.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

    newNotificationsLabel = new JLabel();
    newNotificationsLabel.setFont(newNotificationsLabel.getFont().deriveFont(Font.BOLD));
    headerListPanel = new JPanel();
    headerListPanel.setBackground(UIConstants.HIGHLIGHTER_COLOR);
    headerListPanel.setLayout(new MigLayout("insets 2, fill"));
    headerListPanel.setBorder(BorderFactory.createLineBorder(borderColor));

    list = new JList();
    list.setCellRenderer(new NotificationListCellRenderer());
    list.addListSelectionListener(new ListSelectionListener() {
        @Override//w w w. ja  v  a2  s  .c o m
        public void valueChanged(ListSelectionEvent event) {
            if (!event.getValueIsAdjusting()) {
                currentNotification = (Notification) list.getSelectedValue();
                if (currentNotification != null) {
                    notificationNameTextField.setText(currentNotification.getName());
                    contentTextPane.setText(currentNotification.getContent());
                    archiveSelected();
                }
            }
        }
    });
    listScrollPane = new JScrollPane();
    listScrollPane.setBackground(UIConstants.BACKGROUND_COLOR);
    listScrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, borderColor));
    listScrollPane.setViewportView(list);
    listScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    archiveLabel = new JLabel();
    archiveLabel.setForeground(java.awt.Color.blue);
    archiveLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

    notificationNameTextField = new JTextField();
    notificationNameTextField.setFont(notificationNameTextField.getFont().deriveFont(Font.BOLD));
    notificationNameTextField.setEditable(false);
    notificationNameTextField.setFocusable(false);
    notificationNameTextField.setBorder(BorderFactory.createEmptyBorder());
    notificationNameTextField.setBackground(UIConstants.HIGHLIGHTER_COLOR);
    DefaultCaret nameCaret = (DefaultCaret) notificationNameTextField.getCaret();
    nameCaret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    headerContentPanel = new JPanel();
    headerContentPanel.setLayout(new MigLayout("insets 2, fill"));
    headerContentPanel.setBorder(BorderFactory.createLineBorder(borderColor));
    headerContentPanel.setBackground(UIConstants.HIGHLIGHTER_COLOR);

    contentTextPane = new JTextPane();
    contentTextPane.setContentType("text/html");
    contentTextPane.setEditable(false);
    contentTextPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            if (evt.getEventType() == EventType.ACTIVATED && Desktop.isDesktopSupported()) {
                try {
                    if (Desktop.isDesktopSupported()) {
                        Desktop.getDesktop().browse(evt.getURL().toURI());
                    } else {
                        BareBonesBrowserLaunch.openURL(evt.getURL().toString());
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    });
    DefaultCaret contentCaret = (DefaultCaret) contentTextPane.getCaret();
    contentCaret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    contentScrollPane = new JScrollPane();
    contentScrollPane.setViewportView(contentTextPane);
    contentScrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, borderColor));

    archiveLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            int index = list.getSelectedIndex();
            if (currentNotification.isArchived()) {
                notificationModel.setArchived(false, index);
                unarchivedCount++;
            } else {
                notificationModel.setArchived(true, index);
                unarchivedCount--;
            }
            archiveSelected();
            updateUnarchivedCountLabel();
        }
    });

    archiveAll.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            for (int i = 0; i < notificationModel.getSize(); i++) {
                notificationModel.setArchived(true, i);
            }
            unarchivedCount = 0;
            archiveSelected();
            updateUnarchivedCountLabel();
        }
    });

    notificationCheckBox = new JCheckBox("Show new notifications on login");
    notificationCheckBox.setBackground(UIConstants.BACKGROUND_COLOR);

    if (checkForNotifications == null || BooleanUtils.toBoolean(checkForNotifications)) {
        checkForNotificationsSetting = true;
        if (showNotificationPopup == null || BooleanUtils.toBoolean(showNotificationPopup)) {
            notificationCheckBox.setSelected(true);
        } else {
            notificationCheckBox.setSelected(false);
        }
    } else {
        notificationCheckBox.setSelected(false);
    }

    notificationCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (notificationCheckBox.isSelected() && !checkForNotificationsSetting) {
                alertSettingsChange();
            }
        }
    });

    closeButton = new JButton("Close");
    closeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doSave();
        }
    });

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            doSave();
        }
    });
}