Example usage for javax.swing BoxLayout X_AXIS

List of usage examples for javax.swing BoxLayout X_AXIS

Introduction

In this page you can find the example usage for javax.swing BoxLayout X_AXIS.

Prototype

int X_AXIS

To view the source code for javax.swing BoxLayout X_AXIS.

Click Source Link

Document

Specifies that components should be laid out left to right.

Usage

From source file:me.philnate.textmanager.windows.MainWindow.java

/**
 * Initialize the contents of the frame.
 */// ww  w . j  a va 2s  .co  m
private void initialize() {
    changeListener = new ChangeListener();

    frame = new JFrame();
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            Starter.shutdown();
        }
    });
    frame.setBounds(100, 100, 1197, 500);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(new MigLayout("", "[grow]", "[][grow][::16px]"));

    customers = new CustomerComboBox();
    customers.addItemListener(changeListener);

    frame.getContentPane().add(customers, "flowx,cell 0 0,growx");

    jScrollPane = new JScrollPane();
    billLines = new BillingItemTable(frame, true);

    jScrollPane.setViewportView(billLines);
    frame.getContentPane().add(jScrollPane, "cell 0 1,grow");

    // for each file added through drag&drop create a new lineItem
    new FileDrop(jScrollPane, new FileDrop.Listener() {

        @Override
        public void filesDropped(File[] files) {
            for (File file : files) {
                addNewBillingItem(Document.loadAndSave(file));
            }
        }
    });

    monthChooser = new JMonthChooser();
    monthChooser.addPropertyChangeListener(changeListener);
    frame.getContentPane().add(monthChooser, "cell 0 0");

    yearChooser = new JYearChooser();
    yearChooser.addPropertyChangeListener(changeListener);
    frame.getContentPane().add(yearChooser, "cell 0 0");

    JButton btnAddLine = new JButton();
    btnAddLine.setIcon(ImageRegistry.getImage("load.gif"));
    btnAddLine.setToolTipText(getCaption("mw.tooltip.add"));
    btnAddLine.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            addNewBillingItem();
        }
    });

    frame.getContentPane().add(btnAddLine, "cell 0 0");

    JButton btnMassAdd = new JButton();
    btnMassAdd.setIcon(ImageRegistry.getImage("load_all.gif"));
    btnMassAdd.setToolTipText(getCaption("mw.tooltip.massAdd"));
    btnMassAdd.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser file = new DocXFileChooser();
            switch (file.showOpenDialog(frame)) {
            case JFileChooser.APPROVE_OPTION:
                File[] files = file.getSelectedFiles();
                if (null != files) {
                    for (File fl : files) {
                        addNewBillingItem(Document.loadAndSave(fl));
                    }
                }
                break;
            default:
                return;
            }
        }
    });

    frame.getContentPane().add(btnMassAdd, "cell 0 0");

    billNo = new JTextField();
    // enable/disable build button based upon text in billNo
    billNo.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent arg0) {
            setButtonStates();
        }

        @Override
        public void insertUpdate(DocumentEvent arg0) {
            setButtonStates();
        }

        @Override
        public void changedUpdate(DocumentEvent arg0) {
            setButtonStates();
        }

        private void setButtonStates() {
            boolean notBlank = StringUtils.isNotBlank(billNo.getText());
            build.setEnabled(notBlank);
            view.setEnabled(pdf.find(billNo.getText() + ".pdf").size() == 1);
        }
    });
    frame.getContentPane().add(billNo, "cell 0 0");
    billNo.setColumns(10);

    build = new JButton();
    build.setEnabled(false);// disable build Button until there's some
    // billNo entered
    build.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (runningThread == null) {
                try {
                    // check that billNo isn't empty or already used within
                    // another Bill
                    if (billNo.getText().trim().equals("")) {
                        JOptionPane.showMessageDialog(frame, getCaption("mw.dialog.error.billNoBlank.msg"),
                                getCaption("mw.dialog.error.billNoBlank.title"), JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                    try {
                        bill.setBillNo(billNo.getText()).save();
                    } catch (DuplicateKey e) {
                        // unset the internal value as this is already used
                        bill.setBillNo("");
                        JOptionPane.showMessageDialog(frame,
                                format(getCaption("mw.error.billNoUsed.msg"), billNo.getText()),
                                getCaption("mw.dialog.error.billNoBlank.title"), JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                    PDFCreator pdf = new PDFCreator(bill);
                    pdf.addListener(new ThreadCompleteListener() {

                        @Override
                        public void threadCompleted(NotifyingThread notifyingThread) {
                            build.setToolTipText(getCaption("mw.tooltip.build"));
                            build.setIcon(ImageRegistry.getImage("build.png"));
                            runningThread = null;
                            view.setEnabled(DB.pdf.find(billNo.getText() + ".pdf").size() == 1);
                        }
                    });
                    runningThread = new Thread(pdf);
                    runningThread.start();
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                build.setToolTipText(getCaption("mw.tooltip.build.cancel"));
                build.setIcon(ImageRegistry.getImage("cancel.gif"));
            } else {
                runningThread.interrupt();
                runningThread = null;
                build.setToolTipText(getCaption("mw.tooltip.build"));
                build.setIcon(ImageRegistry.getImage("build.png"));

            }
        }
    });
    build.setToolTipText(getCaption("mw.tooltip.build"));
    build.setIcon(ImageRegistry.getImage("build.png"));
    frame.getContentPane().add(build, "cell 0 0");

    view = new JButton();
    view.setToolTipText(getCaption("mw.tooltip.view"));
    view.setIcon(ImageRegistry.getImage("view.gif"));
    view.setEnabled(false);
    view.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            File file = new File(System.getProperty("user.dir"),
                    format("template/%s.tmp.pdf", billNo.getText()));
            try {
                pdf.findOne(billNo.getText() + ".pdf").writeTo(file);
                new ProcessBuilder(Setting.find("pdfViewer").getValue(), file.getAbsolutePath()).start()
                        .waitFor();
                file.delete();
            } catch (IOException | InterruptedException e1) {
                // TODO Auto-generated catch block
                LOG.warn("Error while building PDF", e1);
            }
        }
    });
    frame.getContentPane().add(view, "cell 0 0");

    statusBar = new JPanel();
    statusBar.setBorder(new BevelBorder(BevelBorder.LOWERED));
    statusBar.setLayout(new BoxLayout(statusBar, BoxLayout.X_AXIS));
    GitRepositoryState state = DB.state;
    JLabel statusLabel = new JLabel(String.format("textManager Version v%s build %s",
            state.getCommitIdDescribe(), state.getBuildTime()));
    statusLabel.setHorizontalAlignment(SwingConstants.LEFT);
    statusBar.add(statusLabel);
    frame.add(statusBar, "cell 0 2,growx");

    JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);

    JMenu menu = new JMenu(getCaption("mw.menu.edit"));
    JMenuItem itemCust = new JMenuItem(getCaption("mw.menu.edit.customer"));
    itemCust.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            new CustomerWindow(customers);
        }
    });
    menu.add(itemCust);

    JMenuItem itemSetting = new JMenuItem(getCaption("mw.menu.edit.settings"));
    itemSetting.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            new SettingWindow();
        }
    });
    menu.add(itemSetting);

    JMenuItem itemImport = new JMenuItem(getCaption("mw.menu.edit.import"));
    itemImport.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            new ImportWindow(new ImportListener() {

                @Override
                public void entriesImported(List<BillingItem> items) {
                    for (BillingItem item : items) {
                        item.setCustomerId(customers.getSelectedCustomer().getId())
                                .setMonth(monthChooser.getMonth()).setYear(yearChooser.getYear());
                        item.save();
                        billLines.addRow(item);
                    }
                }
            }, frame);
        }
    });
    menu.add(itemImport);

    menuBar.add(menu);

    customers.loadCustomer();
    fillTableModel();
}

From source file:de.adv_online.aaa.profiltool.ProfilDialog.java

private Component createMainTab() {

    String s;//  w ww  .  j  a  va2 s. c o  m

    String appSchemaStr;
    s = options.parameter("appSchemaName");
    if (s != null && s.trim().length() > 0)
        appSchemaStr = s.trim();
    else
        appSchemaStr = "";

    String mart;
    s = options.parameter(paramProfilClass, "Modellart");
    if (s != null && s.trim().length() > 0)
        mart = s.trim();
    else
        mart = "";

    String profil;
    s = options.parameter(paramProfilClass, "Profil");
    if (s != null && s.trim().length() > 0)
        profil = s.trim();
    else
        profil = "";

    String quelle;
    s = options.parameter(paramProfilClass, "Quelle");
    if (s != null && s.trim().length() > 0)
        quelle = s.trim();
    else
        quelle = "Neu_Minimal";

    String ziel;
    s = options.parameter(paramProfilClass, "Ziel");
    if (s != null && s.trim().length() > 0)
        ziel = s.trim();
    else
        ziel = "Datei";

    String pfadStr;
    s = options.parameter(paramProfilClass, "Verzeichnis");
    if (s == null || s.trim().length() == 0)
        pfadStr = "";
    else {
        File f = new File(s.trim());
        if (f.exists())
            pfadStr = f.getAbsolutePath();
        else
            pfadStr = "";
    }

    String mdlDirStr = eap;

    final JPanel topPanel = new JPanel();
    final JPanel topInnerPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 30, 5));
    topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS));
    topPanel.setBorder(BorderFactory.createEmptyBorder(15, 20, 15, 10));

    // Anwendungsschema

    appSchemaField = new JTextField(35);
    appSchemaField.setText(appSchemaStr);
    appSchemaFieldLabel = new JLabel("Name des zu prozessierenden Anwendungsschemas:");

    Box asBox = Box.createVerticalBox();
    asBox.add(appSchemaFieldLabel);
    asBox.add(appSchemaField);

    modellartField = new JTextField(10);
    modellartField.setText(mart);
    modellartFieldLabel = new JLabel("Modellart:");

    asBox.add(modellartFieldLabel);
    asBox.add(modellartField);

    profilField = new JTextField(10);
    profilField.setText(profil);
    profilFieldLabel = new JLabel("Profilkennung:");

    asBox.add(profilFieldLabel);
    asBox.add(profilField);

    topInnerPanel.add(asBox);
    topPanel.add(topInnerPanel);

    // Quelle

    Box quelleBox = Box.createVerticalBox();

    final JPanel quellePanel = new JPanel(new GridLayout(4, 1));
    quelleGroup = new ButtonGroup();
    rbq3ap = new JRadioButton("3ap-Datei");
    quellePanel.add(rbq3ap);
    if (quelle.equals("Datei"))
        rbq3ap.setSelected(true);
    rbq3ap.setActionCommand("Datei");
    quelleGroup.add(rbq3ap);
    rbqtv = new JRadioButton("'AAA:Profile' Tagged Values in Modell");
    quellePanel.add(rbqtv);
    if (quelle.equals("Modell"))
        rbqtv.setSelected(true);
    rbqtv.setActionCommand("Modell");
    quelleGroup.add(rbqtv);
    rbqmin = new JRadioButton("Neues Minimalprofil erzeugen");
    quellePanel.add(rbqmin);
    if (quelle.equals("Neu_Minimal"))
        rbqmin.setSelected(true);
    rbqmin.setActionCommand("Neu_Minimal");
    quelleGroup.add(rbqmin);
    rbqmax = new JRadioButton("Neues Maximalprofil erzeugen");
    quellePanel.add(rbqmax);
    if (quelle.equals("Neu_Maximal"))
        rbqmax.setSelected(true);
    rbqmax.setActionCommand("Neu_Maximal");
    quelleGroup.add(rbqmax);
    quelleBorder = new TitledBorder(new LineBorder(Color.black), "Quelle der Profildefinition",
            TitledBorder.LEFT, TitledBorder.TOP);
    quellePanel.setBorder(quelleBorder);

    quelleBox.add(quellePanel);

    Box zielBox = Box.createVerticalBox();

    final JPanel zielPanel = new JPanel(new GridLayout(4, 1));
    zielGroup = new ButtonGroup();
    rbz3ap = new JRadioButton("3ap-Datei");
    zielPanel.add(rbz3ap);
    if (ziel.equals("Datei"))
        rbz3ap.setSelected(true);
    rbz3ap.setActionCommand("Datei");
    zielGroup.add(rbz3ap);
    rbztv = new JRadioButton("'AAA:Profile' Tagged Values in Modell");
    zielPanel.add(rbztv);
    if (ziel.equals("Modell"))
        rbztv.setSelected(true);
    rbztv.setActionCommand("Modell");
    zielGroup.add(rbztv);
    rbzbeide = new JRadioButton("Beides");
    zielPanel.add(rbzbeide);
    if (ziel.equals("DateiModell"))
        rbzbeide.setSelected(true);
    rbzbeide.setActionCommand("DateiModell");
    zielGroup.add(rbzbeide);
    rbzdel = new JRadioButton("Profilkennung wird aus Modell entfernt");
    zielPanel.add(rbzdel);
    if (ziel.equals("Ohne"))
        rbzdel.setSelected(true);
    rbzdel.setActionCommand("Ohne");
    zielGroup.add(rbzdel);
    zielBorder = new TitledBorder(new LineBorder(Color.black), "Ziel der Profildefinition", TitledBorder.LEFT,
            TitledBorder.TOP);
    zielPanel.setBorder(zielBorder);

    zielBox.add(zielPanel);

    // Pfadangaben

    Box pfadBox = Box.createVerticalBox();
    final JPanel pfadInnerPanel = new JPanel();
    Box skBox = Box.createVerticalBox();

    pfadFieldLabel = new JLabel("Pfad in dem 3ap-Dateien liegen/geschrieben werden:");
    skBox.add(pfadFieldLabel);
    pfadField = new JTextField(40);
    pfadField.setText(pfadStr);
    skBox.add(pfadField);

    mdlDirFieldLabel = new JLabel("Pfad zum Modell:");
    skBox.add(mdlDirFieldLabel);
    mdlDirField = new JTextField(40);
    mdlDirField.setText(mdlDirStr);
    skBox.add(mdlDirField);

    pfadInnerPanel.add(skBox);
    pfadBox.add(pfadInnerPanel);

    final JPanel pfadPanel = new JPanel();
    pfadPanel.add(pfadBox);
    pfadPanel.setBorder(
            new TitledBorder(new LineBorder(Color.black), "Pfadangaben", TitledBorder.LEFT, TitledBorder.TOP));

    // Zusammenstellung
    Box fileBox = Box.createVerticalBox();
    fileBox.add(topPanel);
    fileBox.add(quellePanel);
    fileBox.add(zielPanel);
    fileBox.add(pfadPanel);

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(fileBox, BorderLayout.NORTH);

    if (profil.isEmpty()) {
        setModellartOnly = true;
        disableProfileElements();
    }

    // Listen for changes in the profilkennung
    profilField.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            upd();
        }

        public void removeUpdate(DocumentEvent e) {
            upd();
        }

        public void insertUpdate(DocumentEvent e) {
            upd();
        }

        public void upd() {
            if (!setModellartOnly && profilField.getText().isEmpty()) {
                setModellartOnly = true;
                disableProfileElements();
            } else if (setModellartOnly && !profilField.getText().isEmpty()) {
                setModellartOnly = false;
                enableProfileElements();
            }
        }
    });

    return panel;
}

From source file:com.archivas.clienttools.arcmover.gui.panels.ProfilePanel.java

private void initGuiComponents() {
    fileListModel = new FileListTableModel();
    fileList = new FileListTable(fileListModel);
    fileList.addKeyListener(new KeyAdapter() {
        @Override//  ww  w  . ja v a2 s  .  c  om
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                openSelectedFile();
                e.consume();
            }
        }
    });
    fileList.setAutoCreateColumnsFromModel(true);
    fileList.setDropMode(DropMode.ON_OR_INSERT_ROWS);
    fileList.setFillsViewportHeight(true);
    fileList.setGridColor(new Color(-1));

    fileListScrollPane = new JScrollPane(fileList);
    fileListScrollPane.setAutoscrolls(false);
    fileListScrollPane.setBackground(UIManager.getColor("TableHeader.background"));
    fileListScrollPane.setPreferredSize(new Dimension(100, 128));
    fileListScrollPane.setEnabled(false);

    //
    // toolbar
    //

    final JToolBar toolBar1 = new JToolBar();
    toolBar1.setBorderPainted(false);
    toolBar1.setFloatable(false);
    toolBar1.setRollover(true);
    toolBar1.putClientProperty("JToolBar.isRollover", Boolean.TRUE);

    homeDirectoryButton = new JButton();
    homeDirectoryButton.setHorizontalAlignment(2);
    homeDirectoryButton.setIcon(GUIHelper.HOME_ICON);
    homeDirectoryButton.setMargin(new Insets(3, 3, 3, 3));
    homeDirectoryButton.setText("");
    homeDirectoryButton.setToolTipText("Go to home directory");
    homeDirectoryButton.setEnabled(false);
    toolBar1.add(homeDirectoryButton);

    refreshButton = new JButton();
    refreshButton.setHorizontalAlignment(2);
    refreshButton.setIcon(new ImageIcon(getClass().getResource("/images/refresh.gif")));
    refreshButton.setMargin(new Insets(3, 3, 3, 3));
    refreshButton.setText("");
    refreshButton.setToolTipText("Refresh current directory listing");
    refreshButton.setEnabled(false);
    toolBar1.add(refreshButton);

    upDirectoryButton = new JButton();
    upDirectoryButton.setHideActionText(false);
    upDirectoryButton.setHorizontalAlignment(2);
    upDirectoryButton.setIcon(GUIHelper.UP_DIR_ICON);
    upDirectoryButton.setMargin(new Insets(3, 3, 3, 3));
    upDirectoryButton.setToolTipText("Up");
    upDirectoryButton.setEnabled(false);
    toolBar1.add(upDirectoryButton);

    browseDirectoryButton = new JButton();
    browseDirectoryButton.setHideActionText(false);
    browseDirectoryButton.setHorizontalAlignment(2);
    browseDirectoryButton.setIcon(GUIHelper.DIRECTORY_ICON);
    browseDirectoryButton.setMargin(new Insets(3, 3, 3, 3));
    browseDirectoryButton.setToolTipText(BROWSE_LFS_TEXT);
    browseDirectoryButton.setEnabled(false);
    toolBar1.add(browseDirectoryButton);

    profileModel = new ProfileComboBoxModel();
    profileSelectionCombo = new JComboBox(profileModel);
    profileSelectionCombo.setEnabled(false);
    profileSelectionCombo.setToolTipText("Select a namespace profile");
    profileSelectionCombo.setPrototypeDisplayValue("#");

    pathCombo = new JComboBox();
    pathCombo.setEditable(false);
    pathCombo.setEnabled(false);
    pathCombo.setToolTipText("Current directory path");
    pathCombo.setPrototypeDisplayValue("#");

    sslButton = new JButton();
    sslButton.setAlignmentY(0.0f);
    sslButton.setBorderPainted(false);
    sslButton.setHorizontalAlignment(2);
    sslButton.setHorizontalTextPosition(11);
    sslButton.setIcon(new ImageIcon(getClass().getResource("/images/lockedstate.gif")));
    sslButton.setMargin(new Insets(0, 0, 0, 0));
    sslButton.setMaximumSize(new Dimension(20, 20));
    sslButton.setMinimumSize(new Dimension(20, 20));
    sslButton.setPreferredSize(new Dimension(20, 20));
    sslButton.setText("");
    sslButton.setToolTipText("View certificate");
    sslButton.setEnabled(false);

    //
    // profile and toolbar buttons
    //
    JPanel profileAndToolbarPanel = new FixedHeightPanel();
    profileAndToolbarPanel.setLayout(new BoxLayout(profileAndToolbarPanel, BoxLayout.X_AXIS));
    profileAndToolbarPanel.add(profileSelectionCombo);
    profileAndToolbarPanel.add(Box.createHorizontalStrut(25));
    profileAndToolbarPanel.add(toolBar1);

    //
    // Path & SSLCert button
    //
    JPanel pathPanel = new FixedHeightPanel();
    pathPanel.setLayout(new BoxLayout(pathPanel, BoxLayout.X_AXIS));
    pathCombo.setAlignmentY(CENTER_ALIGNMENT);
    pathPanel.add(pathCombo);
    pathPanel.add(Box.createHorizontalStrut(5));
    sslButton.setAlignmentY(CENTER_ALIGNMENT);
    pathPanel.add(sslButton);

    //
    // Put it all together
    //
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    add(profileAndToolbarPanel);
    add(Box.createVerticalStrut(5));
    add(pathPanel);
    add(Box.createVerticalStrut(5));
    add(fileListScrollPane);
    setBorder(new EmptyBorder(12, 12, 12, 12));
}

From source file:lol.search.RankedStatsPage.java

private JPanel bodyPanel(JPanel body) {
    body.setLayout(new BoxLayout(body, BoxLayout.X_AXIS));
    body.setBackground(backgroundColor);
    body.setPreferredSize(new Dimension(1200, 530));

    //load art /*from   w  w  w.j av  a2s .  c  om*/
    this.loadArtLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.loadArtLabel.setPreferredSize(new Dimension(290, 504));
    this.loadArtLabel.setIcon(OBJ_GAME_STATIC_DATA.initLoadingArt(champKeyList.get(0)));
    body.add(this.loadArtLabel);

    JPanel rightPanel = new JPanel(new FlowLayout());
    rightPanel.setPreferredSize(new Dimension(800, 514));
    rightPanel.setOpaque(false);
    //rightPanel.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));

    JPanel headerPanel = new JPanel();
    headerPanel.setLayout(new BoxLayout(headerPanel, BoxLayout.X_AXIS));
    headerPanel.setPreferredSize(new Dimension(910, 55));
    headerPanel.setOpaque(false);
    //headerPanel.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    this.defaultHeader.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 40)); //custom font
    this.defaultHeader.setForeground(Color.WHITE);
    this.defaultHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.defaultHeader.setText(" Season Totals: ");
    this.nameHeader.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 40)); //custom font
    this.nameHeader.setForeground(valueOrange);
    this.nameHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.nameHeader.setText("Overall");
    this.titleHeader.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 16)); //custom font
    this.titleHeader.setForeground(new Color(255, 128, 0));
    this.titleHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    //nameHeader.setAlignmentY(Component.TOP_ALIGNMENT);
    titleHeader.setAlignmentY(Component.TOP_ALIGNMENT);
    headerPanel.add(defaultHeader);
    headerPanel.add(nameHeader);
    headerPanel.add(titleHeader);
    rightPanel.add(headerPanel);
    rightPanel.add(statsPanel());
    body.add(rightPanel);

    return body;
}

From source file:edu.brown.gui.CatalogViewer.java

/**
 * //from  w w w  . ja  v a 2s.c o m
 */
protected void viewerInit() {
    // ----------------------------------------------
    // MENU
    // ----------------------------------------------
    JMenu menu;
    JMenuItem menuItem;

    // 
    // File Menu
    //
    menu = new JMenu("File");
    menu.getPopupMenu().setLightWeightPopupEnabled(false);
    menu.setMnemonic(KeyEvent.VK_F);
    menu.getAccessibleContext().setAccessibleDescription("File Menu");
    menuBar.add(menu);

    menuItem = new JMenuItem("Open Catalog From File");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From File");
    menuItem.addActionListener(this.menuHandler);
    menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_FILE);
    menu.add(menuItem);

    menuItem = new JMenuItem("Open Catalog From Jar");
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From Project Jar");
    menuItem.addActionListener(this.menuHandler);
    menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_JAR);
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem("Quit", KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Quit Program");
    menuItem.addActionListener(this.menuHandler);
    menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.QUIT);
    menu.add(menuItem);

    // ----------------------------------------------
    // CATALOG TREE PANEL
    // ----------------------------------------------
    this.catalogTree = new JTree();
    this.catalogTree.setEditable(false);
    this.catalogTree.setCellRenderer(new CatalogViewer.CatalogTreeRenderer());
    this.catalogTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    this.catalogTree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) CatalogViewer.this.catalogTree
                    .getLastSelectedPathComponent();
            if (node == null)
                return;

            Object user_obj = node.getUserObject();
            String new_text = ""; // <html>";
            boolean text_mode = true;
            if (user_obj instanceof WrapperNode) {
                CatalogType catalog_obj = ((WrapperNode) user_obj).getCatalogType();
                new_text += CatalogViewer.this.getAttributesText(catalog_obj);
            } else if (user_obj instanceof AttributesNode) {
                AttributesNode wrapper = (AttributesNode) user_obj;
                new_text += wrapper.getAttributes();

            } else if (user_obj instanceof PlanTreeCatalogNode) {
                final PlanTreeCatalogNode wrapper = (PlanTreeCatalogNode) user_obj;
                text_mode = false;

                CatalogViewer.this.mainPanel.remove(0);
                CatalogViewer.this.mainPanel.add(wrapper.getPanel(), BorderLayout.CENTER);
                CatalogViewer.this.mainPanel.validate();
                CatalogViewer.this.mainPanel.repaint();

                if (SwingUtilities.isEventDispatchThread() == false) {
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            wrapper.centerOnRoot();
                        }
                    });
                } else {
                    wrapper.centerOnRoot();
                }

            } else {
                new_text += CatalogViewer.this.getSummaryText();
            }

            // Text Mode
            if (text_mode) {
                if (CatalogViewer.this.text_mode == false) {
                    CatalogViewer.this.mainPanel.remove(0);
                    CatalogViewer.this.mainPanel.add(CatalogViewer.this.textInfoPanel);
                }
                CatalogViewer.this.textInfoTextArea.setText(new_text);

                // Scroll to top
                CatalogViewer.this.textInfoTextArea.grabFocus();
            }

            CatalogViewer.this.text_mode = text_mode;
        }
    });
    this.generateCatalogTree(this.catalog, this.catalog_file_path.getName());

    //
    // Text Information Panel
    //
    this.textInfoPanel = new JPanel();
    this.textInfoPanel.setLayout(new BorderLayout());
    this.textInfoTextArea = new JTextArea();
    this.textInfoTextArea.setEditable(false);
    this.textInfoTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
    this.textInfoTextArea.setText(this.getSummaryText());
    this.textInfoTextArea.addFocusListener(new FocusListener() {
        @Override
        public void focusLost(FocusEvent e) {
            // TODO Auto-generated method stub
        }

        @Override
        public void focusGained(FocusEvent e) {
            CatalogViewer.this.scrollTextInfoToTop();
        }
    });
    this.textInfoScroller = new JScrollPane(this.textInfoTextArea);
    this.textInfoPanel.add(this.textInfoScroller, BorderLayout.CENTER);
    this.mainPanel = new JPanel(new BorderLayout());
    this.mainPanel.add(textInfoPanel, BorderLayout.CENTER);

    //
    // Search Toolbar
    //
    JPanel searchPanel = new JPanel();
    searchPanel.setLayout(new BorderLayout());
    JPanel innerSearchPanel = new JPanel();
    innerSearchPanel.setLayout(new BoxLayout(innerSearchPanel, BoxLayout.X_AXIS));
    innerSearchPanel.add(new JLabel("Search: "));
    this.searchField = new JTextField(30);
    innerSearchPanel.add(this.searchField);
    searchPanel.add(innerSearchPanel, BorderLayout.EAST);

    this.searchField.addKeyListener(new KeyListener() {
        private String last = null;

        @Override
        public void keyReleased(KeyEvent e) {
            String value = CatalogViewer.this.searchField.getText().toLowerCase().trim();
            if (!value.isEmpty() && (this.last == null || !this.last.equals(value))) {
                CatalogViewer.this.search(value);
            }
            this.last = value;
        }

        @Override
        public void keyTyped(KeyEvent e) {
            // Do nothing...
        }

        @Override
        public void keyPressed(KeyEvent e) {
            // Do nothing...
        }
    });

    // Putting it all together
    JScrollPane scrollPane = new JScrollPane(this.catalogTree);
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    topPanel.add(searchPanel, BorderLayout.NORTH);
    topPanel.add(scrollPane, BorderLayout.CENTER);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, topPanel, this.mainPanel);
    splitPane.setDividerLocation(400);

    this.add(splitPane, BorderLayout.CENTER);
}

From source file:coreferenceresolver.gui.MarkupGUI.java

private JScrollPane newMarkupPanel(NounPhrase np, ReviewElement reviewElement) {
    //MODEL//from   ww w .  jav a2s .  com
    Element element = new Element();

    //Newly added
    ScrollablePanel markupPanel = new ScrollablePanel();
    markupPanel.setLayout(new BoxLayout(markupPanel, BoxLayout.X_AXIS));
    markupPanel.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT);

    JTextArea npContentTxtArea = new JTextArea();
    npContentTxtArea.setEditable(false);
    npContentTxtArea.setText(((MarkupNounPhrase) np).content);
    markupPanel.add(npContentTxtArea);

    //REF
    SpinnerModel refSpinnerModel = new SpinnerNumberModel(np.getChainId(), -1, COLORS.length - 1, 1);
    JSpinner refSpinner = new JSpinner(refSpinnerModel);
    refSpinner.setValue(np.getChainId());

    refSpinner.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            np.setChainId((int) refSpinner.getValue());
            try {
                rePaint(reviewElements.get(np.getReviewId()), np);
            } catch (BadLocationException ex) {
                Logger.getLogger(MarkupGUI.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });

    element.refSpinner = refSpinner;

    //TYPE        
    String[] typeValues = { "Object", "Other", "Candidate", "Attribute" };
    SpinnerModel typeSpinnerModel = new SpinnerListModel(typeValues);
    JSpinner typeSpinner = new JSpinner(typeSpinnerModel);
    typeSpinner.setValue(typeValues[np.getType()]);

    element.typeSpinner = typeSpinner;

    //REF + TYPE
    ScrollablePanel spinners = new ScrollablePanel();
    spinners.setLayout(new BoxLayout(spinners, BoxLayout.X_AXIS));
    spinners.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT);
    spinners.add(refSpinner);
    spinners.add(typeSpinner);
    markupPanel.add(spinners);

    reviewElement.addElement(element);

    JScrollPane scrollMarkupPanel = new JScrollPane(markupPanel);

    return scrollMarkupPanel;
}

From source file:de.adv_online.aaa.katalogtool.KatalogDialog.java

private Component createMainTab() {

    // bernahme der Eigenschaften
    String s = "";

    String appSchemaStr;/*from w  ww.ja  v  a 2s. c  o m*/
    s = options.parameter("appSchemaName");
    if (s != null && s.trim().length() > 0)
        appSchemaStr = s.trim();
    else
        appSchemaStr = "";

    String schemaKennungenStr;
    s = options.parameter(paramKatalogClass, "schemakennungen");
    if (s != null && s.trim().length() > 0)
        schemaKennungenStr = s.trim();
    else
        schemaKennungenStr = "*";

    Boolean geerbEigBool = false;
    s = options.parameter(paramKatalogClass, "geerbteEigenschaften");
    if (s != null && s.equals("true"))
        geerbEigBool = true;

    String modellartenStr;
    s = options.parameter(paramKatalogClass, "modellarten");
    if (s == null || s.trim().length() == 0)
        modellartenStr = "";
    else
        modellartenStr = s.trim();

    Boolean grundDatBool = false;
    s = options.parameter(paramKatalogClass, "nurGrunddatenbestand");
    if (s != null && s.equals("true"))
        grundDatBool = true;

    Boolean profEinschrBool = false;
    Boolean profDateiBool = false;
    String profileStr;
    s = options.parameter(paramKatalogClass, "profile");
    if (s == null || s.trim().length() == 0)
        profileStr = "";
    else
        profileStr = s.trim();
    if (profileStr.length() > 0)
        profEinschrBool = true;
    s = options.parameter(paramKatalogClass, "profilquelle");
    if (s != null && s.trim().equals("Datei"))
        profDateiBool = true;

    Boolean pkgBool = false;
    String pkgStr;
    s = options.parameter(paramKatalogClass, "paket");
    if (s == null || s.trim().length() == 0)
        pkgStr = "";
    else
        pkgStr = s.trim();
    if (pkgStr.length() > 0)
        pkgBool = true;

    String xsltPfadStr;
    s = options.parameter(paramKatalogClass, "xsltPfad");
    if (s == null || s.trim().length() == 0)
        xsltPfadStr = "";
    else {
        if (s.toLowerCase().startsWith("http://")) {
            xsltPfadStr = s;
        } else {
            File f = new File(s.trim());
            if (f.exists())
                xsltPfadStr = f.getAbsolutePath();
            else
                xsltPfadStr = "";
        }
    }

    String outDirStr;
    s = options.parameter(paramKatalogClass, "Verzeichnis");
    if (s == null || s.trim().length() == 0)
        outDirStr = "";
    else {
        File f = new File(s.trim());
        if (f.exists())
            outDirStr = f.getAbsolutePath();
        else
            outDirStr = "";
    }

    String mdlDirStr = eap;

    // Anwendungsschema

    final JPanel appSchemaPanel = new JPanel();
    final JPanel appSchemaInnerPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 30, 5));
    appSchemaPanel.setLayout(new BoxLayout(appSchemaPanel, BoxLayout.X_AXIS));
    appSchemaPanel.setBorder(BorderFactory.createEmptyBorder(15, 20, 15, 10));

    appSchemaField = new JTextField(37);
    appSchemaField.setText(appSchemaStr);
    appSchemaFieldLabel = new JLabel("Name des zu exportierenden Anwendungsschemas:");

    Box asBox = Box.createVerticalBox();
    asBox.add(appSchemaFieldLabel);
    asBox.add(appSchemaField);

    pkgBox = new JCheckBox("Eingeschrnkt auf Paket:");
    pkgBox.setSelected(pkgBool);
    pkgBox.addItemListener(this);
    pkgField = new JTextField(37);
    pkgField.setText(pkgStr);
    if (pkgStr.length() == 0) {
        pkgField.setEnabled(false);
        pkgField.setEditable(false);
    }
    asBox.add(pkgBox);
    asBox.add(pkgField);

    appSchemaInnerPanel.add(asBox);

    appSchemaPanel.add(appSchemaInnerPanel);

    // Ausgabeoptionen

    Box outOptBox = Box.createVerticalBox();

    final JPanel outOptInnerPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 15, 5));
    Box skBox = Box.createVerticalBox();
    schemaKennFieldLabel1 = new JLabel("Liste der zu bercksichtigenden Schema-Kennungen");
    skBox.add(schemaKennFieldLabel1);
    schemaKennFieldLabel2 = new JLabel("(nur Klassen mit diesen Kennungen werden exportiert)");
    skBox.add(schemaKennFieldLabel2);
    schemaKennField = new JTextField(35);
    schemaKennField.setText(schemaKennungenStr);
    skBox.add(schemaKennField);
    outOptInnerPanel.add(skBox);
    outOptBox.add(outOptInnerPanel);

    final JPanel targetPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 5));
    for (String label : targetLabels) {
        targetPanel.add(targetGuiElems.get(label).selBox);
    }
    outOptBox.add(targetPanel);

    final JPanel geerbEigPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 5));
    geerbEigBox = new JCheckBox("Eigenschaften aus Superklassen auch in abgeleiteten Klassen darstellen");
    geerbEigBox.setSelected(geerbEigBool);
    geerbEigBox.addItemListener(this);
    geerbEigPanel.add(geerbEigBox);
    outOptBox.add(geerbEigPanel);

    final JPanel outOptPanel = new JPanel();
    outOptPanel.add(outOptBox);
    outOptPanel.setBorder(new TitledBorder(new LineBorder(Color.black), "Ausgabeoptionen", TitledBorder.LEFT,
            TitledBorder.TOP));

    // Modellarten und Profile
    Box modProfBox = Box.createVerticalBox();

    final JPanel modProfInnerPanel1 = new JPanel(new FlowLayout(FlowLayout.LEADING, 15, 5));

    skBox = Box.createVerticalBox();
    modellartFieldLabel = new JLabel("Ausgewhlte Modellarten:");
    modellartField = new JTextField(45);
    modellartField.setText(modellartenStr);
    skBox.add(modellartFieldLabel);
    skBox.add(modellartField);
    modProfInnerPanel1.add(skBox);
    modProfBox.add(modProfInnerPanel1);
    final JPanel grundDatPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 8));
    grundDatBox = new JCheckBox("Nur Grunddatenbestand exportieren");
    grundDatBox.setSelected(grundDatBool);
    grundDatBox.addItemListener(this);
    grundDatPanel.add(grundDatBox);
    modProfBox.add(grundDatPanel);

    final JPanel profPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 5));
    profEinschrBox = new JCheckBox("Eingeschrnkt auf folgende Profilkennung(en) im Modell:");
    profEinschrBox.setSelected(profEinschrBool);
    profEinschrBox.addItemListener(this);
    profPanel.add(profEinschrBox);
    final JPanel profPanel2 = new JPanel(new FlowLayout(FlowLayout.LEADING, 15, 2));
    profileField = new JTextField(45);
    profileField.setText(profileStr);
    profPanel2.add(profileField);
    final JPanel profPanel3 = new JPanel(new FlowLayout(FlowLayout.LEADING, 15, 2));
    profDateiBox = new JCheckBox(
            "Profil(e) nur aus 3ap-Datei laden und verwenden statt der Profilkennungen aus dem Modell");
    profDateiBox.setSelected(profDateiBool);
    profDateiBox.addItemListener(this);
    profPanel3.add(profDateiBox);
    if (profileStr.length() == 0) {
        profileField.setEnabled(false);
        profileField.setEditable(false);
        profDateiBox.setEnabled(false);
    }

    modProfBox.add(profPanel);
    modProfBox.add(profPanel2);
    modProfBox.add(profPanel3);

    final JPanel modProfPanel = new JPanel();
    modProfPanel.add(modProfBox);
    modProfPanel.setBorder(new TitledBorder(new LineBorder(Color.black), "Auswahl der Modellarten und Profile",
            TitledBorder.LEFT, TitledBorder.TOP));

    // Pfadangaben
    Box pfadBox = Box.createVerticalBox();
    final JPanel pfadInnerPanel = new JPanel();
    skBox = Box.createVerticalBox();
    xsltpfadFieldLabel = new JLabel("Pfad in dem die XSLT-Skripte liegen:");
    skBox.add(xsltpfadFieldLabel);
    xsltpfadField = new JTextField(45);
    xsltpfadField.setText(xsltPfadStr);
    skBox.add(xsltpfadField);
    outDirFieldLabel = new JLabel("Pfad in den die Kataloge geschrieben werden:");
    skBox.add(outDirFieldLabel);
    outDirField = new JTextField(45);
    outDirField.setText(outDirStr);
    skBox.add(outDirField);
    mdlDirFieldLabel = new JLabel("Pfad zum Modell:");
    skBox.add(mdlDirFieldLabel);
    mdlDirField = new JTextField(45);
    mdlDirField.setText(mdlDirStr);
    skBox.add(mdlDirField);
    pfadInnerPanel.add(skBox);
    pfadBox.add(pfadInnerPanel);

    final JPanel pfadPanel = new JPanel();
    pfadPanel.add(pfadBox);
    pfadPanel.setBorder(
            new TitledBorder(new LineBorder(Color.black), "Pfadangaben", TitledBorder.LEFT, TitledBorder.TOP));

    // Zusammenstellung
    Box fileBox = Box.createVerticalBox();
    fileBox.add(appSchemaPanel);
    fileBox.add(outOptPanel);
    fileBox.add(modProfPanel);
    fileBox.add(pfadPanel);

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(fileBox, BorderLayout.NORTH);

    return panel;
}

From source file:lol.search.RankedStatsPage.java

private JPanel statsPanel() {
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    panel.setOpaque(false);//from w w w.  ja  v a 2s.c o m
    panel.setLayout(new FlowLayout());
    panel.setPreferredSize(new Dimension(910, 464));
    JPanel statsPanelTotals = new JPanel();
    statsPanelTotals.setLayout(new BoxLayout(statsPanelTotals, BoxLayout.X_AXIS));
    statsPanelTotals.setOpaque(false);
    //statsPanelTotals.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    //totals
    statsPanelTotals.setPreferredSize(new Dimension(910, 45));
    totalJLabel(winsLabel, "   W: ", Color.WHITE);
    winsLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    totalJLabel(totalWins, "" + this.wins, valueOrange);
    totalJLabel(lossesLabel, "   L: ", Color.WHITE);
    totalJLabel(totalLosses, "" + this.losses, valueOrange);
    totalJLabel(winPercentLabel, "   Win Ratio: ", Color.WHITE);
    totalJLabel(winPercent, winPercentage + "%", valueOrange);
    totalJLabel(totalGames, "   Total Games Played: ", Color.WHITE);
    totalJLabel(this.totalGamesPlayed, String.valueOf(totalGamesInt), valueOrange);
    statsPanelTotals.add(winsLabel);
    statsPanelTotals.add(totalWins);
    statsPanelTotals.add(lossesLabel);
    statsPanelTotals.add(totalLosses);
    statsPanelTotals.add(winPercentLabel);
    statsPanelTotals.add(winPercent);
    statsPanelTotals.add(totalGames);
    statsPanelTotals.add(totalGamesPlayed);
    JPanel totalsAndAverages = new JPanel();
    totalsAndAverages.setOpaque(false);
    totalsAndAverages.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    totalsAndAverages.setPreferredSize(new Dimension(910, 405));
    totalsAndAverages.setLayout(new GridLayout());
    JPanel leftSide = new JPanel();
    leftSide.setOpaque(false);
    leftSide.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    JPanel leftSideHeader = new JPanel();
    leftSideHeader.setOpaque(false);
    leftSideHeader.setLayout(new FlowLayout());
    leftSideHeader.setPreferredSize(new Dimension(455, 35));
    //leftSideHeader.setBorder(BorderFactory.createLineBorder(Color.CYAN));
    totalJLabel(this.leftSideHeaderLabel, "   Per Game Averages:", Color.WHITE);
    leftSideHeader.add(this.leftSideHeaderLabel);
    JPanel leftSideBody = new JPanel();
    leftSideBody.setOpaque(false);
    leftSideBody.setLayout(new FlowLayout(FlowLayout.LEFT));
    leftSideBody.setPreferredSize(new Dimension(250, 360));
    //leftSideBody.setBorder(BorderFactory.createLineBorder(Color.RED));
    JPanel avgKillsPanel = new JPanel();
    avgKillsPanel.setOpaque(false);
    //avgKillsPanel.setBorder(BorderFactory.createLineBorder(Color.CYAN));
    JPanel avgDeathsPanel = new JPanel();
    avgDeathsPanel.setOpaque(false);
    JPanel avgAssistsPanel = new JPanel();
    avgAssistsPanel.setOpaque(false);
    JPanel avgMinionsPanel = new JPanel();
    avgMinionsPanel.setOpaque(false);
    JPanel avgDoubleKillsPanel = new JPanel();
    avgDoubleKillsPanel.setOpaque(false);
    JPanel avgTripleKillsPanel = new JPanel();
    avgTripleKillsPanel.setOpaque(false);
    JPanel avgQuadKillsPanel = new JPanel();
    avgQuadKillsPanel.setOpaque(false);
    JPanel avgPentaKillsPanel = new JPanel();
    avgPentaKillsPanel.setOpaque(false);
    totalJLabel(this.avgKillsLabel, "   Avg. Kills: ", Color.WHITE);
    totalJLabel(this.avgDeathsLabel, "   Avg. Deaths: ", Color.WHITE);
    totalJLabel(this.avgAssistsLabel, "   Avg. Assists: ", Color.WHITE);
    totalJLabel(this.avgMinionKillsLabel, "   Avg. Minion Kills: ", Color.WHITE);
    totalJLabel(this.avgDoubleKillsLabel, "   Avg. Double Kills: ", Color.WHITE);
    totalJLabel(this.avgTripleKillsLabel, "   Avg. Triple Kills: ", Color.WHITE);
    totalJLabel(this.avgQuadKillsLabel, "   Avg. Quadra Kills: ", Color.WHITE);
    totalJLabel(this.avgPentaKillsLabel, "   Avg. Penta Kills: ", Color.WHITE);
    double totalKills = 00000;
    double totalDeaths = 00000;
    double totalAssists = 00000;
    double totalMinions = 00000;
    double totalDoubleKills = 00000;
    double totalTripleKills = 00000;
    double totalQuadraKills = 00000;
    double totalPentaKills = 00000;
    double avgKills = 99999;
    double avgAssists = 99999;
    double avgDeaths = 99999;
    double avgMinions = 99999;
    double avgDoubleKills = 99999;
    double avgTripleKills = 99999;
    double avgQuadraKills = 99999;
    double avgPentaKills = 99999;
    try {
        double totalGamesPlayed = this.objChampRankedList.get(0).getJSONObject("stats")
                .getInt("totalSessionsPlayed");
        //operations
        totalKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalChampionKills");
        avgKills = totalKills / totalGamesPlayed;
        totalDeaths = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalDeathsPerSession");
        avgDeaths = totalDeaths / totalGamesPlayed;
        totalAssists = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalAssists");
        avgAssists = totalAssists / totalGamesPlayed;
        totalMinions = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalMinionKills");
        avgMinions = totalMinions / totalGamesPlayed;
        totalDoubleKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalDoubleKills");
        avgDoubleKills = totalDoubleKills / totalGamesPlayed;
        totalTripleKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalTripleKills");
        avgTripleKills = totalTripleKills / totalGamesPlayed;
        totalQuadraKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalQuadraKills");
        avgQuadraKills = totalQuadraKills / totalGamesPlayed;
        totalPentaKills = this.objChampRankedList.get(0).getJSONObject("stats").getInt("totalPentaKills");
        avgPentaKills = totalPentaKills / totalGamesPlayed;
    } catch (JSONException ex) {
        Logger.getLogger(RankedStatsPage.class.getName()).log(Level.SEVERE, null, ex);
    }
    String avgKillsString = new DecimalFormat("##.##").format(avgKills);
    String avgDeathsString = new DecimalFormat("##.##").format(avgDeaths);
    String avgAssistsString = new DecimalFormat("##.##").format(avgAssists);
    String avgMinionsString = new DecimalFormat("##.##").format(avgMinions);
    String avgDoubleKillsString = new DecimalFormat("##.##").format(avgDoubleKills);
    String avgTripleKillsString = new DecimalFormat("##.##").format(avgTripleKills);
    String avgQuadraKillsString = new DecimalFormat("##.##").format(avgQuadraKills);
    String avgPentaKillsString = new DecimalFormat("##.##").format(avgPentaKills);
    totalJLabel(this.avgKillsLabelValue, avgKillsString, valueOrange);
    totalJLabel(this.avgDeathsLabelValue, avgDeathsString, valueOrange);
    totalJLabel(this.avgAssistsLabelValue, avgAssistsString, valueOrange);
    totalJLabel(this.avgMinionKillsLabelValue, avgMinionsString, valueOrange);
    totalJLabel(this.avgDoubleKillsLabelValue, avgDoubleKillsString, valueOrange);
    totalJLabel(this.avgTripleKillsLabelValue, avgTripleKillsString, valueOrange);
    totalJLabel(this.avgQuadKillsLabelValue, avgQuadraKillsString, valueOrange);
    totalJLabel(this.avgPentaKillsLabelValue, avgPentaKillsString, valueOrange);
    avgKillsPanel.add(avgKillsLabel);
    avgKillsPanel.add(avgKillsLabelValue);
    avgDeathsPanel.add(avgDeathsLabel);
    avgDeathsPanel.add(avgDeathsLabelValue);
    avgAssistsPanel.add(avgAssistsLabel);
    avgAssistsPanel.add(avgAssistsLabelValue);
    avgMinionsPanel.add(avgMinionKillsLabel);
    avgMinionsPanel.add(avgMinionKillsLabelValue);
    avgDoubleKillsPanel.add(avgDoubleKillsLabel);
    avgDoubleKillsPanel.add(avgDoubleKillsLabelValue);
    avgTripleKillsPanel.add(avgTripleKillsLabel);
    avgTripleKillsPanel.add(avgTripleKillsLabelValue);
    avgQuadKillsPanel.add(avgQuadKillsLabel);
    avgQuadKillsPanel.add(avgQuadKillsLabelValue);
    avgPentaKillsPanel.add(avgPentaKillsLabel);
    avgPentaKillsPanel.add(avgPentaKillsLabelValue);
    leftSideBody.add(avgKillsPanel);
    leftSideBody.add(avgDeathsPanel);
    leftSideBody.add(avgAssistsPanel);
    leftSideBody.add(avgMinionsPanel);
    leftSideBody.add(avgDoubleKillsPanel);
    leftSideBody.add(avgTripleKillsPanel);
    leftSideBody.add(avgQuadKillsPanel);
    leftSideBody.add(avgPentaKillsPanel);
    leftSide.add(leftSideHeader);
    leftSide.add(leftSideBody);
    JPanel rightSide = new JPanel();
    /**/
    rightSide.setOpaque(false);
    rightSide.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
    JPanel rightSideHeader = new JPanel();
    rightSideHeader.setOpaque(false);
    rightSideHeader.setLayout(new FlowLayout());
    rightSideHeader.setPreferredSize(new Dimension(455, 35));
    //rightSideHeader.setBorder(BorderFactory.createLineBorder(Color.MAGENTA));
    totalJLabel(this.rightSideHeaderLabel, "   Season Totals:", Color.WHITE);
    rightSideHeader.add(this.rightSideHeaderLabel);
    JPanel rightSideBody = new JPanel();
    rightSideBody.setOpaque(false);
    rightSideBody.setLayout(new FlowLayout(FlowLayout.LEFT));
    rightSideBody.setPreferredSize(new Dimension(270, 360));
    //rightSideBody.setBorder(BorderFactory.createLineBorder(Color.MAGENTA));
    JPanel totalKillsPanel = new JPanel();
    totalKillsPanel.setOpaque(false);
    JPanel totalDeathsPanel = new JPanel();
    totalDeathsPanel.setOpaque(false);
    JPanel totalAssistsPanel = new JPanel();
    totalAssistsPanel.setOpaque(false);
    JPanel totalMinionsPanel = new JPanel();
    totalMinionsPanel.setOpaque(false);
    JPanel totalDoubleKillsPanel = new JPanel();
    totalDoubleKillsPanel.setOpaque(false);
    JPanel totalTripleKillsPanel = new JPanel();
    totalTripleKillsPanel.setOpaque(false);
    JPanel totalQuadKillsPanel = new JPanel();
    totalQuadKillsPanel.setOpaque(false);
    JPanel totalPentaKillsPanel = new JPanel();
    totalPentaKillsPanel.setOpaque(false);
    totalJLabel(this.totalKillsLabel, "   Total Kills: ", Color.WHITE);
    totalJLabel(this.totalKillsLabelValue, new DecimalFormat("#######").format(totalKills), valueOrange);
    totalJLabel(this.totalDeathsLabel, "   Total Deaths: ", Color.WHITE);
    totalJLabel(this.totalDeathsLabelValue, new DecimalFormat("#######").format(totalDeaths), valueOrange);
    totalJLabel(this.totalAssistsLabel, "   Total Assists: ", Color.WHITE);
    totalJLabel(this.totalAssistsLabelValue, new DecimalFormat("#######").format(totalAssists), valueOrange);
    totalJLabel(this.totalMinionsLabel, "   Total Minion Kills: ", Color.WHITE);
    totalJLabel(this.totalMinionsLabelValue, new DecimalFormat("#######").format(totalMinions), valueOrange);
    totalJLabel(this.totalDoubleKillsLabel, "   Total Double Kills: ", Color.WHITE);
    totalJLabel(this.totalDoubleKillsLabelValue, new DecimalFormat("#######").format(totalDoubleKills),
            valueOrange);
    totalJLabel(this.totalTripleKillsLabel, "   Total Triple Kills: ", Color.WHITE);
    totalJLabel(this.totalTripleKillsLabelValue, new DecimalFormat("#######").format(totalTripleKills),
            valueOrange);
    totalJLabel(this.totalQuadKillsLabel, "   Total Quadra Kills: ", Color.WHITE);
    totalJLabel(this.totalQuadKillsLabelValue, new DecimalFormat("#######").format(totalQuadraKills),
            valueOrange);
    totalJLabel(this.totalPentaKillsLabel, "   Total Penta Kills: ", Color.WHITE);
    totalJLabel(this.totalPentaKillsLabelValue, new DecimalFormat("#######").format(totalPentaKills),
            valueOrange);
    totalKillsPanel.add(totalKillsLabel);
    totalKillsPanel.add(totalKillsLabelValue);
    totalDeathsPanel.add(totalDeathsLabel);
    totalDeathsPanel.add(totalDeathsLabelValue);
    totalAssistsPanel.add(totalAssistsLabel);
    totalAssistsPanel.add(totalAssistsLabelValue);
    totalMinionsPanel.add(totalMinionsLabel);
    totalMinionsPanel.add(totalMinionsLabelValue);
    totalDoubleKillsPanel.add(totalDoubleKillsLabel);
    totalDoubleKillsPanel.add(totalDoubleKillsLabelValue);
    totalTripleKillsPanel.add(totalTripleKillsLabel);
    totalTripleKillsPanel.add(totalTripleKillsLabelValue);
    totalQuadKillsPanel.add(totalQuadKillsLabel);
    totalQuadKillsPanel.add(totalQuadKillsLabelValue);
    totalPentaKillsPanel.add(totalPentaKillsLabel);
    totalPentaKillsPanel.add(totalPentaKillsLabelValue);
    rightSideBody.add(totalKillsPanel);
    rightSideBody.add(totalDeathsPanel);
    rightSideBody.add(totalAssistsPanel);
    rightSideBody.add(totalMinionsPanel);
    rightSideBody.add(totalDoubleKillsPanel);
    rightSideBody.add(totalTripleKillsPanel);
    rightSideBody.add(totalQuadKillsPanel);
    rightSideBody.add(totalPentaKillsPanel);
    //rightSideBody.setBorder(BorderFactory.createLineBorder(Color.RED));
    rightSide.add(rightSideHeader);
    rightSide.add(rightSideBody);
    totalsAndAverages.add(rightSide);
    totalsAndAverages.add(leftSide);
    panel.add(statsPanelTotals);
    panel.add(totalsAndAverages);
    return panel;
}

From source file:net.openbyte.gui.WorkFrame.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Gary Lee
    menuBar1 = new JMenuBar();
    menu2 = new JMenu();
    menuItem8 = new JMenuItem();
    menuItem6 = new JMenuItem();
    menuItem4 = new JMenuItem();
    menuItem5 = new JMenuItem();
    menu3 = new JMenu();
    menuItem7 = new JMenuItem();
    menu6 = new JMenu();
    menuItem11 = new JMenuItem();
    menu1 = new JMenu();
    menuItem1 = new JMenuItem();
    menuItem2 = new JMenuItem();
    menuItem3 = new JMenuItem();
    menu4 = new JMenu();
    menuItem9 = new JMenuItem();
    menu5 = new JMenu();
    menuItem10 = new JMenuItem();
    scrollPane3 = new JScrollPane();
    tree1 = new JTree();
    rTextScrollPane1 = new RTextScrollPane();
    rSyntaxTextArea1 = new RSyntaxTextArea();

    //======== this ========
    setTitle("Project Workspace");
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS));

    //======== menuBar1 ========
    {/*  w  ww  . j av a 2 s . c o m*/

        //======== menu2 ========
        {
            menu2.setText("File");

            //---- menuItem8 ----
            menuItem8.setText("Add Class");
            menuItem8.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItem8ActionPerformed(e);
                }
            });
            menu2.add(menuItem8);

            //---- menuItem6 ----
            menuItem6.setText("Add Package");
            menuItem6.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItem6ActionPerformed(e);
                }
            });
            menu2.add(menuItem6);

            //---- menuItem4 ----
            menuItem4.setText("Save");
            menuItem4.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItem4ActionPerformed(e);
                }
            });
            menu2.add(menuItem4);

            //---- menuItem5 ----
            menuItem5.setText("Close Project");
            menuItem5.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItem5ActionPerformed(e);
                }
            });
            menu2.add(menuItem5);
        }
        menuBar1.add(menu2);

        //======== menu3 ========
        {
            menu3.setText("Edit");

            //---- menuItem7 ----
            menuItem7.setText("Delete");
            menuItem7.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItem7ActionPerformed(e);
                }
            });
            menu3.add(menuItem7);
        }
        menuBar1.add(menu3);

        //======== menu6 ========
        {
            menu6.setText("View");

            //---- menuItem11 ----
            menuItem11.setText("Output");
            menuItem11.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItem11ActionPerformed(e);
                }
            });
            menu6.add(menuItem11);
        }
        menuBar1.add(menu6);

        //======== menu1 ========
        {
            menu1.setText("Gradle");

            //---- menuItem1 ----
            menuItem1.setText("Run Client");
            menuItem1.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItem1ActionPerformed(e);
                }
            });
            menu1.add(menuItem1);

            //---- menuItem2 ----
            menuItem2.setText("Run Server");
            menuItem2.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItem2ActionPerformed(e);
                }
            });
            menu1.add(menuItem2);

            //---- menuItem3 ----
            menuItem3.setText("Build Mod JAR");
            menuItem3.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItem3ActionPerformed(e);
                }
            });
            menu1.add(menuItem3);
        }
        menuBar1.add(menu1);

        //======== menu4 ========
        {
            menu4.setText("Git");

            //---- menuItem9 ----
            menuItem9.setText("Import into Git");
            menuItem9.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItem9ActionPerformed(e);
                    menuItem9ActionPerformed(e);
                }
            });
            menu4.add(menuItem9);

            //======== menu5 ========
            {
                menu5.setText("Options");
                menu5.setEnabled(false);

                //---- menuItem10 ----
                menuItem10.setText("Commit");
                menuItem10.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        menuItem10ActionPerformed(e);
                    }
                });
                menu5.add(menuItem10);
            }
            menu4.add(menu5);
        }
        menuBar1.add(menu4);
    }
    setJMenuBar(menuBar1);

    //======== scrollPane3 ========
    {
        scrollPane3.setBorder(null);

        //---- tree1 ----
        tree1.setBorder(new TitledBorder(LineBorder.createGrayLineBorder(), "File Manager"));
        tree1.setBackground(new Color(240, 240, 240));
        tree1.setPreferredSize(new Dimension(-600, 85));
        tree1.addTreeSelectionListener(new TreeSelectionListener() {
            @Override
            public void valueChanged(TreeSelectionEvent e) {
                tree1ValueChanged(e);
            }
        });
        scrollPane3.setViewportView(tree1);
    }
    contentPane.add(scrollPane3);

    //======== rTextScrollPane1 ========
    {
        rTextScrollPane1.setBorder(new TitledBorder(LineBorder.createGrayLineBorder(), "Code Editor"));

        //---- rSyntaxTextArea1 ----
        rSyntaxTextArea1.setSyntaxEditingStyle("text/java");
        rSyntaxTextArea1.setBackground(Color.white);
        rTextScrollPane1.setViewportView(rSyntaxTextArea1);
    }
    contentPane.add(rTextScrollPane1);
    setSize(1230, 785);
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:medsavant.uhn.cancer.UserCommentApp.java

@Override
public void setVariantRecord(final VariantRecord variantRecord) {
    try {/*from   ww  w  .ja  v  a 2  s.c o m*/
        //Get comment group associated with this variant.
        UserCommentGroup lcg = MedSavantClient.VariantManager.getUserCommentGroup(
                LoginController.getSessionID(), ProjectController.getInstance().getCurrentProjectID(),
                ReferenceController.getInstance().getCurrentReferenceID(), variantRecord);
        boolean hasComments = false;
        JPanel innerPanel = null;
        if (lcg != null) {
            //Build a mapping from ontology terms to all comments pertaining to that ontology term.
            //Iterating through this map will return the ontology terms in alphabetical order, and the comments
            //within each ontology will be ordered by their insertion id.
            Map<OntologyTerm, Collection<UserComment>> otCommentMap = new TreeMap<OntologyTerm, Collection<UserComment>>();

            for (Iterator<UserComment> li = lcg.iterator(); li.hasNext();) {
                UserComment lc = li.next();
                Collection<UserComment> ontologyComments = otCommentMap.get(lc.getOntologyTerm());
                if (ontologyComments == null) {
                    ontologyComments = new ArrayList<UserComment>();
                    hasComments = true;
                }
                ontologyComments.add(lc);

                otCommentMap.put(lc.getOntologyTerm(), ontologyComments);
            }
            if (hasComments) {
                innerPanel = getMainCommentPanel(otCommentMap, lcg, variantRecord);
            }
        }

        if (innerPanel == null) {
            innerPanel = getNoCommentsPanel();
        }

        JButton newCommentButton = new JButton("New Comment");
        newCommentButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                newComment(variantRecord);
            }
        });

        JPanel cp = new JPanel();
        cp.setLayout(new BoxLayout(cp, BoxLayout.X_AXIS));
        cp.add(Box.createHorizontalGlue());
        if (roleManager.checkRole(GENETIC_COUNSELLOR_ROLENAME) || roleManager.checkRole(RESIDENT_ROLENAME)) {
            cp.add(newCommentButton);
        }
        cp.add(Box.createHorizontalGlue());
        innerPanel.add(cp);
        final JScrollPane jsp = new JScrollPane(innerPanel);

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {

                panel.removeAll();
                panel.add(jsp);
                panel.revalidate();
                panel.repaint();
            }
        });

    } catch (SessionExpiredException see) {
        LOG.error(see.getMessage(), see);
    } catch (SQLException sqe) {
        LOG.error(sqe.getMessage(), sqe);

    } catch (RemoteException rex) {
        LOG.error(rex.getMessage(), rex);
    }
}