📄 simplebasisams.java
字号:
buttonContainer.setLayout(new GridLayout(1, 2)); addDialogButton("OK", buttonContainer, okActionListener); addDialogButton("Cancel", buttonContainer, cancelActionListener); dialogContainer.add(textContainer, BorderLayout.CENTER); dialogContainer.add(buttonContainer, BorderLayout.SOUTH); showScreen(dialogContainer); } private void pageUp() { int currentScreen = getCurrentScreen(); if (currentScreen == APPLICATIONS_SCREEN) { // Determine if there is possibly more icons to display // beyond this page if (applicationsScreenPageNumber > 0) { applicationsScreenPageNumber--; doApplicationsScreen(); } } else if (currentScreen == SWITCHTO_SCREEN) { // Determine if there is possibly more icons to display // beyond this page if (switchToScreenPageNumber > 0) { switchToScreenPageNumber--; doSwitchToScreen(); } } else if (currentScreen == KILL_SCREEN) { // Determine if there is possibly more icons to display // beyond this page if (killScreenPageNumber > 0) { killScreenPageNumber--; doKillScreen(); } } else { installer.pageUp(); } } private void pageDown() { int currentScreen = getCurrentScreen(); if (currentScreen == APPLICATIONS_SCREEN) { // Find out number of total screen pages int totalApplicationsScreenPages = getTotalScreenPages(applicationsScreenButtons.length, SCREEN_DISPLAY_ICONS); // Don't scroll beyond the last page if (applicationsScreenPageNumber < (totalApplicationsScreenPages - 1)) { applicationsScreenPageNumber++; doApplicationsScreen(); } } else if (currentScreen == SWITCHTO_SCREEN) { // Find out number of total screen pages int totalSwitchToScreenPages = getTotalScreenPages(switchScreenButtons.length, SCREEN_DISPLAY_ICONS); // Don't scroll beyond the last page if (switchToScreenPageNumber < (totalSwitchToScreenPages - 1)) { switchToScreenPageNumber++; doSwitchToScreen(); } } else if (currentScreen == KILL_SCREEN) { // Find out number of total screen pages int totalKillScreenPages = getTotalScreenPages(killScreenButtons.length, SCREEN_DISPLAY_ICONS); // Don't scroll beyond the last page if (killScreenPageNumber < (totalKillScreenPages - 1)) { killScreenPageNumber++; doKillScreen(); } } else { installer.pageDown(); } } /* * Utility method to determine the number of pages to store * a total number of icons */ int getTotalScreenPages(int numIcons, int screenIconCapacity) { int totalScreenPages = 0; int div = numIcons / screenIconCapacity; int mod = numIcons % screenIconCapacity; if (mod == 0) { totalScreenPages = div; } else { totalScreenPages = div + 1; } return totalScreenPages; } /** * Display the screen containing application icons. */ void doApplicationsScreen() { trace("ENTERING SCREEN: APPLICATIONS"); if (currentApp != null) { pauseApp(currentApp); bringWindowToBack(currentApp); } showScreen(createApplicationsScreen()); setCurrentScreen(APPLICATIONS_SCREEN); } private Container createApplicationsScreen() { Container applicationsScreen = new Container(); applicationsScreen.setLayout(new DisplayLayout()); int firstPositionIndex = applicationsScreenPageNumber * SCREEN_DISPLAY_ICONS; for (int i = firstPositionIndex; i < (applicationsScreenPageNumber * SCREEN_DISPLAY_ICONS + SCREEN_DISPLAY_ICONS); i++) { if (i < applicationsScreenButtons.length) { applicationsScreen.add(applicationsScreenButtons[i]); } else { applicationsScreen.add(createScreenButton(null, APPLICATIONS_SCREEN_COLOR)); } } return applicationsScreen; } class ScreenButtonsKeyListener implements KeyListener { SimpleBasisAMSImageButton button = null; public ScreenButtonsKeyListener(SimpleBasisAMSImageButton button) { this.button = button; } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_PAGE_UP || keyCode == KeyEvent.VK_F1) { pageUp(); } else if (keyCode == KeyEvent.VK_PAGE_DOWN || keyCode == KeyEvent.VK_F2) { pageDown(); } else if (keyCode == KeyEvent.VK_ENTER) { button.doAction(); } else if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_LEFT ) { if (e.getComponent() == screenContainer.getComponent(0)) { commandContainer.requestFocusInWindow(); } else { button.transferFocusBackward(); } } else if (keyCode == KeyEvent.VK_DOWN | keyCode == KeyEvent.VK_RIGHT) { button.transferFocus(); } } public void keyReleased(KeyEvent e) { } } class CommandButtonsKeyListener implements KeyListener { SimpleBasisAMSImageButton button = null; public CommandButtonsKeyListener(SimpleBasisAMSImageButton button) { this.button = button; } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_PAGE_UP || keyCode == KeyEvent.VK_F1) { pageUp(); } else if (keyCode == KeyEvent.VK_PAGE_DOWN || keyCode == KeyEvent.VK_F2) { pageDown(); } else if (keyCode == KeyEvent.VK_ENTER) { button.doAction(); } else if (keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_UP) { screenContainer.requestFocusInWindow(); } else if (keyCode == KeyEvent.VK_LEFT) { button.transferFocusBackward(); } else if (keyCode == KeyEvent.VK_RIGHT) { button.transferFocus(); } } public void keyReleased(KeyEvent e) { } } /** * Display the switch-to screen, consisting of icons * pertaining to currently running applications. */ private void doSwitchToScreen() { trace("ENTERING SCREEN: SWITCH"); if (currentApp == null) { trace("*** currentApp is NULL. ***"); } else { trace("*** currentApp -> " + currentApp.getApplication().getTitle() + " ***"); } if (currentApp != null) { pauseApp(currentApp); bringWindowToBack(currentApp); } showScreen(createSwitchToScreen()); setCurrentScreen(SWITCHTO_SCREEN); } private Container createSwitchToScreen() { Container switchToScreen = new Container(); switchToScreen.setLayout(new DisplayLayout()); JUMPApplicationProxy apps[] = getRunningApps(); switchScreenButtons = new SimpleBasisAMSImageButton[apps.length]; for (int i = 0; i < apps.length; i++) { switchScreenButtons[i] = createScreenButton(apps[i].getApplication(), new SwitchToActionListener(apps[i]), SWITCHTO_SCREEN_COLOR); } int firstPositionIndex = switchToScreenPageNumber * SCREEN_DISPLAY_ICONS; for (int i = firstPositionIndex; i < (switchToScreenPageNumber * SCREEN_DISPLAY_ICONS + SCREEN_DISPLAY_ICONS); i++) { if (i < switchScreenButtons.length) { switchToScreen.add(switchScreenButtons[i]); } else { switchToScreen.add(createScreenButton(null, SWITCHTO_SCREEN_COLOR)); } } return switchToScreen; } /** * Display the kill screen, consisting of icons pertaining to currently * running applications that can be killed . */ private void doKillScreen() { trace("ENTERING SCREEN: KILL"); if (currentApp != null) { pauseApp(currentApp); bringWindowToBack(currentApp); } showScreen(createKillScreen()); setCurrentScreen(KILL_SCREEN); } private Container createKillScreen() { Container killScreen = new Container(); killScreen.setLayout(new DisplayLayout()); JUMPApplicationProxy apps[] = getRunningApps(); killScreenButtons = new SimpleBasisAMSImageButton[apps.length]; for (int i = 0; i < apps.length; i++) { killScreenButtons[i] = createScreenButton(apps[i].getApplication(), new KillActionListener(apps[i]), KILL_SCREEN_COLOR); } int firstPositionIndex = killScreenPageNumber * SCREEN_DISPLAY_ICONS; for (int i = firstPositionIndex; i < (killScreenPageNumber * SCREEN_DISPLAY_ICONS + SCREEN_DISPLAY_ICONS) ; i++) { if (i < killScreenButtons.length) { killScreen.add(killScreenButtons[i]); } else { killScreen.add(createScreenButton(null, KILL_SCREEN_COLOR)); } } return killScreen; } private void doRemoveScreen() { trace("ENTERING SCREEN: INSTALLER"); if (currentApp != null) { pauseApp(currentApp); bringWindowToBack(currentApp); } installer.showRemoveScreen(); } private void doInstallScreen() { trace("ENTERING SCREEN: INSTALLER"); if (currentApp != null) { pauseApp(currentApp); bringWindowToBack(currentApp); } installer.showInstallScreen(); } private void doHelpScreen() { trace("ENTERING SCREEN: KILL"); if (currentApp != null) { pauseApp(currentApp); bringWindowToBack(currentApp); } Container helpContainer = new Container() { public void paint(Graphics g) { super.paint(g); g.drawString(" NOTE: When there is no mouse support,", 10, 20); g.drawString(" the TAB key must be pressed to initially", 10, 40); g.drawString(" bring focus to this window.", 10, 60); g.drawString(" F1 : PAGE UP", 10, 100); g.drawString(" F2 : PAGE DOWN", 10, 120); } }; helpContainer.setBackground(HELP_SCREEN_COLOR); showScreen(helpContainer); setCurrentScreen(HELP_SCREEN); } private void doPrefsScreen() { trace("ENTERING SCREEN: PREFS"); if (currentApp != null) { pauseApp(currentApp); bringWindowToBack(currentApp); } Container prefsContainer = new Container() { public void paint(Graphics g) { super.paint(g); g.drawString(" NOTE: This screen is currently,", 10, 20); g.drawString(" unimplemented.", 10, 40); } }; prefsContainer.setBackground(PREFS_SCREEN_COLOR); showScreen(prefsContainer); setCurrentScreen(PREFS_SCREEN); } class InstallScreenActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { doInstallScreen(); } } class RemoveScreenActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { doRemoveScreen(); } } class ApplicationsScreenActionListener implements ActionListener { public ApplicationsScreenActionListener() { } public void actionPerformed(ActionEvent e) { doApplicationsScreen(); } } class SwitchToScreenActionListener implements ActionListener { public SwitchToScreenActionListener() { } public void actionPerformed(ActionEvent e) { doSwitchToScreen(); } } class KillScreenActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { doKillScreen(); } } class HelpScreenActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { doHelpScreen(); } } class PrefsScreenActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { doPrefsScreen(); } } class LaunchAppActionListener implements ActionListener { JUMPApplication app; public LaunchAppActionListener(JUMPApplication app) { this.app = app; } public void actionPerformed(ActionEvent e) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -