Example usage for java.awt AWTEvent getID

List of usage examples for java.awt AWTEvent getID

Introduction

In this page you can find the example usage for java.awt AWTEvent getID.

Prototype

public int getID() 

Source Link

Document

Returns the event type.

Usage

From source file:com.moneydance.modules.features.mdvenmoimporter.VenmoImporterWindow.java

public final void processEvent(AWTEvent evt) {
    if (evt.getID() == WindowEvent.WINDOW_CLOSING) {
        extension.closeConsole();//  www.j  av a2 s. co  m
        return;
    }
    if (evt.getID() == WindowEvent.WINDOW_OPENED) {
    }
    super.processEvent(evt);
}

From source file:EventDispatchThreadHangMonitor.java

/**
 * Overrides EventQueue.dispatchEvent to call our pre and post hooks either
 * side of the system's event dispatch code.
 */// www . java2s  .  c  om
@Override
protected void dispatchEvent(AWTEvent event) {
    try {
        preDispatchEvent();
        super.dispatchEvent(event);
    } finally {
        postDispatchEvent();
        if (!haveShownSomeComponent && event instanceof WindowEvent
                && event.getID() == WindowEvent.WINDOW_OPENED) {
            haveShownSomeComponent = true;
        }
    }
}

From source file:org.eclipse.jubula.rc.swing.listener.ComponentHandler.java

/**
 * {@inheritDoc}/*from   w w  w  .j a  va2 s.  com*/
 */
public void eventDispatched(AWTEvent event) {

    final ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
    try {
        if (log.isDebugEnabled()) {
            log.debug(event.paramString());
        }
        final int id = event.getID();
        ComponentEvent componentEvent;
        switch (id) {
        case WindowEvent.WINDOW_ACTIVATED:
        case WindowEvent.WINDOW_OPENED:
            // add recursivly all components to AUTHierarchy 
            // and create names for unnamed components
            Window window = ((WindowEvent) event).getWindow();
            autHierarchy.add(window);
            break;
        case ContainerEvent.COMPONENT_ADDED:
            checkContainerListener((ContainerEvent) event);
            break;
        case ComponentEvent.COMPONENT_HIDDEN:
            componentEvent = (ComponentEvent) event;
            if (!hasListener(componentEvent.getComponent(), ComponentListener.class)) {
                autHierarchy.componentHidden(componentEvent);
            }
            break;
        case ComponentEvent.COMPONENT_SHOWN:
            componentEvent = (ComponentEvent) event;
            if (!hasListener(componentEvent.getComponent(), ComponentListener.class)) {
                autHierarchy.componentShown(componentEvent);
            }
            break;
        default:
            // do nothing
        }
        if (AUTServer.getInstance().getMode() == ChangeAUTModeMessage.OBJECT_MAPPING) {

            AUTServer.getInstance().updateHighLighter();
        }
    } catch (Throwable t) {
        log.error("exception during ComponentHandler", t); //$NON-NLS-1$
    } finally {
        Thread.currentThread().setContextClassLoader(originalCL);
    }
}

From source file:org.tinymediamanager.ui.MainWindow.java

/**
 * Initialize the contents of the frame.
 *///from  w w w . ja  va 2 s.c  o m
private void initialize() {
    // set the logo
    setIconImages(LOGOS);
    setBounds(5, 5, 1100, 727);
    // do nothing, we have our own windowClosing() listener
    // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    JLayeredPane content = new JLayeredPane();
    content.setLayout(new FormLayout(
            new ColumnSpec[] { ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("right:270px"), },
            new RowSpec[] { RowSpec.decode("fill:max(500px;default):grow"), }));
    getContentPane().add(content, BorderLayout.CENTER);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow") },
            new RowSpec[] { RowSpec.decode("fill:max(500px;default):grow") }));
    content.add(mainPanel, "1, 1, 3, 1, fill, fill");
    content.setLayer(mainPanel, 1);

    JTabbedPane tabbedPane = VerticalTextIcon.createTabbedPane(JTabbedPane.LEFT);
    tabbedPane.setTabPlacement(JTabbedPane.LEFT);
    mainPanel.add(tabbedPane, "1, 1, fill, fill");
    // getContentPane().add(tabbedPane, "1, 2, fill, fill");

    panelStatusBar = new StatusBar();
    getContentPane().add(panelStatusBar, BorderLayout.SOUTH);

    panelMovies = new MoviePanel();
    VerticalTextIcon.addTab(tabbedPane, BUNDLE.getString("tmm.movies"), panelMovies); //$NON-NLS-1$

    panelMovieSets = new MovieSetPanel();
    VerticalTextIcon.addTab(tabbedPane, BUNDLE.getString("tmm.moviesets"), panelMovieSets); //$NON-NLS-1$

    panelTvShows = new TvShowPanel();
    VerticalTextIcon.addTab(tabbedPane, BUNDLE.getString("tmm.tvshows"), panelTvShows); //$NON-NLS-1$

    // shutdown listener - to clean database connections safely
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            closeTmm();
        }
    });

    MessageManager.instance.addListener(TmmUIMessageCollector.instance);

    // mouse event listener for context menu
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        @Override
        public void eventDispatched(AWTEvent arg0) {
            if (arg0 instanceof MouseEvent && MouseEvent.MOUSE_RELEASED == arg0.getID()
                    && arg0.getSource() instanceof JTextComponent) {
                MouseEvent me = (MouseEvent) arg0;
                JTextComponent tc = (JTextComponent) arg0.getSource();
                if (me.isPopupTrigger() && tc.getComponentPopupMenu() == null) {
                    TextFieldPopupMenu.buildCutCopyPaste().show(tc, me.getX(), me.getY());
                }
            }
        }
    }, AWTEvent.MOUSE_EVENT_MASK);

    // temp info for users using Java 6
    if (SystemUtils.IS_JAVA_1_6) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(MainWindow.this, BUNDLE.getString("tmm.java6")); //$NON-NLS-1$
            }
        });
    }

    // inform user is MI could not be loaded
    if (Platform.isLinux() && StringUtils.isBlank(MediaInfo.version())) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(MainWindow.this, BUNDLE.getString("mediainfo.failed.linux")); //$NON-NLS-1$
            }
        });
    }
}

From source file:CodePointInputMethod.java

/**
 * This is the input method's main routine.  The composed text is stored
 * in buffer.//from   www . j  av  a 2 s .  co m
 */
public void dispatchEvent(AWTEvent event) {
    // This input method handles KeyEvent only.
    if (!(event instanceof KeyEvent)) {
        return;
    }

    KeyEvent e = (KeyEvent) event;
    int eventID = event.getID();
    boolean notInCompositionMode = buffer.length() == 0;

    if (eventID == KeyEvent.KEY_PRESSED) {
        // If we are not in composition mode, pass through
        if (notInCompositionMode) {
            return;
        }

        switch (e.getKeyCode()) {
        case KeyEvent.VK_LEFT:
            moveCaretLeft();
            break;
        case KeyEvent.VK_RIGHT:
            moveCaretRight();
            break;
        }
    } else if (eventID == KeyEvent.KEY_TYPED) {
        char c = e.getKeyChar();

        // If we are not in composition mode, wait a back slash
        if (notInCompositionMode) {
            // If the type character is not a back slash, pass through
            if (c != '\\') {
                return;
            }

            startComposition(); // Enter to composition mode
        } else {
            switch (c) {
            case ' ': // Exit from composition mode
                finishComposition();
                break;
            case '\u007f': // Delete
                deleteCharacter();
                break;
            case '\b': // BackSpace
                deletePreviousCharacter();
                break;
            case '\u001b': // Escape
                cancelComposition();
                break;
            case '\n': // Return
            case '\t': // Tab
                sendCommittedText();
                break;
            default:
                composeUnicodeEscape(c);
                break;
            }
        }
    } else { // KeyEvent.KEY_RELEASED
        // If we are not in composition mode, pass through
        if (notInCompositionMode) {
            return;
        }
    }

    e.consume();
}

From source file:com.hp.alm.ali.idea.content.taskboard.TaskBoardPanel.java

public TaskBoardPanel(final Project project) {
    super(new BorderLayout());

    this.project = project;

    status = new EntityStatusPanel(project);
    queue = new QueryQueue(project, status, false);

    entityService = project.getComponent(EntityService.class);
    entityService.addEntityListener(this);
    sprintService = project.getComponent(SprintService.class);
    sprintService.addListener(this);

    loadTasks();// w  w w .j a  v  a2 s.  c  om

    header = new Header();
    columnHeader = new ColumnHeader();

    content = new Content();
    add(content, BorderLayout.NORTH);

    header.assignedTo.reload();

    // force mouse-over task as visible (otherwise events are captured by the overlay and repaint quirks)
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        @Override
        public void eventDispatched(AWTEvent event) {
            if (isShowing() && event.getID() == MouseEvent.MOUSE_MOVED) {
                MouseEvent m = (MouseEvent) event;
                TaskPanel currentPanel = locateContainer(m, TaskPanel.class);
                if (currentPanel != null) {
                    if (forcedTaskPanel == currentPanel) {
                        return;
                    } else if (forcedTaskPanel != null) {
                        forcedTaskPanel.removeForcedMatch(this);
                    }
                    forcedTaskPanel = currentPanel;
                    forcedTaskPanel.addForcedMatch(this);
                } else if (forcedTaskPanel != null) {
                    forcedTaskPanel.removeForcedMatch(this);
                    forcedTaskPanel = null;
                }
            }
        }
    }, AWTEvent.MOUSE_MOTION_EVENT_MASK);

    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        @Override
        public void eventDispatched(AWTEvent event) {
            if (isShowing()) {
                MouseEvent m = (MouseEvent) event;
                switch (event.getID()) {
                case MouseEvent.MOUSE_PRESSED:
                case MouseEvent.MOUSE_RELEASED:
                    // implement backlog item popup
                    if (m.isPopupTrigger()) {
                        final BacklogItemPanel itemPanel = locateContainer(m, BacklogItemPanel.class);
                        if (itemPanel != null) {
                            ActionPopupMenu popupMenu = ActionUtil.createEntityActionPopup("taskboard");
                            Point p = SwingUtilities.convertPoint(m.getComponent(), m.getPoint(), itemPanel);
                            popupMenu.getComponent().show(itemPanel, p.x, p.y);
                        }
                    }
                    break;

                case MouseEvent.MOUSE_CLICKED:
                    // implement backlog item double click
                    if (m.getClickCount() > 1) {
                        BacklogItemPanel itemPanel = locateContainer(m, BacklogItemPanel.class);
                        if (itemPanel != null) {
                            Entity backlogItem = itemPanel.getItem();
                            Entity workItem = new Entity(backlogItem.getPropertyValue("entity-type"),
                                    Integer.valueOf(backlogItem.getPropertyValue("entity-id")));
                            AliContentFactory.loadDetail(project, workItem, true, true);
                        }
                    }
                }
            }

        }
    }, AWTEvent.MOUSE_EVENT_MASK);
}

From source file:com.brainflow.application.toplevel.Brainflow.java

private void initializeToolBar() {

    CommandGroup mainToolbarGroup = new CommandGroup("main-toolbar");
    mainToolbarGroup.bind(getApplicationFrame());

    ToggleGroup interpToggleGroup = new ToggleGroup("toggle-interp-group");
    interpToggleGroup.bind(getApplicationFrame());

    OpenImageCommand openImageCommand = new OpenImageCommand();
    openImageCommand.bind(getApplicationFrame());

    SnapshotCommand snapshotCommand = new SnapshotCommand();
    snapshotCommand.bind(getApplicationFrame());

    CreateAxialViewCommand axialCommand = new CreateAxialViewCommand();
    axialCommand.bind(getApplicationFrame());
    axialCommand.installShortCut(documentPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    CreateSagittalViewCommand sagittalCommand = new CreateSagittalViewCommand();
    sagittalCommand.bind(getApplicationFrame());
    sagittalCommand.installShortCut(documentPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    CreateCoronalViewCommand coronalCommand = new CreateCoronalViewCommand();
    coronalCommand.bind(getApplicationFrame());
    coronalCommand.installShortCut(documentPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    CreateVerticalOrthogonalCommand vertCommand = new CreateVerticalOrthogonalCommand();
    vertCommand.bind(getApplicationFrame());
    vertCommand.installShortCut(documentPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    CreateHorizontalOrthogonalCommand horizCommand = new CreateHorizontalOrthogonalCommand();
    horizCommand.bind(getApplicationFrame());
    horizCommand.installShortCut(documentPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    CreateTriangularOrthogonalCommand triCommand = new CreateTriangularOrthogonalCommand();
    triCommand.bind(getApplicationFrame());
    triCommand.installShortCut(documentPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    CommandGroup orthoGroup = new CommandGroup("ortho-view-group");
    orthoGroup.bind(getApplicationFrame());

    final NextSliceCommand nextSliceCommand = new NextSliceCommand();
    nextSliceCommand.bind(getApplicationFrame());
    nextSliceCommand.installShortCut(documentPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    final PreviousSliceCommand previousSliceCommand = new PreviousSliceCommand();
    previousSliceCommand.bind(getApplicationFrame());
    previousSliceCommand.installShortCut(documentPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        public void eventDispatched(AWTEvent event) {
            if (event.getID() == KeyEvent.KEY_PRESSED) {
                KeyEvent ke = (KeyEvent) event;
                if (ke.getKeyCode() == KeyEvent.VK_LEFT) {
                    previousSliceCommand.execute();
                } else if (ke.getKeyCode() == KeyEvent.VK_RIGHT) {
                    nextSliceCommand.execute();
                }//from ww  w . java  2 s  .c om

            }

        }
    }, AWTEvent.KEY_EVENT_MASK);

    PageBackSliceCommand pageBackSliceCommand = new PageBackSliceCommand();
    pageBackSliceCommand.bind(getApplicationFrame());
    pageBackSliceCommand.installShortCut(documentPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    PageForwardSliceCommand pageForwardSliceCommand = new PageForwardSliceCommand();
    pageForwardSliceCommand.bind(getApplicationFrame());
    pageForwardSliceCommand.installShortCut(documentPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    IncreaseContrastCommand increaseContrastCommand = new IncreaseContrastCommand();
    increaseContrastCommand.bind(getApplicationFrame());
    increaseContrastCommand.installShortCut(documentPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    DecreaseContrastCommand decreaseContrastCommand = new DecreaseContrastCommand();
    decreaseContrastCommand.bind(getApplicationFrame());
    decreaseContrastCommand.installShortCut(documentPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    ToggleCommand nearest = new NearestInterpolationToggleCommand();
    nearest.bind(getApplicationFrame());
    decreaseContrastCommand.installShortCut(documentPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    ToggleCommand linear = new LinearInterpolationToggleCommand();
    linear.bind(getApplicationFrame());

    ToggleCommand cubic = new CubicInterpolationToggleCommand();
    cubic.bind(getApplicationFrame());

    ToggleCommand toggleAxisLabelCommand = new ToggleAxisLabelCommand();
    toggleAxisLabelCommand.bind(getApplicationFrame());

    JToolBar mainToolbar = mainToolbarGroup.createToolBar();
    //ActionCommand increaseContrastCommand = new IncreaseContrastCommand();
    //increaseContrastCommand.bind(brainFrame);
    //mainToolbar.add(increaseContrastCommand.getActionAdapter());

    //ActionCommand decreaseContrastCommand = new DecreaseContrastCommand();
    //decreaseContrastCommand.bind(brainFrame);
    //mainToolbar.add(decreaseContrastCommand.getActionAdapter());

    brainFrame.getContentPane().add(mainToolbar, BorderLayout.NORTH);

    //InputMap map = documentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

    //for (KeyStroke ks : map.keys()) {
    //    System.out.println("key : " + ks);
    //}

}

From source file:brainflow.app.toplevel.BrainFlow.java

private void initializeToolBar() {

    CommandGroup mainToolbarGroup = new CommandGroup("main-toolbar");

    mainToolbarGroup.bind(getApplicationFrame());

    ToggleGroup interpToggleGroup = new ToggleGroup("toggle-interp-group");
    interpToggleGroup.bind(getApplicationFrame());

    bindCommand(new OpenImageCommand(), true);
    bindCommand(new SnapshotCommand(), true);
    bindCommand(new NewCanvasCommand(), true);

    bindCommand(new CreateAxialViewCommand(), true);
    bindCommand(new CreateSagittalViewCommand(), true);

    bindCommand(new CreateCoronalViewCommand(), true);
    bindCommand(new CreateMontageViewCommand(), true);
    bindCommand(new CreateVerticalOrthogonalCommand(), true);

    bindCommand(new CreateHorizontalOrthogonalCommand(), true);
    bindCommand(new CreateTriangularOrthogonalCommand(), true);

    CommandGroup orthoGroup = new CommandGroup("ortho-view-group");
    orthoGroup.bind(getApplicationFrame());

    final NextSliceCommand nextSliceCommand = new NextSliceCommand();
    bindCommand(nextSliceCommand, false);

    final PreviousSliceCommand previousSliceCommand = new PreviousSliceCommand();
    bindCommand(previousSliceCommand, false);

    bindCommand(new PageBackSliceCommand(), true);
    bindCommand(new PageForwardSliceCommand(), true);

    bindCommand(new IncreaseContrastCommand(), true);
    bindCommand(new DecreaseContrastCommand(), true);

    bindCommand(new NearestInterpolationToggleCommand(), true);
    bindCommand(new LinearInterpolationToggleCommand(), true);
    bindCommand(new CubicInterpolationToggleCommand(), true);
    bindCommand(new ToggleAxisLabelCommand(), true);
    bindCommand(new ToggleCrossCommand(), true);

    //JToolBar mainToolbar = mainToolbarGroup.createToolBar();
    final CommandBar mainToolbar = new CommandBar();
    // for nimbus look and feel
    mainToolbar.setPaintBackground(false);
    // for nimbus look and feel

    mainToolbar.setBorder(new EmptyBorder(0, 0, 0, 0));
    final ButtonFactory buttonFactory = createToolBarButtonFactory();

    mainToolbarGroup.visitMembers(new GroupVisitor() {
        @Override//from   ww  w .j  a v  a2  s.  c  om
        public void visit(ActionCommand actionCommand) {
            JideButton jb = new JideButton(actionCommand.getActionAdapter());
            jb.setButtonStyle(JideButton.TOOLBAR_STYLE);
            jb.setText("");
            mainToolbar.add(jb);
        }

        @Override
        public void visit(CommandGroup commandGroup) {
            JComponent jc = commandGroup.createButton(buttonFactory);
            mainToolbar.add(jc);
        }
    });

    mainToolbar.setKey("toolbar");
    brainFrame.getDockableBarManager().addDockableBar(mainToolbar);

    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        public void eventDispatched(AWTEvent event) {

            if (event.getID() == KeyEvent.KEY_PRESSED) {

                KeyEvent ke = (KeyEvent) event;
                Component comp = ke.getComponent();
                if (ke.getKeyCode() == KeyEvent.VK_LEFT) {
                    ImageView view = BrainFlow.get().getSelectedView();

                    if (/*view.hasFocus() || */ parentIsImageView(comp)) {
                        previousSliceCommand.execute();
                    }
                } else if (ke.getKeyCode() == KeyEvent.VK_RIGHT) {
                    ImageView view = BrainFlow.get().getSelectedView();

                    if ( /*view.hasFocus() */ parentIsImageView(comp)) {
                        nextSliceCommand.execute();
                    } else {
                        System.out.println("no focus");
                    }
                }

            }

        }
    }, AWTEvent.KEY_EVENT_MASK);

    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        public void eventDispatched(AWTEvent event) {
            if (event.getID() == MouseEvent.MOUSE_RELEASED) {
                MouseEvent me = (MouseEvent) event;
                if (me.isPopupTrigger()) {
                    showActionMenu(me);
                }
            }

        }
    }, AWTEvent.MOUSE_EVENT_MASK);

}

From source file:com.sshtools.sshterm.SshTermSessionPanel.java

/**
 *
 *
 * @param application//from  w ww .  j  a va 2 s  . c om
 *
 * @throws SshToolsApplicationException
 */
public void init(SshToolsApplication application) throws SshToolsApplicationException {
    super.init(application);

    //  Additional connection tabs
    additionalTabs = new SshToolsConnectionTab[] { new SshTermTerminalTab() };

    //  Printing page format
    try {
        if (System.getSecurityManager() != null) {
            AccessController.checkPermission(new RuntimePermission("queuePrintJob"));
        }

        try {
            PrinterJob job = PrinterJob.getPrinterJob();

            if (job == null) {
                throw new IOException("Could not get print page format.");
            }

            pageFormat = job.defaultPage();

            if (PreferencesStore.preferenceExists(PREF_PAGE_FORMAT_ORIENTATION)) {
                pageFormat.setOrientation(
                        PreferencesStore.getInt(PREF_PAGE_FORMAT_ORIENTATION, PageFormat.LANDSCAPE));

                Paper paper = new Paper();
                paper.setImageableArea(PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_X, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_Y, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_W, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_H, 0));
                paper.setSize(PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_W, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_H, 0));
                pageFormat.setPaper(paper);
            }
        } catch (Exception e) {
            showExceptionMessage("Error", e.getMessage());
        }
    } catch (AccessControlException ace) {
        ace.printStackTrace();
    }

    enableEvents(VDU_EVENTS);

    // Set up the actions
    initActions();

    // Create the status bar
    statusBar = new StatusBar();

    dataListener = new DataNotificationListener(statusBar);

    // Create our terminal emulation object
    try {
        emulation = createEmulation();
    } catch (IOException ioe) {
        throw new SshToolsApplicationException(ioe);
    }

    emulation.addTerminalListener(this);

    // Set a scrollbar for the terminal - doesn't seem to be as simple as this
    scrollBar = new JScrollBar(JScrollBar.VERTICAL);
    emulation.setBufferSize(1000);

    // Create our swing terminal and add it to the main frame
    terminal = new TerminalPanel(emulation) {

        public void processEvent(AWTEvent evt) {
            /** We can't add a MouseWheelListener because it was not available in 1.3, so direct processing of events is necessary */
            if (evt instanceof MouseEvent && evt.getID() == 507) {
                try {
                    Method m = evt.getClass().getMethod("getWheelRotation", new Class[] {});
                    SshTermSessionPanel.this.scrollBar.setValue(SshTermSessionPanel.this.scrollBar.getValue()
                            + (SshTermSessionPanel.this.scrollBar.getUnitIncrement()
                                    * ((Integer) m.invoke(evt, new Object[] {})).intValue()
                                    * PreferencesStore.getInt(PREF_MOUSE_WHEEL_INCREMENT, 1)));

                } catch (Throwable t) {
                }
            } else {
                super.processEvent(evt);
            }
        }

        public void copyNotify() {
            copyAction.actionPerformed(null);
        }

    };
    terminal.requestFocus();
    terminal.setScrollbar(scrollBar);
    terminal.addMouseMotionListener(this);

    //terminal.addMouseWheelListener(this);
    // Center panel with terminal and scrollbar
    JPanel center = new JPanel(new BorderLayout());
    center.setBackground(Color.red);
    center.add(terminal, BorderLayout.CENTER);
    center.add(scrollBar, BorderLayout.EAST);

    // Show the context menu on mouse button 3 (right click)
    terminal.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) > 0) {
                getContextMenu().setLabel(getApplication().getApplicationName());
                getContextMenu().show(terminal, evt.getX(), evt.getY());
            } else if ((evt.getModifiers() & MouseEvent.BUTTON2_MASK) > 0) {
                pasteAction.actionPerformed(null);
            }
        }
    });

    //
    //        JPanel top = new JPanel(new BorderLayout());
    //        top.add(getJMenuBar(), BorderLayout.NORTH);
    //        top.add(north, BorderLayout.SOUTH);
    setLayout(new BorderLayout());
    add(center, BorderLayout.CENTER);

    //        add(top, BorderLayout.NORTH);
    // Make sure that the swing terminal has focus
    terminal.requestFocus();
}

From source file:com.sshtools.sshterm.SshTerminalPanel.java

public void init(SshToolsApplication application) throws SshToolsApplicationException {
    super.init(application);
    boolean kerb_support = false;
    if (PreferencesStore.get(PREF_KRB5_MYPROXY_USE, "NONE").indexOf("true") >= 0)
        kerb_support = true;/*w  w w  .j  a va  2  s  .c om*/

    //  Additional connection tabs
    if (kerb_support == true) {
        additionalTabs = new SshToolsConnectionTab[] { new SshTermCommandTab(), new SshTermTerminalTab(),
                new GSIAuthTab(), new XForwardingTab(), new SshToolsConnectionKerberosTab() };
        SshTerminalPanel.PREF_KRB5_MYPROXY_ENABLED = true;
    } else {
        additionalTabs = new SshToolsConnectionTab[] { new SshTermCommandTab(), new SshTermTerminalTab(),
                new GSIAuthTab(), new XForwardingTab() };
        SshTerminalPanel.PREF_KRB5_MYPROXY_ENABLED = false;

    }
    //
    //portForwardingPane = new PortForwardingPane();

    //  Printing page format
    try {
        if (System.getSecurityManager() != null) {
            AccessController.checkPermission(new RuntimePermission("queuePrintJob"));
        }

        try {
            PrinterJob job = PrinterJob.getPrinterJob();

            if (job == null) {
                throw new IOException("Could not get print page format.");
            }

            pageFormat = job.defaultPage();

            if (PreferencesStore.preferenceExists(PREF_PAGE_FORMAT_ORIENTATION)) {
                pageFormat.setOrientation(
                        PreferencesStore.getInt(PREF_PAGE_FORMAT_ORIENTATION, PageFormat.LANDSCAPE));

                Paper paper = new Paper();
                paper.setImageableArea(PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_X, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_Y, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_W, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_H, 0));
                paper.setSize(PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_W, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_H, 0));
                pageFormat.setPaper(paper);
            }
        } catch (Exception e) {
            showExceptionMessage("Error", e.getMessage());
        }
    } catch (AccessControlException ace) {
        ace.printStackTrace();
    }

    enableEvents(VDU_EVENTS);

    // Set up the actions
    initActions();

    // Create the status bar
    statusBar = new StatusBar();

    dataListener = new DataNotificationListener(statusBar);

    // Create our terminal emulation object
    try {
        emulation = createEmulation();
    } catch (IOException ioe) {
        throw new SshToolsApplicationException(ioe);
    }

    emulation.addTerminalListener(this);

    // Set a scrollbar for the terminal - doesn't seem to be as simple as this
    scrollBar = new JScrollBar(JScrollBar.VERTICAL);
    emulation.setBufferSize(1000);

    // Create our swing terminal and add it to the main frame
    terminal = new TerminalPanel(emulation) {
        public void processEvent(AWTEvent evt) {
            /** We can't add a MouseWheelListener because it was not available in 1.3, so direct processing of events is necessary */
            if (evt instanceof MouseEvent && evt.getID() == 507) {
                try {
                    Method m = evt.getClass().getMethod("getWheelRotation", new Class[] {});
                    SshTerminalPanel.this.scrollBar.setValue(SshTerminalPanel.this.scrollBar.getValue()
                            + (SshTerminalPanel.this.scrollBar.getUnitIncrement()
                                    * ((Integer) m.invoke(evt, new Object[] {})).intValue()
                                    * PreferencesStore.getInt(PREF_MOUSE_WHEEL_INCREMENT, 1)));

                } catch (Throwable t) {
                    //   In theory, this should never happen
                }
            } else {
                super.processEvent(evt);
            }
        }

        public void copyNotify() {
            copyAction.actionPerformed(null);
        }

    };
    terminal.requestFocus();
    terminal.setScrollbar(scrollBar);
    terminal.addMouseMotionListener(this);

    //terminal.addMouseWheelListener(this);
    // Center panel with terminal and scrollbar
    JPanel center = new JPanel(new BorderLayout());
    center.setBackground(Color.red);
    center.add(terminal, BorderLayout.CENTER);
    center.add(scrollBar, BorderLayout.EAST);

    // Show the context menu on mouse button 3 (right click)
    terminal.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) > 0) {
                getContextMenu()
                        .setLabel((getCurrentConnectionFile() == null) ? getApplication().getApplicationName()
                                : getCurrentConnectionFile().getName());
                getContextMenu().show(terminal, evt.getX(), evt.getY());
            } else if ((evt.getModifiers() & MouseEvent.BUTTON2_MASK) > 0) {
                pasteAction.actionPerformed(null);
            }
        }
    });

    //
    //        JPanel top = new JPanel(new BorderLayout());
    //        top.add(getJMenuBar(), BorderLayout.NORTH);
    //        top.add(north, BorderLayout.SOUTH);
    setLayout(new BorderLayout());
    add(center, BorderLayout.CENTER);

    //        add(top, BorderLayout.NORTH);
    // Make sure that the swing terminal has focus
    terminal.requestFocus();
}