📄 hushapplet.java
字号:
add(commands,commandsConstraints,selectAllButton,1,0); showSelectFunctionButtons(foldersSelected()>0,2); lockButtons(false); } /* On click of the "Save" button */ else if (e.target==saveButton || e.target==saveButtonR) { lockButtons(true); clearCommands(); folderChoice = new Choice(); folderChoice.setBackground(Color.white); folderChoice.setFont(new Font("Helvetica",Font.PLAIN,12)); for (int x=0;x<c.numberOfFolders();x++) if (!c.folderName(x).equals(c.folderName())) folderChoice.addItem(c.folderName(x)); add(commands,commandsConstraints,saveMessageLabel,0,0); add(commands,commandsConstraints,folderChoice,1,0); add(commands,commandsConstraints,smallSaveButton,2,0); add(commands,commandsConstraints,cancelSaveButton,3,0); } /* On selection of folder to save message to */ else if (e.target==smallSaveButton) { clearCommands(); add(commands,commandsConstraints, new Label("Moving message(s) " +" "),0,0); commands.paintAll(commands.getGraphics()); if (currentScreen.equals("read")) { try { c.use(); c.moveMessage(c.messageID(),folderChoice.getSelectedItem()); listMessages(c.folderName(),0,true); listFolders(currentFolderPage,true); c.done(); } catch (IOException e5) {error();} c.wipeMessage(); clearCommands(); if (c.numberOfMessages()>0) { add(commands,commandsConstraints,selectAllButton,0,0); showSelectFunctionButtons(messagesSelected()>0,1); } currentScreen = "listMessages"; lockButtons(false); mainLayout.show(main,currentScreen); } else { int saveCount=0; // Special variable to compensate for changes during multiple saves try { c.use(); for (int x=0; x<c.numberOfMessages(); x++) if (messageSelected[x]) { c.moveMessage(c.messageID(x)-saveCount,folderChoice.getSelectedItem()); saveCount++; } listMessages(c.folderName(),0,true); listFolders(currentFolderPage,true); c.done(); } catch (IOException e5) {error();} clearCommands(); if (c.numberOfMessages()>0) { add(commands,commandsConstraints,selectAllButton,0,0); showSelectFunctionButtons(messagesSelected()>0,1); } } lockButtons(false); } /* On click of cancel button for save */ else if (e.target==cancelSaveButton) { clearCommands(); if (currentScreen.equals("read")) { add(commands,commandsConstraints,backButton,0,0); add(commands,commandsConstraints,replyButton,1,0); add(commands,commandsConstraints,forwardButton,2,0); add(commands,commandsConstraints,deleteButtonR,3,0); add(commands,commandsConstraints,saveButtonR,4,0); } else { add(commands,commandsConstraints,selectAllButton,0,0); showSelectFunctionButtons(messagesSelected()>0,1); } lockButtons(false); } /* On click of "Rename Selected" button */ else if (e.target==renameButton) { if (folderSelected[0]) statusBar(spaces+"Cannot rename inbox"+spaces); else { lockButtons(true); clearCommands(); formatTextComponent(renameFolderField = new TextField(12),true); add(commands,commandsConstraints,newNameLabel,0,0); add(commands,commandsConstraints,renameFolderField,1,0); add(commands,commandsConstraints,smallRenameButton,2,0); add(commands,commandsConstraints,cancelRenameButton,3,0); commands.paintAll(commands.getGraphics()); renameFolderField.requestFocus(); } return true; } /* On enter of new name for folder */ else if (e.target==renameFolderField || e.target==smallRenameButton) { String newFolderName=renameFolderField.getText().trim(); if (validFolderName(newFolderName)) { for (int a=0;a<c.numberOfFolders();a++) { if (c.folderName(a).equals(newFolderName) && !folderSelected[a]) { statusBar(spaces+"That foldername already exists!"+spaces); ignoreLostFocus = true; renameFolderField.requestFocus(); return true; } } clearCommands(); add(commands,commandsConstraints, new Label("Renaming folder " +" "),0,0); commands.paintAll(commands.getGraphics()); int x; for (x=0;x<c.numberOfFolders();x++) if (folderSelected[x]) break; try { c.use(); c.renameFolder(c.folderName(x),newFolderName); listFolders(currentFolderPage,true); c.done(); } catch (IOException e6) {error();} showSelectFunctionButtons(false,0); clearCommands(); add(commands,commandsConstraints,newFolderButton,0,0); add(commands,commandsConstraints,selectAllButton,1,0); showSelectFunctionButtons(foldersSelected()>2,0); lockButtons(false); } else { ignoreLostFocus=true; renameFolderField.requestFocus(); } } /* On click of "Cancel" button for renaming a folder */ else if (e.target==cancelRenameButton) { commands.remove(newNameLabel); commands.remove(renameFolderField); commands.remove(smallRenameButton); commands.remove(cancelRenameButton); add(commands,commandsConstraints,newFolderButton,0,0); add(commands,commandsConstraints,selectAllButton,1,0); showSelectFunctionButtons(foldersSelected()>2,0); lockButtons(false); } /* On click of the "New Address" button */ else if (e.target==newAddressButton) { lockButtons(true); addressesPanel.removeAll(); add(addressesPanel,aConstraints,new Label("Enter new address information here..."), 0,0,2,1,0,0,1,0,NO,NW,0,6,0,6); add(addressesPanel,aConstraints,colorLabel(new Label("Nickname:")),0,1,1,1,0,0,0,0,NO,NW,0,6,0,6); add(addressesPanel,aConstraints,colorLabel(new Label("Full Name:")),0,2); add(addressesPanel,aConstraints,colorLabel(new Label("Email Address:")),0,3); add(addressesPanel,aConstraints,newNicknameField=new TextField(10),1,1,1,1,0,0,1,0,B,NW,0,6,0,6); add(addressesPanel,aConstraints,newFullnameField=new TextField(10),1,2); add(addressesPanel,aConstraints,newAddressField=new TextField(10),1,3); add(addressesPanel,aConstraints,saveAddressButton=new Button("Done"),0,4,1,1,0,0,0,1,NO,NW,0,6,0,6); add(addressesPanel,aConstraints,cancelNewAddressButton=new Button("Cancel"), 1,4,1,1,0,0,1,1,NO,NW,0,6,0,6); newNicknameField.setForeground(Color.black); newFullnameField.setForeground(Color.black); newAddressField.setForeground(Color.black); saveAddressButton.setForeground(Color.black); cancelNewAddressButton.setForeground(Color.black); addressesPanel.paintAll(addressesPanel.getGraphics()); } /* On click of "save" button for a new address */ else if (e.target==saveAddressButton) { String newNickname = newNicknameField.getText().trim(); if (newNickname.length()==0) { statusBar(spaces+"You must enter a nickname"+spaces); ignoreLostFocus = true; newNicknameField.requestFocus(); return true; } else if (newNickname.length()>9) { statusBar(spaces+"Nicknames must be nine characters or less"+spaces); ignoreLostFocus = true; newNicknameField.requestFocus(); return true; } else if (newFullnameField.getText().indexOf('\\')!=-1) { statusBar(spaces+"Cannot use \\ in name"+spaces); ignoreLostFocus = true; newFullnameField.requestFocus(); return true; } else if (newAddressField.getText().trim().length()==0) { statusBar(spaces+"You must enter an email address"+spaces); ignoreLostFocus = true; newAddressField.requestFocus(); return true; } else if (validEmailAddress(newAddressField.getText().trim())) { for (int a=0;a<c.numberOfAddresses();a++) { if (c.nickname(a).equals(newNickname)) { statusBar(spaces+"That nickname already exists!"+spaces); ignoreLostFocus = true; newNicknameField.requestFocus(); return true; } } clearCommands(); add(commands,commandsConstraints, new Label("Adding address " +" "),0,0); commands.paintAll(commands.getGraphics()); try { c.use(); boolean successful = c.addAddress(newNicknameField.getText().trim(), newFullnameField.getText().trim(),newAddressField.getText().trim()); if (successful) { listAddresses(currentAddressPage,true); lockButtons(false); } else newAddressField.requestFocus(); c.done(); } catch (IOException e7) { error(); lockButtons(false); } clearCommands(); add(commands,commandsConstraints,newAddressButton,0,0); add(commands,commandsConstraints,showFingerprintButton,1,0); commands.paintAll(commands.getGraphics()); } else { newAddressField.requestFocus(); statusBar(spaces+"Bad email address"+spaces); } } /* On click of "Cancel" button for a new address */ else if (e.target==cancelNewAddressButton) { listAddressesNoReload(currentAddressPage); lockButtons(false); } /* Buttons for changing pages */ else if (e.target==nextMessagePageButton) { listMessagesNoReload(c.folderName(),currentMessagePage+1); commands.remove(deleteButton); commands.remove(saveButton); showSelectFunctionButtons(messagesSelected()>0,1); } else if (e.target==previousMessagePageButton) { listMessagesNoReload(c.folderName(),currentMessagePage-1); commands.remove(deleteButton); commands.remove(saveButton); showSelectFunctionButtons(messagesSelected()>0,1); } else if (e.target==nextFolderPageButton) { listFoldersNoReload(currentFolderPage+1); commands.remove(deleteButton); commands.remove(renameButton); showSelectFunctionButtons(foldersSelected()>0,2); } else if (e.target==previousFolderPageButton) { listFoldersNoReload(currentFolderPage-1); commands.remove(deleteButton); commands.remove(renameButton); showSelectFunctionButtons(foldersSelected()>0,2); } else if (e.target==nextAddressPageButton) listAddressesNoReload(currentAddressPage+1); else if (e.target==previousAddressPageButton) listAddressesNoReload(currentAddressPage-1); /* If the encrypt checkbox has been clicked */ else if (e.target==encryptCheckbox) { /* Check to make sure we're only encrypting to hushmail addresses. */ if (encryptCheckbox.getState()) { for (int n=0;n<3;n++) { String t = headerField[n].getText().trim(); int l = t.length(); if (l>0) { if (!toHushmail(t)) { encryptCheckbox.setState(false); statusBar(spaces+"Can only encrypt to addresses @"+c.domain()+spaces); break; } } } } else statusBar(spaces+"Warning: this message will not be sent securely"+spaces); } else if (e.target==actualMessageCheckbox) { try { readMessage(c.messageID(),false); } catch (IOException cantHappen) {} } /* Check the address choices on the "Compose" screen */ else if (currentScreen.equals("compose")) { /* Iterate through fields on compose screen checking for address book grabbing */ for (int n=0;n<3;n++) { if (e.target==addressChoice[n]) { if (addressChoice[n].getSelectedIndex()!=0) { String address; if (c.fullname(addressChoice[n].getSelectedIndex()-1).length()>0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -