Example usage for javax.swing ScrollPaneConstants HORIZONTAL_SCROLLBAR_ALWAYS

List of usage examples for javax.swing ScrollPaneConstants HORIZONTAL_SCROLLBAR_ALWAYS

Introduction

In this page you can find the example usage for javax.swing ScrollPaneConstants HORIZONTAL_SCROLLBAR_ALWAYS.

Prototype

int HORIZONTAL_SCROLLBAR_ALWAYS

To view the source code for javax.swing ScrollPaneConstants HORIZONTAL_SCROLLBAR_ALWAYS.

Click Source Link

Document

Used to set the horizontal scroll bar policy so that horizontal scrollbars are always displayed.

Usage

From source file:edu.harvard.i2b2.query.ui.MainPanel.java

/**
 * This method is called from within the constructor to initialize the form.
 *///from  www.ja v  a2s  .  c o m
private void initComponents() {
    jAnalysisLabel = new javax.swing.JLabel();
    jTimingLabel = new javax.swing.JLabel();
    jNameLabel = new javax.swing.JLabel();
    jSetSizeLabel = new javax.swing.JLabel();
    jNameTextField = new javax.swing.JTextField();
    jSetSizeFiled = new javax.swing.JLabel();
    jDeleteButton = new javax.swing.JButton();
    jScrollPane1 = new GroupPanel("Group 1", this);
    jRunQueryButton = new javax.swing.JButton();
    jCancelButton = new javax.swing.JButton();
    jClearGroupsButton = new javax.swing.JButton();
    jScrollPane2 = new GroupPanel("Group 2", this);
    jScrollPane3 = new GroupPanel("Group 3", this);
    jScrollPane4 = new javax.swing.JScrollPane();
    jPanel1 = new javax.swing.JPanel();
    // jVisitComboBox = new javax.swing.JComboBox();
    jAndOrLabel1 = new javax.swing.JLabel();
    jAndOrLabel2 = new javax.swing.JLabel();
    jMorePanelsButton = new javax.swing.JButton();
    jWorkflowToolBar = new javax.swing.JToolBar();
    // jTimelineToggleButton = new javax.swing.JToggleButton();
    jPatientCountToggleButton = new javax.swing.JToggleButton();
    // jPatientSetToggleButton = new javax.swing.JToggleButton();
    jToolbarPanel = new javax.swing.JPanel();
    jQueryNamePanel = new javax.swing.JPanel();

    // jOptionsScrollPane = new javax.swing.JScrollPane();
    jOptionsPanel = new AnalysisPanel();
    jTimingPanel = new TimingPanel(this.dataModel);
    jShowTimelineCheckBox = new javax.swing.JCheckBox();
    jGetAllPatientsCheckBox = new javax.swing.JCheckBox();
    // jGetPatientCountCheckBox = new javax.swing.JCheckBox();
    // jGetPatientSetCheckBox = new javax.swing.JCheckBox();

    setLayout(null);

    // jScrollPane4.setHorizontalScrollBarPolicy(javax.swing.
    // ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    jPanel1.setLayout(null);

    jPanel1.add(jScrollPane1);
    jScrollPane1.setBounds(0, 0, 180, 200);

    jPanel1.add(jScrollPane2);
    jScrollPane2.setBounds(185, 0, 180, 200);

    jPanel1.add(jScrollPane3);
    jScrollPane3.setBounds(370, 0, 180, 200);

    // jAndOrLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER)
    // ;
    jAndOrLabel1.setText("and");
    // jAndOrLabel1.setBorder(javax.swing.BorderFactory.createEtchedBorder())
    // ;
    // jPanel1.add(jAndOrLabel1);
    // jAndOrLabel1.setBounds(190, 90, 30, 18);

    // jAndOrLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER)
    // ;
    // jAndOrLabel2.setText("and");
    // jAndOrLabel2.setBorder(javax.swing.BorderFactory.createEtchedBorder())
    // ;
    // jPanel1.add(jAndOrLabel2);
    // jAndOrLabel2.setBounds(410, 90, 30, 18);

    jQueryNamePanel.setLayout(null);
    jQueryNamePanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

    jNameLabel.setText(" Query Name: ");
    jNameLabel.setToolTipText("You may drag this item to workplace to save the query definition");
    jNameLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jNameLabel.setBounds(2, 2, 70, 23);
    add(jNameLabel);
    // jQueryNamePanel.add(jNameLabel);
    jNameLabel.setTransferHandler(new NameLabelTextHandler());
    jNameLabel.addMouseListener(new DragMouseAdapter());
    jNameLabel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
        public void mouseMoved(java.awt.event.MouseEvent evt) {
            jNameLabelMouseMoved(evt);
        }
    });
    jNameLabel.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseExited(java.awt.event.MouseEvent evt) {
            jNameLabelMouseExited(evt);
        }
    });

    jNameTextField.setText("");
    jNameTextField.setBounds(95, 10, 370, 20);
    jNameTextField.setEditable(false);
    jNameTextField.setDragEnabled(true);
    jNameTextField.setTransferHandler(new TransferHandler("Text"));
    // jQueryNamePanel.add(jNameTextField);
    // add(jNameTextField);
    // add(jQueryNamePanel);
    // jQueryNamePanel.setBounds(5, 5, 400, 50);

    jClearGroupsButton.setFont(new java.awt.Font("Tahoma", 1, 10));
    jClearGroupsButton.setText("X");
    jClearGroupsButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    jClearGroupsButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    jClearGroupsButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    jClearGroupsButton.setToolTipText("Reset all panels");
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jClearGroupsButton.setMargin(new java.awt.Insets(-10, -15, -10, -20));
    }
    jClearGroupsButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jClearGroupsButtonActionPerformed(evt);
        }
    });
    jClearGroupsButton.setBounds(600, 10, 30, 20);
    add(jClearGroupsButton);

    jAnalysisLabel.setText("Analysis Types");
    // jAnalysisLabel.setBackground(Color.WHITE);
    // jAnalysisLabel.setOpaque(true);
    jAnalysisLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jAnalysisLabel.setBounds(2, 2, 120, 23);
    jAnalysisLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jAnalysisLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    add(jAnalysisLabel);

    jPanel1.setPreferredSize(new Dimension(700, 150));
    jScrollPane4.setViewportView(jPanel1);
    add(jScrollPane4);
    jScrollPane4.setBounds(20, 35, 635, 220);
    jScrollPane4.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    jScrollPane4.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    // jScrollPane4.setBorder(javax.swing.BorderFactory
    // .createLineBorder(new java.awt.Color(0, 0, 0)));
    jCancelButton.setText("Cancel");
    jCancelButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jCancelButtonActionPerformed(evt);
        }
    });
    // add(jCancelButton);
    // jCancelButton.setBounds(20, 255, 90, 23);
    // jCancelButton.setFont(new Font("Tahoma", Font.PLAIN, 10));

    jGetAllPatientsCheckBox.setText("Get Everyone");
    jGetAllPatientsCheckBox.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    // jGetAllPatientsCheckBox
    // .setBorder(new javax.swing.border.SoftBevelBorder(
    // javax.swing.border.BevelBorder.RAISED));
    jGetAllPatientsCheckBox.setBorderPainted(true);
    jGetAllPatientsCheckBox.setContentAreaFilled(false);
    jGetAllPatientsCheckBox.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jGetAllPatientsCheckBox.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
    jGetAllPatientsCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    jGetAllPatientsCheckBox.setToolTipText("Get all the patients in datamart");
    add(jGetAllPatientsCheckBox);
    jGetAllPatientsCheckBox.setBounds(5, 255, 110, 15);
    jGetAllPatientsCheckBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jGetAllPatientsCheckBoxActionPerformed(evt);
        }
    });

    jRunQueryButton.setText("Run Query Above");
    jRunQueryButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jRunQueryButtonActionPerformed(evt);
        }
    });
    add(jRunQueryButton);
    jRunQueryButton.setBounds(100, 255, 625, 23);

    jSetSizeLabel.setText(" Patient(s) returned:");
    add(jSetSizeLabel);
    jSetSizeLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jSetSizeLabel.setBounds(20, 275, 70, 23);

    // jSetSizeFiled.setText(" subjects");
    // jSetSizeFiled.setEditable(false);
    // jSetSizeFiled.setHorizontalAlignment(SwingConstants.LEFT);
    // add(jSetSizeFiled);
    // jSetSizeLabel.setBounds(20, 275, 70, 23);

    jToolbarPanel.setLayout(new java.awt.BorderLayout());

    // jWorkflowToolBar.setRollover(true);
    // jWorkflowToolBar.setInheritsPopupMenu(true);
    // jTimelineToggleButton
    // .setIcon(new javax.swing.ImageIcon(
    // "C:\\Documents and Settings\\wp066\\My Documents\\icons\\wb16.gif"));
    // /jTimelineToggleButton.setText("Show TimeLine");
    // jTimelineToggleButton.setFocusPainted(false);
    // jWorkflowToolBar.add(jTimelineToggleButton);

    jPatientCountToggleButton.setIcon(
            new javax.swing.ImageIcon("C:\\Documents and Settings\\wp066\\My Documents\\icons\\wb16.gif"));
    jPatientCountToggleButton.setText("Get Patient Count");
    jPatientCountToggleButton.setFocusPainted(false);
    jWorkflowToolBar.add(jPatientCountToggleButton);

    // jPatientSetToggleButton
    // .setIcon(new javax.swing.ImageIcon(
    // "C:\\Documents and Settings\\wp066\\My Documents\\icons\\wb16.gif"));
    // jPatientSetToggleButton.setText("Get Patient Set");
    // jPatientSetToggleButton.setFocusPainted(false);
    // jWorkflowToolBar.add(jPatientSetToggleButton);
    jWorkflowToolBar.setPreferredSize(new Dimension(380, 40));

    jToolbarPanel.add(jWorkflowToolBar, java.awt.BorderLayout.PAGE_START);
    jToolbarPanel.add(jWorkflowToolBar, java.awt.BorderLayout.CENTER);

    // add(jToolbarPanel);
    jToolbarPanel.setBounds(20, 130, 240, 23);

    jMorePanelsButton.setText("<html><center>Add<br>" + "<left>Group");
    jMorePanelsButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMorePanelsButtonActionPerformed(evt);
        }
    });
    // add(jMorePanelsButton);
    // jMorePanelsButton.setBounds(655, 35, 60, 220);

    jPanel1.add(jMorePanelsButton);
    jMorePanelsButton.setBounds(550, 0, 60, 200);

    // jOptionsPanel.setLayout(null);
    // jOptionsScrollPane.setBorder(javax.swing.BorderFactory
    // .createEtchedBorder());

    // jOptionsPanel.setPreferredSize(new java.awt.Dimension(100, 100));
    jShowTimelineCheckBox.setText("Timeline");
    jShowTimelineCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    jShowTimelineCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    jShowTimelineCheckBox.setToolTipText("Get the patient set and display it in timeline view");
    // jOptionsPanel.add(jShowTimelineCheckBox);
    jShowTimelineCheckBox.setBounds(5, 20, 110, 15);

    // jGetPatientCountCheckBox.setText("Patient Count");
    // jGetPatientCountCheckBox.setBorder(javax.swing.BorderFactory
    // .createEmptyBorder(0, 0, 0, 0));
    // jGetPatientCountCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    // jGetPatientCountCheckBox.setToolTipText("Get the patient count XML");
    // jOptionsPanel.add(jGetPatientCountCheckBox);
    // jGetPatientCountCheckBox.setBounds(5, 50, 110, 15);

    // jGetPatientSetCheckBox.setText("Patient Set");
    // jGetPatientSetCheckBox.setBorder(javax.swing.BorderFactory
    // .createEmptyBorder(0, 0, 0, 0));
    // jGetPatientSetCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    // jOptionsPanel.add(jGetPatientSetCheckBox);
    // jGetPatientSetCheckBox.setBounds(10, 80, 80, 15);

    // jOptionsScrollPane.setViewportView(jOptionsPanel);

    add(jOptionsPanel);
    jOptionsPanel.setBounds(500, 30, 120, 120);

    jTimingLabel.setText("Query Timing");
    // jAnalysisLabel.setBackground(Color.WHITE);
    // jAnalysisLabel.setOpaque(true);
    jTimingLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jTimingLabel.setBounds(2, 2, 120, 23);
    jTimingLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jTimingLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    add(jTimingLabel);
    jTimingLabel.setBounds(500, 30, 120, 120);

    add(jTimingPanel);
    jTimingPanel.setBounds(500, 122, 120, 70);

    /*
     * jDeleteButton.setText("Delete"); jDeleteButton.addActionListener(new
     * java.awt.event.ActionListener() { public void
     * actionPerformed(java.awt.event.ActionEvent evt) {
     * jDeleteButtonActionPerformed(evt); } });
     * 
     * jVisitComboBox.setModel(new javax.swing.DefaultComboBoxModel(new
     * String[] { "Groups don't have to occur in the same visit", "Groups
     * must all occur in the same visit" })); add(jVisitComboBox);
     * jVisitComboBox.setBounds(20, 40, 240, 22);
     * 
     * //add(jDeleteButton); //jDeleteButton.setBounds(20, 10, 65, 23);
     * 
     * add(jScrollPane1); jScrollPane1.setBounds(20, 70, 170, 320);
     * 
     * jRunQueryButton.setText("Run Query");
     * jRunQueryButton.addActionListener(new java.awt.event.ActionListener()
     * { public void actionPerformed(java.awt.event.ActionEvent evt) {
     * jRunQueryButtonActionPerformed(evt); } });
     * 
     * add(jRunQueryButton); jRunQueryButton.setBounds(20, 10, 87, 23);
     * 
     * jCancelButton.setText("Remove All");
     * jCancelButton.addActionListener(new java.awt.event.ActionListener() {
     * public void actionPerformed(java.awt.event.ActionEvent evt) {
     * jRemoveAllButtonActionPerformed(evt); } });
     * 
     * add(jCancelButton); jCancelButton.setBounds(115, 10, 90, 23);
     * 
     * //jScrollPane4.setHorizontalScrollBarPolicy(javax.swing.
     * ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
     * jPanel1.setLayout(null);
     * jScrollPane4.getHorizontalScrollBar().setUnitIncrement(20);
     * //jPanel1.setVisible(false);
     * 
     * //jScrollPane1.setToolTipText("scrollpane 1");
     * jPanel1.add(jScrollPane1); jScrollPane1.setBounds(0, 0, 170, 350);
     * 
     * jPanel1.add(jScrollPane2); jScrollPane2.setBounds(210, 0, 170, 350);
     */

    jAndOrLabel1.setBackground(new java.awt.Color(255, 255, 255));
    jAndOrLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jAndOrLabel1.setText("and");
    jAndOrLabel1.setToolTipText("Click to change the relationship");
    jAndOrLabel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    jAndOrLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jAndOrLabel1MouseClicked(evt);
        }
    });

    // jPanel1.add(jAndOrLabel1);

    jAndOrLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jAndOrLabel2.setText("and");
    jAndOrLabel2.setToolTipText("Click to change the relationship");
    jAndOrLabel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    jAndOrLabel2.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jAndOrLabel2MouseClicked(evt);
        }
    });

    // jPanel1.add(jAndOrLabel2);
    // jTree1.addTreeWillExpandListener(this);
    // jTree1.addTreeExpansionListener(this);
    // jScrollPane1.setViewportView(new QueryConceptTreePanel("Group 1"));
    // jScrollPane1.setToolTipText("Double click on a folder to view the
    // items inside");
    // jTree2.addTreeExpansionListener(this);
    // jScrollPane2.setViewportView(new QueryConceptTreePanel("Group 2"));
    // jTree3.addTreeExpansionListener(this);
    // treepanel = new QueryConceptTreePanel("", this);
    // jScrollPane3.setViewportView(new QueryConceptTreePanel("Group 3"));
    // jSlider1.setMajorTickSpacing(20);
    /*
     * jSlider1.setPaintTicks(true); jSlider1.setValue(0);
     * jSlider1.setMinorTickSpacing(10); jSlider1.setToolTipText("Slider on
     * left is more Sensitive Query, " + "on right is more Specific");
     * add(jSlider1); jSlider1.setBounds(380, 40, 140, 18);
     * 
     * //jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
     * jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
     * jLabel1.setText("Sensitivity <"); add(jLabel1);
     * jLabel1.setBounds(290, 40, 80, 20);
     * 
     * //jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11));
     * jLabel2.setText("> Specificity"); add(jLabel2);
     * jLabel2.setBounds(525, 40, 70, 20);
     */

    dataModel.addPanel(jScrollPane1, null, 0);
    dataModel.addPanel(jScrollPane2, jAndOrLabel1, 0);
    dataModel.addPanel(jScrollPane3, jAndOrLabel2, 555);
}

From source file:net.pms.newgui.LooksFrame.java

/**
 * Constructs a <code>DemoFrame</code>, configures the UI,
 * and builds the content./*from w ww.j av  a 2  s. c  o  m*/
 */
public LooksFrame(AutoUpdater autoUpdater, @Nonnull PmsConfiguration configuration,
        @Nonnull WindowPropertiesConfiguration windowConfiguration) {
    super(windowConfiguration.getGraphicsConfiguration());
    if (configuration == null) {
        throw new IllegalArgumentException("configuration can't be null");
    }
    setResizable(true);
    windowProperties = new WindowProperties(this, STANDARD_SIZE, MINIMUM_SIZE, windowConfiguration);
    this.autoUpdater = autoUpdater;
    this.configuration = configuration;
    assert this.configuration != null;
    setMinimumSize(MINIMUM_SIZE);
    Options.setDefaultIconSize(new Dimension(18, 18));
    Options.setUseNarrowButtons(true);

    // Set view level, can be omitted if ViewLevel is implemented in configuration
    // by setting the view level as variable initialization
    if (configuration.isHideAdvancedOptions()) {
        viewLevel = ViewLevel.NORMAL;
    } else {
        viewLevel = ViewLevel.ADVANCED;
    }

    // Global options
    Options.setTabIconsEnabled(true);
    UIManager.put(Options.POPUP_DROP_SHADOW_ENABLED_KEY, null);

    // Swing Settings
    initializeLookAndFeel();

    // wait till the look and feel has been initialized before (possibly) displaying the update notification dialog
    if (autoUpdater != null) {
        autoUpdater.addObserver(this);
        autoUpdater.pollServer();
    }

    // Shared Fonts
    final Integer twelve = Integer.valueOf(12);
    final Integer fontPlain = Integer.valueOf(Font.PLAIN);
    final Integer fontBold = Integer.valueOf(Font.BOLD);

    LazyValue dialogPlain12 = new LazyValue() {
        @Override
        public Object createValue(UIDefaults t) {
            return new FontUIResource(Font.DIALOG, fontPlain, twelve);
        }
    };

    LazyValue sansSerifPlain12 = new LazyValue() {
        @Override
        public Object createValue(UIDefaults t) {
            return new FontUIResource(Font.SANS_SERIF, fontPlain, twelve);
        }
    };

    LazyValue monospacedPlain12 = new LazyValue() {
        @Override
        public Object createValue(UIDefaults t) {
            return new FontUIResource(Font.MONOSPACED, fontPlain, twelve);
        }
    };

    LazyValue dialogBold12 = new LazyValue() {
        @Override
        public Object createValue(UIDefaults t) {
            return new FontUIResource(Font.DIALOG, fontBold, twelve);
        }
    };

    Object MenuFont = dialogPlain12;
    Object FixedControlFont = monospacedPlain12;
    Object ControlFont = dialogPlain12;
    Object MessageFont = dialogPlain12;
    Object WindowFont = dialogBold12;
    Object ToolTipFont = sansSerifPlain12;
    Object IconFont = ControlFont;

    // Override our fonts with a unicode font for languages with special characters
    final String language = configuration.getLanguageTag();
    if (language != null && (language.equals("ja") || language.startsWith("zh") || language.equals("ko"))) {
        // http://propedit.sourceforge.jp/propertieseditor.jnlp
        MenuFont = sansSerifPlain12;
        FixedControlFont = sansSerifPlain12;
        ControlFont = sansSerifPlain12;
        MessageFont = sansSerifPlain12;
        WindowFont = sansSerifPlain12;
        IconFont = sansSerifPlain12;
    }

    UIManager.put("Button.font", ControlFont);
    UIManager.put("CheckBox.font", ControlFont);
    UIManager.put("CheckBoxMenuItem.font", MenuFont);
    UIManager.put("ComboBox.font", ControlFont);
    UIManager.put("EditorPane.font", ControlFont);
    UIManager.put("FileChooser.listFont", IconFont);
    UIManager.put("FormattedTextField.font", ControlFont);
    UIManager.put("InternalFrame.titleFont", WindowFont);
    UIManager.put("Label.font", ControlFont);
    UIManager.put("List.font", ControlFont);
    UIManager.put("PopupMenu.font", MenuFont);
    UIManager.put("Menu.font", MenuFont);
    UIManager.put("MenuBar.font", MenuFont);
    UIManager.put("MenuItem.font", MenuFont);
    UIManager.put("MenuItem.acceleratorFont", MenuFont);
    UIManager.put("RadioButton.font", ControlFont);
    UIManager.put("RadioButtonMenuItem.font", MenuFont);
    UIManager.put("OptionPane.font", MessageFont);
    UIManager.put("OptionPane.messageFont", MessageFont);
    UIManager.put("OptionPane.buttonFont", MessageFont);
    UIManager.put("Panel.font", ControlFont);
    UIManager.put("PasswordField.font", ControlFont);
    UIManager.put("ProgressBar.font", ControlFont);
    UIManager.put("ScrollPane.font", ControlFont);
    UIManager.put("Slider.font", ControlFont);
    UIManager.put("Spinner.font", ControlFont);
    UIManager.put("TabbedPane.font", ControlFont);
    UIManager.put("Table.font", ControlFont);
    UIManager.put("TableHeader.font", ControlFont);
    UIManager.put("TextArea.font", FixedControlFont);
    UIManager.put("TextField.font", ControlFont);
    UIManager.put("TextPane.font", ControlFont);
    UIManager.put("TitledBorder.font", ControlFont);
    UIManager.put("ToggleButton.font", ControlFont);
    UIManager.put("ToolBar.font", MenuFont);
    UIManager.put("ToolTip.font", ToolTipFont);
    UIManager.put("Tree.font", ControlFont);
    UIManager.put("Viewport.font", ControlFont);

    setTitle("Test");
    setIconImage(readImageIcon("icon-32.png").getImage());

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    JComponent jp = buildContent();
    String showScrollbars = System.getProperty("scrollbars", "").toLowerCase();

    /**
     * Handle scrollbars:
     *
     * 1) forced scrollbars (-Dscrollbars=true): always display them
     * 2) optional scrollbars (-Dscrollbars=optional): display them as needed
     * 3) otherwise (default): don't display them
     */
    switch (showScrollbars) {
    case "true":
        setContentPane(new JScrollPane(jp, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS));
        break;
    case "optional":
        setContentPane(new JScrollPane(jp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED));
        break;
    default:
        setContentPane(jp);
        break;
    }

    String projectName = PropertiesUtil.getProjectProperties().get("project.name");
    String projectVersion = PropertiesUtil.getProjectProperties().get("project.version");
    String title = projectName + " " + projectVersion;

    // If the version contains a "-" (e.g. "1.50.1-SNAPSHOT" or "1.50.1-beta1"), add a warning message
    if (projectVersion.indexOf('-') > -1) {
        title = title + " - " + Messages.getString("LooksFrame.26");
    }

    if (PMS.getTraceMode() == 2) {
        // Forced trace mode
        title = title + "  [" + Messages.getString("TracesTab.10").toUpperCase() + "]";
    }

    setTitle(title);
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

    // Display tooltips immediately and for a long time
    ToolTipManager.sharedInstance().setInitialDelay(400);
    ToolTipManager.sharedInstance().setDismissDelay(60000);
    ToolTipManager.sharedInstance().setReshowDelay(400);

    if (!configuration.isMinimized() && System.getProperty(START_SERVICE) == null) {
        setVisible(true);
    }
    BasicSystemUtils.INSTANCE.addSystemTray(this);
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java

/**
 * Creates a JTextArea in a ScrollPane./*from  w w w.j av a 2 s  .  c  o  m*/
 * @return the scollpane
 */
protected JScrollPane createTextArea(final short len, final short rows) {
    ValTextArea textArea = new ValTextArea("", rows, len);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.getDocument().addDocumentListener(docListener);
    JScrollPane taScrollPane = new JScrollPane(textArea);
    taScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    taScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    return taScrollPane;
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

private void peaksDataInitializations() {
    String classElements[] = _ecurveclass.getName().split("\\.");
    elutionTableLabel.setText("<html><body><center>Elution Data<br><font size='-1'>("
            + classElements[classElements.length - 1] + ")</font></center></body></html>");
    elutionTableLabel.setHorizontalAlignment(JLabel.CENTER);
    elutionTableLabel.setHorizontalTextPosition(JLabel.CENTER);

    if (transDefHeader == null || transDefHeader.getAQUApairs() == null
            || transDefHeader.getAQUApairs().size() == 0) {
        buttonFindMate.setVisible(false);
    } else {//from   www . j  a v a2 s .  com
        buttonFindMate.setVisible(true);
    }
    peaksScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    peaksScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    peaksTable = new JTable(new PeaksTableModel());
    //peaksTable.setPreferredScrollableViewportSize(new Dimension(500, 700));
    peaksTable.setSelectionModel(new peaksTableSelectionModel());
    peaksTable.setAutoscrolls(true);
    peaksTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    int totalTableRows = 1;
    for (MRMTransition curTrans : _mrmTransitions)
        totalTableRows += (1 + curTrans.getDaughters().size());
    ((PeaksTableModel) (peaksTable.getModel())).data = new Object[totalTableRows
            - 1][peaksData.values().length];
    for (peaksData pd : EnumSet.allOf(peaksData.class)) {
        peaksTable.getColumnModel().getColumn(pd.colno).setPreferredWidth(pd.colWidth);
    }
    peaksTable.doLayout();
    ((DefaultCellEditor) peaksTable.getDefaultEditor(peaksData.Accept.colClass)).setClickCountToStart(1);
    int i = 0;
    for (MRMTransition curTrans : _mrmTransitions) {
        curTrans.setGraphData(makeParentSeries(curTrans));
        int curPrecursorIndex = i;
        curTrans.setTableRow(curPrecursorIndex);
        for (peaksData pd : EnumSet.allOf(peaksData.class)) {
            ((PeaksTableModel) (peaksTable.getModel())).data[i][pd.colno] = null;
            pd.makeVisible(true);
        }

        ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = null;
        ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Precursor.colno] = curTrans;
        for (MRMDaughter d : curTrans.getDaughters().values()) {
            i++;
            d.setGraphData(d.makeDaughterSeries());
            d.setContinDaughterData(d.makeDaughterSeries(d, true));
            d.setElutionDataTableRow(i);
            ElutionCurveStrategy bes = ElutionCurveStrategy.getInstance(curTrans, d, _ecurveclass);
            bes.calculateParentElutionCurves(null);
            bes.calculateDaughterElutionCurves(null);
            bes.calculateBestCurves();
            d.calculateQuality();
            curTrans.getElutionCurves().put(d, bes);

            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = new Boolean(
                    !Utils.allYsAre0(d));
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Peptide.colno] = "";
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Precursor.colno] = curTrans;
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Daughter.colno] = d;
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.CoStart.colno] = null;
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.CoEnd.colno] = null;
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.CoDelta.colno] = null;
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.AUC.colno] = null;
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MaxPeak.colno] = null;
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MidTime.colno] = null;
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Quality.colno] = null;
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Label.colno] = "";
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Code.colno] = null;
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.LHRatio.colno] = null;
            ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Comment.colno] = "";
            if (transDefHeader != null && transDefHeader.getDToTD() != null
                    && transDefHeader.getDToTD().get(d) != null) {
                TransitionDefinition td = transDefHeader.getDToTD().get(d);
                ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Peptide.colno] = td.getPeptide();
                ((PeaksTableModel) (peaksTable
                        .getModel())).data[curPrecursorIndex][peaksData.Peptide.colno] = td.getPeptide();
                ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Code.colno] = new Integer(
                        td.getAQUAcode());
            }
            ElutionCurve bestPrecursorCurve = bes.getBestParentCurve();
            if (bestPrecursorCurve == null || bestPrecursorCurve.getMinElutionTimeSecs() <= 0.0) {
                ((PeaksTableModel) (peaksTable
                        .getModel())).data[curPrecursorIndex][peaksData.AUC.colno] = new Float(-1);
                ((PeaksTableModel) (peaksTable
                        .getModel())).data[curPrecursorIndex][peaksData.MaxPeak.colno] = new Float(-1);
                ((PeaksTableModel) (peaksTable
                        .getModel())).data[curPrecursorIndex][peaksData.Quality.colno] = new Float(-1);
                ((PeaksTableModel) (peaksTable
                        .getModel())).data[curPrecursorIndex][peaksData.MidTime.colno] = new Float(-1);

            } else {
                ((PeaksTableModel) (peaksTable
                        .getModel())).data[curPrecursorIndex][peaksData.AUC.colno] = new Float(
                                bestPrecursorCurve.getAUC());
                ((PeaksTableModel) (peaksTable
                        .getModel())).data[curPrecursorIndex][peaksData.MaxPeak.colno] = new Float(
                                bestPrecursorCurve.getHighestPointY());
                ((PeaksTableModel) (peaksTable
                        .getModel())).data[curPrecursorIndex][peaksData.Quality.colno] = new Float(
                                curTrans.getQuality());
            }

            ElutionCurve bestDaughterCurve = bes.getBestDaughterCurve();
            if (bestDaughterCurve == null || bestDaughterCurve.getMinElutionTimeSecs() <= 0.0) {
                ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = new Boolean(
                        false);
                ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.AUC.colno] = new Float(-1);
                ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MaxPeak.colno] = new Float(-1);
                ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Quality.colno] = new Float(-1);
                ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MidTime.colno] = new Float(-1);

            } else {
                ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.AUC.colno] = new Float(
                        bestDaughterCurve.getAUC());
                ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.MaxPeak.colno] = new Float(
                        bestDaughterCurve.getHighestPointY());
                d.setBestElutionCurve(bestDaughterCurve);
                ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Quality.colno] = new Float(
                        d.getQuality());
                if (_minPeakCutoff > 0 && bestDaughterCurve.getHighestPointY() < _minPeakCutoff)
                    ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = new Boolean(
                            false);
                if (_minAreaCutoff > 0 && bestDaughterCurve.getAUC() < _minAreaCutoff)
                    ((PeaksTableModel) (peaksTable.getModel())).data[i][peaksData.Accept.colno] = new Boolean(
                            false);
            }
        }
        curTrans.setElutionRegionStart(curTrans.calculateMinOfAllBestDaughterCurves());
        curTrans.setElutionRegionEnd(curTrans.calculateMaxOfAllBestDaughterCurves());
        curTrans.calcMaxYofAllDaughters();
        for (int j = curPrecursorIndex; j <= i; j++) {
            ((PeaksTableModel) (peaksTable.getModel())).data[j][peaksData.CoStart.colno] = new Float(
                    curTrans.getElutionRegionStart());
            ((PeaksTableModel) (peaksTable.getModel())).data[j][peaksData.CoEnd.colno] = new Float(
                    curTrans.getElutionRegionEnd());
            ((PeaksTableModel) (peaksTable.getModel())).data[j][peaksData.CoDelta.colno] = new Float(
                    curTrans.getElutionRegionEnd() - curTrans.getElutionRegionStart());
            ((PeaksTableModel) (peaksTable.getModel())).data[j][peaksData.MidTime.colno] = new Float(
                    curTrans.getCalcXatMaxYAllDaughters());
        }
        i++;
    }

    peaksTable.setDefaultRenderer(MRMTransition.class, new MRMTransitionTableRenderer(false));
    peaksTable.setDefaultRenderer(MRMDaughter.class, new MRMDaughterTableRenderer(false));
    peaksTable.setDefaultRenderer(Number.class, new MRMNumberTableRenderer());
    peaksTable.setDefaultRenderer(Integer.class, new MRMNumberTableRenderer());
    peaksTable.setDefaultRenderer(Boolean.class, new MRMBooleanRenderer());
    peaksTable.getColumnModel().getColumn(peaksData.CoStart.colno).setCellEditor(new NumberTableCellEditor());
    peaksTable.getColumnModel().getColumn(peaksData.CoEnd.colno).setCellEditor(new NumberTableCellEditor());
    peaksTable.getColumnModel().getColumn(peaksData.Code.colno).setCellEditor(new NumberTableCellEditor());
    peaksTable.getColumnModel().getColumn(peaksData.LHRatio.colno).setCellEditor(new NumberTableCellEditor());

    peaksScrollPane.getViewport().setView(peaksTable);

    if (transDefHeader == null) {
        peaksData.Peptide.makeVisible(false);
        peaksData.Label.makeVisible(false);
        peaksData.LHRatio.makeVisible(false);
        peaksData.Code.makeVisible(false);
    } else {
        if (transDefHeader.getAQUApairs() == null || transDefHeader.getAQUApairs().isEmpty()) {
            peaksData.Label.makeVisible(false);
            peaksData.LHRatio.makeVisible(false);
            peaksData.Code.makeVisible(false);
        }
    }

    //  "Quality" column, currently unused, is invisible unless one or more of its
    //  values is not -1          
    peaksData.Quality.makeVisible(!Utils.qualColIsEmpty());

    peaksScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
        public void adjustmentValueChanged(AdjustmentEvent ae) {
            if (!ae.getValueIsAdjusting()) {
                peaksTable.repaint();
            }
        }
    });
    peaksTable.getModel().addTableModelListener(new peaksTableListener());
    _ptmlsl = new PeaksTableListSelectionListener();
    peaksTable.getSelectionModel().addListSelectionListener(_ptmlsl);

}

From source file:sim.util.media.chart.ChartGenerator.java

public void setFixed(boolean value) {
    fixBox.setSelected(value);/* ww  w  . jav a  2 s. co m*/
    chartHolder.setHorizontalScrollBarPolicy(value ? ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
            : ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scaleField.setEnabled(!value);
    if (value)
        scaleField.setText("");
    else {
        double val = scaleField.getValue();
        if (val == (int) val)
            scaleField.setText("" + (int) val);
        else
            scaleField.setText("" + val);
    }
    resizeChart();
}

From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java

public void setFixed(boolean value) {
    fixBox.setSelected(value);// w  w  w .j  av a2s .  c  o  m
    chartHolder.setHorizontalScrollBarPolicy(value ? ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
            : ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scaleField.setEnabled(!value);
    if (value) {
        scaleField.setText("");
    } else {
        double val = scaleField.getValue();
        if (val == (int) val) {
            scaleField.setText("" + (int) val);
        } else {
            scaleField.setText("" + val);
        }
    }
    resizeChart();
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.DataImportDialog.java

/**
* Takes the list of data import errors and displays then to the user
* 
* void/*from   w ww .jav  a 2 s . c  o m*/
*/
protected void showErrors() {
    JList listOfErrors = genListOfErrorWhereTableDataDefiesSizeConstraints(model.getColumnNames(),
            model.getData());

    if ((model.getColumnNames() == null) || (model.getData() == null) || (listOfErrors == null)
            || (listOfErrors.getModel().getSize() == 0)) {
        JTextArea textArea = new JTextArea();
        textArea.setRows(25);
        textArea.setColumns(60);
        //String newline = "\n";
        //for (int i = 0; i < listOfErrors.getModel().getSize(); i++)
        //{
        textArea.append(getResourceString("WB_PARSE_FILE_ERROR2"));
        //}
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setEditable(false);
        textArea.setCaretPosition(0);
        JScrollPane pane = new JScrollPane(textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), pane, getResourceString("DATA_IMPORT_ISSUES"),
                JOptionPane.WARNING_MESSAGE);
        okBtn.setEnabled(false);
    } else if (listOfErrors.getModel().getSize() > 0) {
        JTextArea textArea = new JTextArea();
        textArea.setRows(25);
        textArea.setColumns(60);
        String newline = "\n";
        for (int i = 0; i < listOfErrors.getModel().getSize(); i++) {
            textArea.append((String) listOfErrors.getModel().getElementAt(i) + newline + newline);
        }
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setEditable(false);
        textArea.setCaretPosition(0);
        JScrollPane pane = new JScrollPane(textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), pane, getResourceString("DATA_IMPORT_ISSUES"),
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:ca.phon.ipamap.IpaMap.java

private void init() {
    setLayout(new BorderLayout());

    // favorites//from   w w  w .  j a v a  2s.co m
    IpaGrids favData = getFavData();
    final Grid fg = favData.getGrid().get(0);
    favPanel = getGridPanel(fg);
    favPanel.setCollapsed(getSavedSectionToggle(fg.getName()));
    favToggleButton = getToggleButton(fg, favPanel);
    favToggleButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setSavedSectionToggle(fg.getName(), !getSavedSectionToggle(fg.getName()));
        }
    });

    JPanel favSection = new JPanel(new VerticalLayout(0));
    favSection.add(favToggleButton);
    favSection.add(favPanel);
    favContainer = favSection;

    // search
    Grid emptyGrid = (new ObjectFactory()).createGrid();
    emptyGrid.setName("Search Results (0)");
    emptyGrid.setRows(0);
    emptyGrid.setCols(0);

    searchPanel = getGridPanel(emptyGrid);
    searchToggleButton = getToggleButton(emptyGrid, searchPanel);

    final JButton searchButton = new JButton("Search");
    searchButton.putClientProperty("JComponent.sizeVariant", "small");

    searchButton.addActionListener(this::showSearchFrame);

    JPanel searchSection = new JPanel(new VerticalLayout(0));
    searchSection.add(searchButton);
    searchSection.add(searchToggleButton);
    searchContainer = searchSection;

    // static content
    final JPanel centerPanel = new JPanel(new VerticalLayout(0));
    IpaGrids grids = getGridData();
    for (final Grid grid : grids.getGrid()) {
        final JXCollapsiblePane cp = getGridPanel(grid);

        cp.setCollapsed(getSavedSectionToggle(grid.getName()));
        JXButton toggleBtn = getToggleButton(grid, cp);
        toggleBtn.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                setSavedSectionToggle(grid.getName(), !getSavedSectionToggle(grid.getName()));
            }
        });

        toggleButtons.add(toggleBtn);

        centerPanel.add(toggleBtn);
        centerPanel.add(cp);

        gridPanels.add(cp);
    }

    scrollPane = new JScrollPane(centerPanel);
    scrollPane.setAutoscrolls(true);
    scrollPane.setWheelScrollingEnabled(true);
    //      scrollPane.setViewportView(centerPanel);
    add(scrollPane, BorderLayout.CENTER);

    //      JPanel btmPanel = new JPanel(new BorderLayout());
    //      scalePanel.add(smallLbl, BorderLayout.WEST);
    //      scalePanel.add(scaleSlider, BorderLayout.CENTER);
    //      scalePanel.add(largeLbl, BorderLayout.EAST);

    final JButton scrollBtn = new JButton("-");
    scrollBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            //            popupMenu.show(scrollBtn, 0, scrollBtn.getHeight());
            JPopupMenu ctxMenu = new JPopupMenu();
            setupContextMenu(ctxMenu, scrollBtn);
            ctxMenu.show(scrollBtn, 0, scrollBtn.getHeight());
        }
    });

    //      Font infoFont = new Font("Courier New", Font.PLAIN, 12);
    infoLabel = new JLabel();
    infoLabel.setFont(infoLabel.getFont().deriveFont(Font.ITALIC));
    infoLabel.setText("[]");
    infoLabel.setOpaque(false);

    statusBar = new JXStatusBar();
    statusBar.setLayout(new BorderLayout());
    statusBar.add(infoLabel, BorderLayout.CENTER);

    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, scrollBtn);

    add(statusBar, BorderLayout.SOUTH);

    JPanel topPanel = new JPanel(new VerticalLayout(0));
    topPanel.add(searchSection);
    topPanel.add(favSection);
    add(topPanel, BorderLayout.NORTH);

}

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java

/**
 * create the query builder UI./*from  w w  w. j a  v a  2 s  .co  m*/
 */
protected void createUI() {
    removeAll();

    JMenuItem saveItem = new JMenuItem(UIRegistry.getResourceString("QB_SAVE"));
    Action saveActionListener = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (saveQuery(false)) {
                try {
                    String selId = null;
                    if (selectedQFP != null && selectedQFP.getQueryField() != null) {
                        selId = selectedQFP.getQueryField().getStringId();
                    }
                    final String selectedFldId = selId;
                    setupUI(true);
                    SwingUtilities.invokeLater(new Runnable() {

                        /* (non-Javadoc)
                         * @see java.lang.Runnable#run()
                         */
                        @Override
                        public void run() {
                            if (selectedFldId != null) {
                                for (QueryFieldPanel qfp : queryFieldItems) {
                                    if (qfp.getQueryField() != null
                                            && selectedFldId.equals(qfp.getQueryField().getStringId())) {
                                        selectQFP(qfp);
                                        return;
                                    }
                                }
                                selectQFP(queryFieldItems.get(0));
                            }
                        }

                    });
                } catch (Exception ex) {

                }
                setSaveBtnEnabled(false);
            }
        }
    };
    saveItem.addActionListener(saveActionListener);

    JMenuItem saveAsItem = new JMenuItem(UIRegistry.getResourceString("QB_SAVE_AS"));
    Action saveAsActionListener = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (saveQuery(true)) {
                setSaveBtnEnabled(false);
            }
        }
    };
    saveAsItem.addActionListener(saveAsActionListener);
    JComponent[] itemSample = { saveItem, saveAsItem };
    saveBtn = new DropDownButton(UIRegistry.getResourceString("QB_SAVE"), null, 1,
            java.util.Arrays.asList(itemSample));
    saveBtn.addActionListener(saveActionListener);
    String ACTION_KEY = "SAVE";
    KeyStroke ctrlS = KeyStroke.getKeyStroke(KeyEvent.VK_S,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    InputMap inputMap = saveBtn.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(ctrlS, ACTION_KEY);
    ActionMap actionMap = saveBtn.getActionMap();
    actionMap.put(ACTION_KEY, saveActionListener);
    ACTION_KEY = "SAVE_AS";
    KeyStroke ctrlA = KeyStroke.getKeyStroke(KeyEvent.VK_A,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    inputMap.put(ctrlA, ACTION_KEY);
    actionMap.put(ACTION_KEY, saveAsActionListener);
    saveBtn.setActionMap(actionMap);

    UIHelper.setControlSize(saveBtn);
    //saveBtn.setOverrideBorder(true, BasicBorders.getButtonBorder());

    listBoxPanel = new JPanel(new HorzLayoutManager(2, 2));

    Vector<TableQRI> list = new Vector<TableQRI>();
    for (int k = 0; k < tableTree.getKids(); k++) {
        list.add(tableTree.getKid(k).getTableQRI());
    }

    Collections.sort(list);
    DefaultListModel model = new DefaultListModel();
    for (TableQRI qri : list) {
        model.addElement(qri);
    }

    tableList = new JList(model);
    QryListRenderer qr = new QryListRenderer(IconManager.IconSize.Std16);
    qr.setDisplayKidIndicator(false);
    tableList.setCellRenderer(qr);

    JScrollPane spt = new JScrollPane(tableList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    Dimension pSize = spt.getPreferredSize();
    pSize.height = 200;
    spt.setPreferredSize(pSize);

    JPanel topPanel = new JPanel(new BorderLayout());

    scrollPane = new JScrollPane(listBoxPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    tableList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                int inx = tableList.getSelectedIndex();
                if (inx > -1) {
                    fillNextList(tableList);
                } else {
                    listBoxPanel.removeAll();
                }
            }
        }
    });

    addBtn = new JButton(IconManager.getImage("PlusSign", IconManager.IconSize.Std16));
    addBtn.setEnabled(false);
    addBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            BaseQRI qri = (BaseQRI) listBoxList.get(currentInx).getSelectedValue();
            if (qri.isInUse) {
                return;
            }

            try {
                FieldQRI fieldQRI = buildFieldQRI(qri);
                if (fieldQRI == null) {
                    throw new Exception("null FieldQRI");
                }
                SpQueryField qf = new SpQueryField();
                qf.initialize();
                qf.setFieldName(fieldQRI.getFieldName());
                qf.setStringId(fieldQRI.getStringId());
                query.addReference(qf, "fields");

                if (!isExportMapping) {
                    addQueryFieldItem(fieldQRI, qf, false);
                } else {
                    addNewMapping(fieldQRI, qf, null, false);
                }
            } catch (Exception ex) {
                log.error(ex);
                UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(QueryBldrPane.class, ex);
                return;
            }
        }
    });

    contextPanel = new JPanel(new BorderLayout());
    contextPanel.add(createLabel("Search Context", SwingConstants.CENTER), BorderLayout.NORTH); // I18N
    contextPanel.add(spt, BorderLayout.CENTER);
    contextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));

    JPanel schemaPanel = new JPanel(new BorderLayout());
    schemaPanel.add(scrollPane, BorderLayout.CENTER);

    topPanel.add(contextPanel, BorderLayout.WEST);
    topPanel.add(schemaPanel, BorderLayout.CENTER);
    add(topPanel, BorderLayout.NORTH);

    queryFieldsPanel = new JPanel();
    queryFieldsPanel.setLayout(new NavBoxLayoutManager(0, 2));
    queryFieldsScroll = new JScrollPane(queryFieldsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    queryFieldsScroll.setBorder(null);
    add(queryFieldsScroll);

    //if (!isExportMapping)
    //{
    final JPanel mover = buildMoverPanel(false);
    add(mover, BorderLayout.EAST);
    // }

    String searchLbl = schemaMapping == null ? getResourceString("QB_SEARCH")
            : getResourceString("QB_EXPORT_PREVIEW");
    searchBtn = createButton(searchLbl);
    searchBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            //               int m = ae.getModifiers();
            //               boolean ors = (m & ActionEvent.ALT_MASK) > 0 && (m & ActionEvent.CTRL_MASK) > 0 && (m & ActionEvent.SHIFT_MASK) > 0;
            //               if (ors)
            //               {
            //                  System.out.println("Disjunctional conjoinment desire gesture detected");
            //               }
            //               doSearch(ors);
            doSearch(false);
        }
    });
    distinctChk = createCheckBox(UIRegistry.getResourceString("QB_DISTINCT"));
    distinctChk.setVisible(schemaMapping == null);
    if (schemaMapping == null) {
        distinctChk.setSelected(false);
        distinctChk.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                new SwingWorker() {

                    /* (non-Javadoc)
                     * @see edu.ku.brc.helpers.SwingWorker#construct()
                     */
                    @Override
                    public Object construct() {
                        if (distinctChk.isSelected()) {
                            UsageTracker.incrUsageCount("QB.DistinctOn");
                        } else {
                            UsageTracker.incrUsageCount("QB.DistinctOff");
                        }
                        if ((isTreeLevelSelected() || isAggFieldSelected()) && countOnly
                                && distinctChk.isSelected()) {
                            countOnlyChk.setSelected(false);
                            countOnly = false;
                        }
                        query.setCountOnly(countOnly);
                        query.setSelectDistinct(distinctChk.isSelected());
                        setSaveBtnEnabled(thereAreItems());
                        return null;
                    }
                }.start();
            }
        });
    }
    countOnlyChk = createCheckBox(UIRegistry.getResourceString("QB_COUNT_ONLY"));
    countOnlyChk.setSelected(false);
    countOnlyChk.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            new SwingWorker() {

                /* (non-Javadoc)
                 * @see edu.ku.brc.helpers.SwingWorker#construct()
                 */
                @Override
                public Object construct() {
                    //Don't allow change while query is running.
                    if (runningResults.get() == null) {
                        countOnly = !countOnly;
                        if (countOnly) {
                            UsageTracker.incrUsageCount("QB.CountOnlyOn");
                        } else {
                            UsageTracker.incrUsageCount("QB.CountOnlyOff");
                        }
                        if ((isTreeLevelSelected() || isAggFieldSelected()) && countOnly
                                && (distinctChk.isSelected() || searchSynonymyChk.isSelected())) {
                            distinctChk.setSelected(false);
                            searchSynonymyChk.setSelected(false);
                        }
                    } else {
                        //This might be awkward and/or klunky...
                        countOnlyChk.setSelected(countOnly);
                    }
                    query.setCountOnly(countOnly);
                    query.setSelectDistinct(distinctChk.isSelected());
                    setSaveBtnEnabled(thereAreItems());
                    return null;
                }
            }.start();
        }
    });

    searchSynonymyChk = createCheckBox(UIRegistry.getResourceString("QB_SRCH_SYNONYMS"));
    searchSynonymyChk.setSelected(searchSynonymy);
    searchSynonymyChk.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            new SwingWorker() {

                /* (non-Javadoc)
                 * @see edu.ku.brc.helpers.SwingWorker#construct()
                 */
                @Override
                public Object construct() {
                    searchSynonymy = !searchSynonymy;
                    if (!searchSynonymy) {
                        UsageTracker.incrUsageCount("QB.SearchSynonymyOff");
                    } else {
                        UsageTracker.incrUsageCount("QB.SearchSynonymyOn");
                    }
                    if (isTreeLevelSelected() && countOnly && searchSynonymyChk.isSelected()) {
                        countOnlyChk.setSelected(false);
                        countOnly = false;
                    }
                    query.setSearchSynonymy(searchSynonymy);
                    setSaveBtnEnabled(thereAreItems());
                    return null;
                }
            }.start();
        }
    });

    smushedChk = createCheckBox(UIRegistry.getResourceString("QB_SMUSH_RESULTS"));
    smushedChk.setVisible(isSmushableContext());
    if (isSmushableContext()) {
        smushedChk.setSelected(smushed);
        smushedChk.setToolTipText(
                String.format(UIRegistry.getResourceString("QB_SMUSH_RESULTS_HINT"), getCatalogNumberTitle()));
        smushedChk.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                new SwingWorker() {

                    /*
                     * (non-Javadoc)
                     * 
                     * @see edu.ku.brc.helpers.SwingWorker#construct()
                     */
                    @Override
                    public Object construct() {
                        smushed = !smushed;
                        if (!smushed) {
                            UsageTracker.incrUsageCount("QB.SmushedOff");
                        } else {
                            UsageTracker.incrUsageCount("QB.SmushedOn");
                        }
                        query.setSmushed(smushed);
                        setSaveBtnEnabled(thereAreItems());
                        return null;
                    }
                }.start();
            }
        });
    }

    PanelBuilder outer = new PanelBuilder(
            new FormLayout("p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 6dlu, p", "p"));

    CellConstraints cc = new CellConstraints();
    outer.add(smushedChk, cc.xy(1, 1));
    outer.add(searchSynonymyChk, cc.xy(3, 1));
    outer.add(distinctChk, cc.xy(5, 1));
    outer.add(countOnlyChk, cc.xy(7, 1));
    outer.add(searchBtn, cc.xy(9, 1));
    outer.add(saveBtn, cc.xy(11, 1));

    JPanel bottom = new JPanel(new BorderLayout());
    bottom.add(outer.getPanel(), BorderLayout.EAST);

    JButton helpBtn = UIHelper.createHelpIconButton(getHelpBtnContext());
    bottom.add(helpBtn, BorderLayout.WEST);
    add(bottom, BorderLayout.SOUTH);

    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.DataImportDialog.java

/**
 * Adds table to scrollpanel/*from w  w  w  .j a v  a  2s  . c  om*/
 * @param t - the table to be displayed in the preview pane
 * @return
 * JScrollPane
 */
private JScrollPane addtoScroll(JTable t) {
    JScrollPane pane = new JScrollPane(t, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    return pane;
}