Search in sources :

Example 51 with JScrollBar

use of javax.swing.JScrollBar in project Malai by arnobl.

the class MoveCamera method doActionBody.

@Override
protected void doActionBody() {
    final JScrollBar hor = scrollPane.getHorizontalScrollBar();
    final JScrollBar ver = scrollPane.getVerticalScrollBar();
    if (hor != null)
        moveScrollBar(hor, (int) (px - hor.getWidth() / 2.0));
    if (ver != null)
        moveScrollBar(ver, (int) (py - ver.getHeight() / 2.0));
}
Also used : JScrollBar(javax.swing.JScrollBar)

Example 52 with JScrollBar

use of javax.swing.JScrollBar in project chatty by chatty.

the class ModerationLog method printLine.

private void printLine(JTextArea text, String line) {
    try {
        Document doc = text.getDocument();
        String linebreak = doc.getLength() > 0 ? "\n" : "";
        doc.insertString(doc.getLength(), linebreak + line, null);
        JScrollBar bar = scroll.getVerticalScrollBar();
        boolean scrollDown = bar.getValue() > bar.getMaximum() - bar.getVisibleAmount() - 4;
        if (scrollDown) {
            scrollDown();
        }
        clearSomeChat(doc);
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}
Also used : Document(javax.swing.text.Document) BadLocationException(javax.swing.text.BadLocationException) JScrollBar(javax.swing.JScrollBar)

Example 53 with JScrollBar

use of javax.swing.JScrollBar in project clusterMaker2 by RBVI.

the class KnnDendroView method setupViews.

/**
 *  This method should be called only during initial setup of the modelview
 *
 *  It sets up the views and binds them all to config nodes.
 */
protected void setupViews() {
    DataModel knnModel = getDataModel();
    hintpanel = new MessagePanel("Usage Hints");
    statuspanel = new MessagePanel("View Status");
    colorPresets = new ColorPresets(root);
    cpresetEditor = new ColorPresetEditor(colorPresets);
    ColorExtractor colorExtractor = new ColorExtractor();
    colorExtractor.setDefaultColorSet(colorPresets.getDefaultColorSet());
    colorExtractor.bindConfig(root);
    colorExtractor.setMissing(DataModel.NODATA, DataModel.EMPTY);
    KnnArrayDrawer kArrayDrawer = new KnnArrayDrawer();
    kArrayDrawer.setColorExtractor(colorExtractor);
    arrayDrawer = kArrayDrawer;
    // XXX shouldn't need to observer, should be immuable?
    ((Observable) getDataModel()).addObserver(arrayDrawer);
    globalview = new GlobalView();
    // scrollbars, mostly used by maps
    globalXscrollbar = new JScrollBar(JScrollBar.HORIZONTAL, 0, 1, 0, 1);
    globalYscrollbar = new JScrollBar(JScrollBar.VERTICAL, 0, 1, 0, 1);
    zoomXscrollbar = new JScrollBar(JScrollBar.HORIZONTAL, 0, 1, 0, 1);
    zoomYscrollbar = new JScrollBar(JScrollBar.VERTICAL, 0, 1, 0, 1);
    zoomXmap = new MapContainer();
    zoomXmap.setDefaultScale(12.0);
    zoomXmap.setScrollbar(zoomXscrollbar);
    zoomYmap = new MapContainer();
    zoomYmap.setDefaultScale(12.0);
    zoomYmap.setScrollbar(zoomYscrollbar);
    // globalmaps tell globalview, atrview, and gtrview
    // where to draw each data point.
    // the scrollbars "scroll" by communicating with the maps.
    globalXmap = new MapContainer();
    globalXmap.setDefaultScale(2.0);
    globalXmap.setScrollbar(globalXscrollbar);
    globalYmap = new MapContainer();
    globalYmap.setDefaultScale(2.0);
    globalYmap.setScrollbar(globalYscrollbar);
    globalview.setXMap(globalXmap);
    globalview.setYMap(globalYmap);
    globalview.setZoomYMap(getZoomYmap());
    globalview.setZoomXMap(getZoomXmap());
    arraynameview = new ArrayNameView(getDataModel().getArrayHeaderInfo());
    leftTreeDrawer = new LeftTreeDrawer();
    gtrview = new GTRView();
    gtrview.setMap(globalYmap);
    gtrview.setLeftTreeDrawer(leftTreeDrawer);
    invertedTreeDrawer = new InvertedTreeDrawer();
    atrview = new ATRView();
    atrview.setMap(globalXmap);
    atrview.setInvertedTreeDrawer(invertedTreeDrawer);
    atrzview = new ATRZoomView();
    atrzview.setZoomMap(getZoomXmap());
    atrzview.setInvertedTreeDrawer(invertedTreeDrawer);
    zoomview = new ZoomView();
    zoomview.setYMap(getZoomYmap());
    zoomview.setXMap(getZoomXmap());
    zoomview.setArrayDrawer(arrayDrawer);
    globalview.setArrayDrawer(arrayDrawer);
    arraynameview.setMapping(getZoomXmap());
    textview = new TextViewManager(getDataModel().getGeneHeaderInfo());
    textview.setMap(getZoomYmap());
    doDoubleLayout();
    // reset persistent popups
    settingsFrame = null;
    // color extractor
    colorExtractor.bindConfig(getFirst("ColorExtractor"));
    // set data first to avoid adding auto-genereated contrast to documentConfig.
    kArrayDrawer.setDataMatrix(knnModel.getDataMatrix());
    kArrayDrawer.bindConfig(getFirst("ArrayDrawer"));
    // responsible for adding and removing components...
    bindTrees();
    globalXmap.bindConfig(getFirst("GlobalXMap"));
    globalYmap.bindConfig(getFirst("GlobalYMap"));
    getZoomXmap().bindConfig(getFirst("ZoomXMap"));
    getZoomYmap().bindConfig(getFirst("ZoomYMap"));
    textview.bindConfig(getFirst("TextViewParent"));
    arraynameview.bindConfig(getFirst("ArrayNameView"));
    // perhaps I could remember this stuff in the MapContainer...
    DataMatrix dataMatrix = getDataModel().getDataMatrix();
    globalXmap.setIndexRange(0, dataMatrix.getNumCol() - 1);
    globalYmap.setIndexRange(0, dataMatrix.getNumRow() - 1);
    getZoomXmap().setIndexRange(-1, -1);
    getZoomYmap().setIndexRange(-1, -1);
    globalXmap.notifyObservers();
    globalYmap.notifyObservers();
    getZoomXmap().notifyObservers();
    getZoomYmap().notifyObservers();
}
Also used : DataMatrix(edu.ucsf.rbvi.clusterMaker2.internal.treeview.DataMatrix) Observable(java.util.Observable) JScrollBar(javax.swing.JScrollBar) DataModel(edu.ucsf.rbvi.clusterMaker2.internal.treeview.DataModel) MessagePanel(edu.ucsf.rbvi.clusterMaker2.internal.treeview.MessagePanel)

Example 54 with JScrollBar

use of javax.swing.JScrollBar in project wechat by dllwh.

the class CodeHelper method createView.

/**
 * ----------------------------------------------------- Fields end
 */
/**
 * @方法:创建UI
 * @创建人:独泪了无痕
 */
public static void createView() {
    final JTabbedPane tab = new JTabbedPane();
    JPanel topPanel = new JPanel();
    BoxLayout boxLayout = new BoxLayout(topPanel, BoxLayout.Y_AXIS);
    topPanel.setLayout(boxLayout);
    topPanel.add(getFieldByText("驱动", driverField));
    topPanel.add(getFieldByText("URL", urlField));
    topPanel.add(getFieldByText("用户名", usernameField));
    topPanel.add(getFieldByText("密码", passwordField));
    topPanel.add(getFieldByText("数据库表", tableField));
    topPanel.add(getFieldByText("基础路径", packageField));
    topPanel.add(getFieldSpecial("操作"));
    topPanel.setPreferredSize(new Dimension(0, 270));
    JPanel centerPanel = new JPanel(new BorderLayout());
    centerPanel.add(tab, BorderLayout.CENTER);
    JScrollPane beanScroll = setTextAreaByTab(beanText);
    final JScrollBar beanScrollBar = beanScroll.getVerticalScrollBar();
    beanScrollBar.setUnitIncrement(100);
    codeButton.setEnabled(false);
    // 测试链接
    connButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent event) {
            try {
                if (checkParam() && getConnection()) {
                    showMessageDialog("连接成功", JOptionPane.INFORMATION_MESSAGE);
                    setEditable(false);
                    codeButton.setEnabled(true);
                    // 生成代码
                    codeButton.addMouseListener(new MouseAdapter() {

                        @Override
                        public void mouseClicked(MouseEvent event) {
                            try {
                                createCode();
                            } catch (Exception e) {
                                e.printStackTrace();
                                showMessageDialog(e.getMessage(), JOptionPane.ERROR_MESSAGE);
                            } finally {
                                tab.setSelectedIndex(0);
                                beanScrollBar.setValue(beanScrollBar.getMinimum());
                            }
                        }
                    });
                } else {
                    showMessageDialog("无法连接,请检查参数配置是否正常", JOptionPane.ERROR_MESSAGE);
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                tab.setSelectedIndex(0);
                beanScrollBar.setValue(beanScrollBar.getMinimum());
            }
        }
    });
    mybatisText.setBorder(BorderFactory.createEtchedBorder());
    beanText.setBorder(BorderFactory.createEtchedBorder());
    tab.addTab("Bean 代码", beanScroll);
    tab.addTab("Service 接口", setTextAreaByTab(serviceText));
    tab.addTab("Service 实现", setTextAreaByTab(serviceImplText));
    tab.addTab("Dao 实现", setTextAreaByTab(daoText));
    tab.addTab("MyBatis 配置", setTextAreaByTab(mybatisText));
    // 使窗体可视
    frame.setVisible(true);
    // 设置窗体大小
    frame.setSize(800, 700);
    frame.setLayout(new BorderLayout());
    frame.add(topPanel, BorderLayout.NORTH);
    frame.add(centerPanel, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
// frame.setExtendedState(JFrame.MAXIMIZED_BOTH); // 设置窗体全屏显示
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) BorderLayout(java.awt.BorderLayout) JTabbedPane(javax.swing.JTabbedPane) BoxLayout(javax.swing.BoxLayout) MouseAdapter(java.awt.event.MouseAdapter) Dimension(java.awt.Dimension) JScrollBar(javax.swing.JScrollBar)

Example 55 with JScrollBar

use of javax.swing.JScrollBar in project browsermator by pcalkins.

the class STAppController method AddMainAppListeners.

public void AddMainAppListeners() {
    mainAppFrame.addAboutMenuItemActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            new AboutBox(ProgramVersion);
        }
    });
    mainAppFrame.addExitMenuActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            int closure = 0;
            int number_of_windows_to_close = 0;
            int last_window_index = MDIViewClasses.size() - 1;
            for (int x = last_window_index; x > -1; x--) {
                closure = CheckToSaveChanges(MDIViewClasses.get(x), MDIDataClasses.get(x), true);
                if (closure == 1) {
                    MDIViewClasses.get(x).setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
                } else {
                    MDIViewClasses.get(x).setDefaultCloseOperation(DISPOSE_ON_CLOSE);
                    number_of_windows_to_close++;
                }
            }
            if (number_of_windows_to_close == MDIViewClasses.size()) {
                for (int x = 0; x < number_of_windows_to_close; x++) {
                    MDIViewClasses.remove(MDIViewClasses.size() - 1);
                    MDIDataClasses.remove(MDIDataClasses.size() - 1);
                }
            }
            if (MDIViewClasses.size() == 0) {
                Properties newProps = new Properties();
                Boolean file_exists = false;
                try {
                    File f = new File(BrowsermatorAppFolder + "browsermator_config.properties");
                    FileInputStream input = new FileInputStream(BrowsermatorAppFolder + "browsermator_config.properties");
                    newProps.load(input);
                    newProps.setProperty("main_window_locationY", Integer.toString(mainAppFrame.getY()));
                    newProps.setProperty("main_window_locationX", Integer.toString(mainAppFrame.getX()));
                    newProps.setProperty("main_window_sizeWidth", Integer.toString(mainAppFrame.getWidth()));
                    newProps.setProperty("main_window_sizeHeight", Integer.toString(mainAppFrame.getHeight()));
                    FileWriter writer = new FileWriter(BrowsermatorAppFolder + "browsermator_config.properties");
                    newProps.store(writer, "browsermator_settings");
                    writer.close();
                } catch (Exception e) {
                    System.out.println("Exception: " + e);
                }
                System.exit(0);
            }
        }
    });
    mainAppFrame.addFileMenuImportActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            CurrentMDIWindowIndex = GetCurrentWindow();
            if (CurrentMDIWindowIndex != -1) {
                File[] newfiles = BrowseForFile();
                if (newfiles != null) {
                    ImportFileFunct(newfiles, CurrentMDIWindowIndex);
                }
            } else {
                JOptionPane.showMessageDialog(null, "No Active Window to import into. Click to select a Window.", "No Selected Window", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });
    mainAppFrame.addFileMenuSaveActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            CurrentMDIWindowIndex = GetCurrentWindow();
            if (CurrentMDIWindowIndex != -1) {
                SeleniumTestToolData STAppData = MDIDataClasses.get(CurrentMDIWindowIndex);
                SeleniumTestTool STAppFrame = MDIViewClasses.get(CurrentMDIWindowIndex);
                ThreadSaveFile(mainAppFrame, STAppFrame, STAppData, false, false);
            } else {
                JOptionPane.showMessageDialog(null, "No Active Window to save. Click to select a Window.", "No Selected Window", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });
    mainAppFrame.addFileMenuCloseActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            CurrentMDIWindowIndex = GetCurrentWindow();
            if (CurrentMDIWindowIndex != -1) {
                SeleniumTestTool STAppFrame = MDIViewClasses.get(CurrentMDIWindowIndex);
                SeleniumTestToolData STAppData = MDIDataClasses.get(CurrentMDIWindowIndex);
                int closed = CheckToSaveChanges(STAppFrame, STAppData, false);
                if (closed == 1) {
                    STAppFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
                } else {
                    // RemoveWindow(MDIClasses.size()-1);
                    int thisMDIIndex = GetCurrentWindow();
                    RemoveWindow(thisMDIIndex);
                    STAppFrame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
                    STAppFrame.dispose();
                }
            } else {
                JOptionPane.showMessageDialog(null, "No Active Window to close. Click to select a Window.", "No Selected Window", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });
    mainAppFrame.addFileMenuBrowseCloudMenuItemActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            OpenBrowserMatorCloud();
        }
    });
    mainAppFrame.addFileMenuuploadFileToCloudMenuItemActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            CurrentMDIWindowIndex = GetCurrentWindow();
            if (CurrentMDIWindowIndex != -1) {
                SeleniumTestTool STAppFrame = MDIViewClasses.get(CurrentMDIWindowIndex);
                SeleniumTestToolData STAppData = MDIDataClasses.get(CurrentMDIWindowIndex);
                UploadFile(STAppFrame, STAppData, true, false);
            } else {
                JOptionPane.showMessageDialog(null, "No Active Window to save. Click to select a Window.", "No Selected Window", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });
    mainAppFrame.addFileMenuSaveAsActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            CurrentMDIWindowIndex = GetCurrentWindow();
            if (CurrentMDIWindowIndex != -1) {
                SeleniumTestToolData STAppData = MDIDataClasses.get(CurrentMDIWindowIndex);
                SeleniumTestTool STAppFrame = MDIViewClasses.get(CurrentMDIWindowIndex);
                ThreadSaveFile(mainAppFrame, STAppFrame, STAppData, true, false);
            } else {
                JOptionPane.showMessageDialog(null, "No Active Window to save. Click to select a Window.", "No Selected Window", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });
    mainAppFrame.addFileMenuNewActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            String filename = "";
            if (MDIViewClasses.size() == 0) {
                filename = "untitled";
            } else {
                filename = "untitled" + MDIViewClasses.size();
            }
            ArrayList<ProcedureView> blankprocviews = new ArrayList<ProcedureView>();
            ArrayList<Procedure> blankprocs = new ArrayList<Procedure>();
            SeleniumTestToolData STAppData = new SeleniumTestToolData(blankprocs);
            STAppData.setFilenames(filename);
            STAppData.setTargetBrowser("Chrome");
            STAppData.setTargetBrowser("Chrome");
            STAppData.setOSType("Windows32");
            STAppData.setIsTemplateOrNew(true);
            SeleniumTestTool STAppFrame = new SeleniumTestTool(STAppData);
            STAppFrame.setFilename(filename);
            STAppFrame.ShowStoredVarControls(false);
            STAppFrame.setClosable(true);
            STAppFrame.setMaximizable(true);
            STAppFrame.setResizable(true);
            MDIViewClasses.add(STAppFrame);
            MDIDataClasses.add(STAppData);
            DisplayWindow(MDIViewClasses.size() - 1);
            STAppFrame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() {

                @Override
                public void internalFrameClosing(InternalFrameEvent e) {
                    int closed = CheckToSaveChanges(STAppFrame, STAppData, false);
                    if (closed == 1) {
                        STAppFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
                    } else {
                        int thisMDIIndex = GetCurrentWindow();
                        RemoveWindow(thisMDIIndex);
                        // RemoveWindow(MDIClasses.size()-1);
                        STAppFrame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
                    }
                }
            });
            STAppFrame.addjButtonDoStuffActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    RunActions(STAppFrame, STAppData);
                }
            });
            STAppFrame.addjButtonClearEmailSettingsListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    STAppFrame.ClearEmailSettings();
                    STAppData.ClearEmailSettings();
                }
            });
            STAppFrame.addjButtonLoadEmailSettingsListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    try {
                        STAppData.loadGlobalEmailSettings();
                        STAppFrame.setEmailSettings(STAppData);
                    } catch (Exception ex) {
                        System.out.println("Exception loading global email settings: " + ex.toString());
                    }
                }
            });
            STAppFrame.addTargetBrowserItemListener(new ItemListener() {

                public void itemStateChanged(ItemEvent e) {
                    if ((e.getStateChange() == ItemEvent.SELECTED)) {
                        Object ActionType = e.getItem();
                        String TargetBrowser = ActionType.toString();
                        STAppFrame.setTargetBrowserView(TargetBrowser);
                        STAppData.changes = true;
                    }
                }
            });
            STAppFrame.addjButtonGutsViewActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    showGuts(STAppFrame, STAppData);
                }
            });
            STAppFrame.addjButtonNewBugActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    STAppFrame.saveState();
                    int insertionPoint = STAppFrame.getInsertionPoint();
                    STAppData.AddNewBug(insertionPoint);
                    STAppFrame.AddNewBugView(insertionPoint);
                    int last_added_bug_index = insertionPoint - 1;
                    ProcedureView newbugview = STAppFrame.BugViewArray.get(last_added_bug_index);
                    Procedure newbug = STAppData.BugArray.get(last_added_bug_index);
                    AddNewHandlers(STAppFrame, STAppData, newbugview, newbug);
                    STAppFrame.UpdateDisplay();
                    JScrollBar vertical = STAppFrame.MainScrollPane.getVerticalScrollBar();
                    vertical.setValue(vertical.getMaximum());
                }
            });
            STAppFrame.addjButtonNewDataLoopActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    STAppFrame.saveState();
                    int insertionPoint = STAppFrame.getInsertionPoint();
                    STAppData.AddNewDataLoop(insertionPoint);
                    STAppFrame.AddNewDataLoopView(insertionPoint);
                    int last_added_bug_index = insertionPoint - 1;
                    ProcedureView newbugview = STAppFrame.BugViewArray.get(last_added_bug_index);
                    Procedure newbug = STAppData.BugArray.get(last_added_bug_index);
                    AddNewHandlers(STAppFrame, STAppData, newbugview, newbug);
                    AddLoopHandlers(STAppFrame, STAppData, newbugview, newbug);
                    STAppFrame.UpdateDisplay();
                    JScrollBar vertical = STAppFrame.MainScrollPane.getVerticalScrollBar();
                    vertical.setValue(vertical.getMaximum());
                }
            });
        }
    });
    mainAppFrame.addFileMenuOpenActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            File[] newfiles = BrowseForFile();
            if (newfiles != null) {
                for (int fileindex = 0; fileindex < newfiles.length; fileindex++) {
                    OpenFile(newfiles[fileindex], false);
                }
            }
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) ActionEvent(java.awt.event.ActionEvent) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) InternalFrameEvent(javax.swing.event.InternalFrameEvent) Properties(java.util.Properties) JScrollBar(javax.swing.JScrollBar) FileInputStream(java.io.FileInputStream) PropertyVetoException(java.beans.PropertyVetoException) GeneralSecurityException(java.security.GeneralSecurityException) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) ActionListener(java.awt.event.ActionListener) InternalFrameAdapter(javax.swing.event.InternalFrameAdapter) ItemListener(java.awt.event.ItemListener) File(java.io.File)

Aggregations

JScrollBar (javax.swing.JScrollBar)60 Dimension (java.awt.Dimension)12 Point (java.awt.Point)12 JScrollPane (javax.swing.JScrollPane)10 JLabel (javax.swing.JLabel)7 JPanel (javax.swing.JPanel)6 Component (java.awt.Component)5 JTabbedPane (javax.swing.JTabbedPane)5 JTextArea (javax.swing.JTextArea)5 GridBagConstraints (java.awt.GridBagConstraints)4 Insets (java.awt.Insets)4 ActionEvent (java.awt.event.ActionEvent)4 JPopupMenu (javax.swing.JPopupMenu)4 JViewport (javax.swing.JViewport)4 Color (java.awt.Color)3 GridBagLayout (java.awt.GridBagLayout)3 ActionListener (java.awt.event.ActionListener)3 AdjustmentEvent (java.awt.event.AdjustmentEvent)3 AdjustmentListener (java.awt.event.AdjustmentListener)3 IOException (java.io.IOException)3