當前位置:首頁 » 操作系統 » 圖文編輯器源碼

圖文編輯器源碼

發布時間: 2022-08-15 14:42:33

java語言寫一個文本編輯器的源代碼 要能測試通過的!用Eclipse能運行通過的!

一. 高亮的內容:
需要高亮的內容有:
1. 關鍵字, 如 public, int, true 等.
2. 運算符, 如 +, -, *, /等
3. 數字
4. 高亮字元串, 如 "example of string"
5. 高亮單行注釋
6. 高亮多行注釋

二. 實現高亮的核心方法:
StyledDocument.setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace)

三. 文本編輯器選擇.
Java中提供的多行文本編輯器有: JTextComponent, JTextArea, JTextPane, JEditorPane等, 都可以使用. 但是因為語法著色中文本要使用多種風格的樣式, 所以這些文本編輯器的document要使用StyledDocument.
JTextArea使用的是PlainDocument, 此document不能進行多種格式的著色.
JTextPane, JEditorPane使用的是StyledDocument, 默認就可以使用.
為了實現語法著色, 可以繼承自DefaultStyledDocument, 設置其為這些文本編輯器的documet, 或者也可以直接使用JTextPane, JEditorPane來做. 為了方便, 這里就直接使用JTextPane了.

四. 何時進行著色.
當文本編輯器中有字元被插入或者刪除時, 文本的內容就發生了變化, 這時檢查, 進行著色.
為了監視到文本的內容發生了變化, 要給document添加一個DocumentListener監聽器, 在他的removeUpdate和insertUpdate中進行著色處理.
而changedUpdate方法在文本的屬性例如前景色, 背景色, 字體等風格改變時才會被調用.
@Override
public void changedUpdate(DocumentEvent e) {

}

@Override
public void insertUpdate(DocumentEvent e) {
try {
colouring((StyledDocument) e.getDocument(), e.getOffset(), e.getLength());
} catch (BadLocationException e1) {
e1.printStackTrace();
}
}

@Override
public void removeUpdate(DocumentEvent e) {
try {
// 因為刪除後游標緊接著影響的單詞兩邊, 所以長度就不需要了
colouring((StyledDocument) e.getDocument(), e.getOffset(), 0);
} catch (BadLocationException e1) {
e1.printStackTrace();
}
}

五. 著色范圍:
pos: 指變化前游標的位置.
len: 指變化的字元數.
例如有關鍵字public, int
單詞"publicint", 在"public"和"int"中插入一個空格後變成"public int", 一個單詞變成了兩個, 這時對"public" 和 "int"進行著色.
著色范圍是public中p的位置和int中t的位置加1, 即是pos前面單詞開始的下標和pos+len開始單詞結束的下標. 所以上例中要著色的范圍是"public int".
提供了方法indexOfWordStart來取得pos前單詞開始的下標, 方法indexOfWordEnd來取得pos後單詞結束的下標.
public int indexOfWordStart(Document doc, int pos) throws BadLocationException {
// 從pos開始向前找到第一個非單詞字元.
for (; pos > 0 && isWordCharacter(doc, pos - 1); --pos);
return pos;
}

public int indexOfWordEnd(Document doc, int pos) throws BadLocationException {
// 從pos開始向前找到第一個非單詞字元.
for (; isWordCharacter(doc, pos); ++pos);
return pos;
}

一個字元是單詞的有效字元: 是字母, 數字, 下劃線.
public boolean isWordCharacter(Document doc, int pos) throws BadLocationException {
char ch = getCharAt(doc, pos); // 取得在文檔中pos位置處的字元
if (Character.isLetter(ch) || Character.isDigit(ch) || ch == '_')
return false;
}

所以著色的范圍是[start, end] :
int start = indexOfWordStart(doc, pos);
int end = indexOfWordEnd(doc, pos + len);

六. 關鍵字著色.
從著色范圍的開始下標起進行判斷, 如果是以字母開或者下劃線開頭, 則說明是單詞, 那麼先取得這個單詞, 如果這個單詞是關鍵字, 就進行關鍵字著色, 如果不是, 就進行普通的著色. 著色完這個單詞後, 繼續後面的著色處理. 已經著色過的字元, 就不再進行著色了.
public void colouring(StyledDocument doc, int pos, int len) throws BadLocationException {
// 取得插入或者刪除後影響到的單詞.
// 例如"public"在b後插入一個空格, 就變成了:"pub lic", 這時就有兩個單詞要處理:"pub"和"lic"
// 這時要取得的范圍是pub中p前面的位置和lic中c後面的位置
int start = indexOfWordStart(doc, pos);
int end = indexOfWordEnd(doc, pos + len);

char ch;
while (start < end) {
ch = getCharAt(doc, start);
if (Character.isLetter(ch) || ch == '_') {
// 如果是以字母或者下劃線開頭, 說明是單詞
// pos為處理後的最後一個下標
start = colouringWord(doc, start);
} else {
//SwingUtilities.invokeLater(new ColouringTask(doc, pos, wordEnd - pos, normalStyle));
++start;
}
}
}

public int colouringWord(StyledDocument doc, int pos) throws BadLocationException {
int wordEnd = indexOfWordEnd(doc, pos);
String word = doc.getText(pos, wordEnd - pos); // 要進行著色的單詞

if (keywords.contains(word)) {
// 如果是關鍵字, 就進行關鍵字的著色, 否則使用普通的著色.
// 這里有一點要注意, 在insertUpdate和removeUpdate的方法調用的過程中, 不能修改doc的屬性.
// 但我們又要達到能夠修改doc的屬性, 所以把此任務放到這個方法的外面去執行.
// 實現這一目的, 可以使用新線程, 但放到swing的事件隊列里去處理更輕便一點.
SwingUtilities.invokeLater(new ColouringTask(doc, pos, wordEnd - pos, keywordStyle));
} else {
SwingUtilities.invokeLater(new ColouringTask(doc, pos, wordEnd - pos, normalStyle));
}

return wordEnd;
}

因為在insertUpdate和removeUpdate方法中不能修改document的屬性, 所以著色的任務放到這兩個方法外面, 所以使用了SwingUtilities.invokeLater來實現.
private class ColouringTask implements Runnable {
private StyledDocument doc;
private Style style;
private int pos;
private int len;

public ColouringTask(StyledDocument doc, int pos, int len, Style style) {
this.doc = doc;
this.pos = pos;
this.len = len;
this.style = style;
}

public void run() {
try {
// 這里就是對字元進行著色
doc.setCharacterAttributes(pos, len, style, true);
} catch (Exception e) {}
}
}

七: 源碼
關鍵字著色的完成代碼如下, 可以直接編譯運行. 對於數字, 運算符, 字元串等的著色處理在以後的教程中會繼續進行詳解.
import java.awt.Color;
import java.util.HashSet;
import java.util.Set;

import javax.swing.JFrame;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;

public class HighlightKeywordsDemo {
public static void main(String[] args) {
JFrame frame = new JFrame();

JTextPane editor = new JTextPane();
editor.getDocument().addDocumentListener(new SyntaxHighlighter(editor));
frame.getContentPane().add(editor);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 500);
frame.setVisible(true);
}
}

/**
* 當文本輸入區的有字元插入或者刪除時, 進行高亮.
*
* 要進行語法高亮, 文本輸入組件的document要是styled document才行. 所以不要用JTextArea. 可以使用JTextPane.
*
* @author Biao
*
*/
class SyntaxHighlighter implements DocumentListener {
private Set<String> keywords;
private Style keywordStyle;
private Style normalStyle;

public SyntaxHighlighter(JTextPane editor) {
// 准備著色使用的樣式
keywordStyle = ((StyledDocument) editor.getDocument()).addStyle("Keyword_Style", null);
normalStyle = ((StyledDocument) editor.getDocument()).addStyle("Keyword_Style", null);
StyleConstants.setForeground(keywordStyle, Color.RED);
StyleConstants.setForeground(normalStyle, Color.BLACK);

// 准備關鍵字
keywords = new HashSet<String>();
keywords.add("public");
keywords.add("protected");
keywords.add("private");
keywords.add("_int9");
keywords.add("float");
keywords.add("double");
}

public void colouring(StyledDocument doc, int pos, int len) throws BadLocationException {
// 取得插入或者刪除後影響到的單詞.
// 例如"public"在b後插入一個空格, 就變成了:"pub lic", 這時就有兩個單詞要處理:"pub"和"lic"
// 這時要取得的范圍是pub中p前面的位置和lic中c後面的位置
int start = indexOfWordStart(doc, pos);
int end = indexOfWordEnd(doc, pos + len);

char ch;
while (start < end) {
ch = getCharAt(doc, start);
if (Character.isLetter(ch) || ch == '_') {
// 如果是以字母或者下劃線開頭, 說明是單詞
// pos為處理後的最後一個下標
start = colouringWord(doc, start);
} else {
SwingUtilities.invokeLater(new ColouringTask(doc, start, 1, normalStyle));
++start;
}
}
}

/**
* 對單詞進行著色, 並返回單詞結束的下標.
*
* @param doc
* @param pos
* @return
* @throws BadLocationException
*/
public int colouringWord(StyledDocument doc, int pos) throws BadLocationException {
int wordEnd = indexOfWordEnd(doc, pos);
String word = doc.getText(pos, wordEnd - pos);

if (keywords.contains(word)) {
// 如果是關鍵字, 就進行關鍵字的著色, 否則使用普通的著色.
// 這里有一點要注意, 在insertUpdate和removeUpdate的方法調用的過程中, 不能修改doc的屬性.
// 但我們又要達到能夠修改doc的屬性, 所以把此任務放到這個方法的外面去執行.
// 實現這一目的, 可以使用新線程, 但放到swing的事件隊列里去處理更輕便一點.
SwingUtilities.invokeLater(new ColouringTask(doc, pos, wordEnd - pos, keywordStyle));
} else {
SwingUtilities.invokeLater(new ColouringTask(doc, pos, wordEnd - pos, normalStyle));
}

return wordEnd;
}

/**
* 取得在文檔中下標在pos處的字元.
*
* 如果pos為doc.getLength(), 返回的是一個文檔的結束符, 不會拋出異常. 如果pos<0, 則會拋出異常.
* 所以pos的有效值是[0, doc.getLength()]
*
* @param doc
* @param pos
* @return
* @throws BadLocationException
*/
public char getCharAt(Document doc, int pos) throws BadLocationException {
return doc.getText(pos, 1).charAt(0);
}

/**
* 取得下標為pos時, 它所在的單詞開始的下標. ±wor^d± (^表示pos, ±表示開始或結束的下標)
*
* @param doc
* @param pos
* @return
* @throws BadLocationException
*/
public int indexOfWordStart(Document doc, int pos) throws BadLocationException {
// 從pos開始向前找到第一個非單詞字元.
for (; pos > 0 && isWordCharacter(doc, pos - 1); --pos);

return pos;
}

/**
* 取得下標為pos時, 它所在的單詞結束的下標. ±wor^d± (^表示pos, ±表示開始或結束的下標)
*
* @param doc
* @param pos
* @return
* @throws BadLocationException
*/
public int indexOfWordEnd(Document doc, int pos) throws BadLocationException {
// 從pos開始向前找到第一個非單詞字元.
for (; isWordCharacter(doc, pos); ++pos);

return pos;
}

/**
* 如果一個字元是字母, 數字, 下劃線, 則返回true.
*
* @param doc
* @param pos
* @return
* @throws BadLocationException
*/
public boolean isWordCharacter(Document doc, int pos) throws BadLocationException {
char ch = getCharAt(doc, pos);
if (Character.isLetter(ch) || Character.isDigit(ch) || ch == '_')
return false;
}

@Override
public void changedUpdate(DocumentEvent e) {

}

@Override
public void insertUpdate(DocumentEvent e) {
try {
colouring((StyledDocument) e.getDocument(), e.getOffset(), e.getLength());
} catch (BadLocationException e1) {
e1.printStackTrace();
}
}

@Override
public void removeUpdate(DocumentEvent e) {
try {
// 因為刪除後游標緊接著影響的單詞兩邊, 所以長度就不需要了
colouring((StyledDocument) e.getDocument(), e.getOffset(), 0);
} catch (BadLocationException e1) {
e1.printStackTrace();
}
}

/**
* 完成著色任務
*
* @author Biao
*
*/
private class ColouringTask implements Runnable {
private StyledDocument doc;
private Style style;
private int pos;
private int len;

public ColouringTask(StyledDocument doc, int pos, int len, Style style) {
this.doc = doc;
this.pos = pos;
this.len = len;
this.style = style;
}

public void run() {
try {
// 這里就是對字元進行著色
doc.setCharacterAttributes(pos, len, style, true);
} catch (Exception e) {}
}
}
}

Ⅱ 源碼編輯器電腦版百度怎麼下載

你好 很高興回答你的問題
1、首先,可以在PC下載網下載源碼編輯器軟體包,解壓,雙擊打開exe文件,進入安裝界面
2、選擇安裝位置,點擊下一步
3、創建存放快捷方式的文件夾,點擊下一步
4、創建桌面快捷方式,點擊下一步
5、准備安裝軟體,點擊安裝
6、完成安裝,點擊完成即可退出安裝向導。
根據以上步驟就完成了下載,望採納 謝謝

Ⅲ 急求簡單文本編輯器的C語言源代碼,源程序 VC++6.0

//頭文件//
main.h
#define CM_FILE_SAVEAS 9072
#define CM_FILE_EXIT 9071
#define CM_FILE_OPEN 9070
#define CM_ABOUT 9069
//主程序文件//
main.c
/*****************************************************/
#include <windows.h>
#pragma hdrstop
#include "Main.h"

static char g_szClassName[] = "MyWindowClass";
static HINSTANCE g_hInst = NULL;

#define IDC_MAIN_TEXT 1001

BOOL LoadFile(HWND hEdit, LPSTR pszFileName)
{
HANDLE hFile;
BOOL bSuccess = FALSE;

hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, 0);
if(hFile != INVALID_HANDLE_VALUE)
{
DWORD dwFileSize;
dwFileSize = GetFileSize(hFile, NULL);
if(dwFileSize != 0xFFFFFFFF)
{
LPSTR pszFileText;
pszFileText = (LPSTR)GlobalAlloc(GPTR, dwFileSize + 1);
if(pszFileText != NULL)
{
DWORD dwRead;
if(ReadFile(hFile, pszFileText, dwFileSize, &dwRead, NULL))
{
pszFileText[dwFileSize] = 0; // Null terminator
if(SetWindowText(hEdit, pszFileText))
bSuccess = TRUE; // It worked!
}
GlobalFree(pszFileText);
}
}
CloseHandle(hFile);
}
return bSuccess;
}

BOOL SaveFile(HWND hEdit, LPSTR pszFileName)
{
HANDLE hFile;
BOOL bSuccess = FALSE;

hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, 0,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if(hFile != INVALID_HANDLE_VALUE)
{
DWORD dwTextLength;
dwTextLength = GetWindowTextLength(hEdit);
if(dwTextLength > 0)// No need to bother if there's no text.
{
LPSTR pszText;
pszText = (LPSTR)GlobalAlloc(GPTR, dwTextLength + 1);
if(pszText != NULL)
{
if(GetWindowText(hEdit, pszText, dwTextLength + 1))
{
DWORD dwWritten;
if(WriteFile(hFile, pszText, dwTextLength, &dwWritten, NULL))
bSuccess = TRUE;
}
GlobalFree(pszText);
}
}
CloseHandle(hFile);
}
return bSuccess;
}

BOOL DoFileOpenSave(HWND hwnd, BOOL bSave)
{
OPENFILENAME ofn;
char szFileName[MAX_PATH];

ZeroMemory(&ofn, sizeof(ofn));
szFileName[0] = 0;

ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = "txt";

if(bSave)
{
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY |
OFN_OVERWRITEPROMPT;

if(GetSaveFileName(&ofn))
{
if(!SaveFile(GetDlgItem(hwnd, IDC_MAIN_TEXT), szFileName))
{
MessageBox(hwnd, "Save file failed.", "Error",
MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}
}
}
else
{
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if(GetOpenFileName(&ofn))
{
if(!LoadFile(GetDlgItem(hwnd, IDC_MAIN_TEXT), szFileName))
{
MessageBox(hwnd, "Load of file failed.", "Error",
MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}
}
}
return TRUE;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_CREATE:
CreateWindow("EDIT", "",
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE |
ES_WANTRETURN,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hwnd, (HMENU)IDC_MAIN_TEXT, g_hInst, NULL);

SendDlgItemMessage(hwnd, IDC_MAIN_TEXT, WM_SETFONT,
(WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE, 0));
break;
case WM_SIZE:
if(wParam != SIZE_MINIMIZED)
MoveWindow(GetDlgItem(hwnd, IDC_MAIN_TEXT), 0, 0, LOWORD(lParam),
HIWORD(lParam), TRUE);
break;
case WM_SETFOCUS:
SetFocus(GetDlgItem(hwnd, IDC_MAIN_TEXT));
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case CM_FILE_OPEN:
DoFileOpenSave(hwnd, FALSE);
break;
case CM_FILE_SAVEAS:
DoFileOpenSave(hwnd, TRUE);
break;
case CM_FILE_EXIT:
PostMessage(hwnd, WM_CLOSE, 0, 0);
break;
case CM_ABOUT:
MessageBox (NULL, "File Editor for Windows !\n Using the Win32 API" , "About...", 0);
}
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, Message, wParam, lParam);
}
return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX WndClass;
HWND hwnd;
MSG Msg;

g_hInst = hInstance;

WndClass.cbSize = sizeof(WNDCLASSEX);
WndClass.style = 0;
WndClass.lpfnWndProc = WndProc;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hInstance = g_hInst;
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
WndClass.lpszMenuName = "MAINMENU";
WndClass.lpszClassName = g_szClassName;
WndClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

if(!RegisterClassEx(&WndClass))
{
MessageBox(0, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
return 0;
}

hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"A File Program",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 320, 240,
NULL, NULL, g_hInst, NULL);

if(hwnd == NULL)
{
MessageBox(0, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
return 0;
}

ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);

while(GetMessage(&Msg, NULL, 0, 0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}

Ⅳ 誰有在線網頁編輯器源代碼ASP網站能用的

城市時尚頻道管理系統 軟體類別: ASP源碼 / 文章管理
軟體語言: 簡體中文
授權方式: 免費版
文件大小: 2.19M
系統平台: ASP+ACCESS
聯 系 人: [email protected]
1,文章欄目可二級分類,隨意修改,管理員分級管理
2,採用強大的HTML編輯器輸入文章
3,不存在任何新聞內容不能分段,不出空格的問題
4,可以直接復制任何圖文信息,輸出和原來格式一模一樣
5,前台使用JS隨意調用新聞
6,支持圖片文章,無組件上傳圖片到資料庫,前台JS調用
http://www.mycodes.net/soft/10130.htm

Ⅳ 源碼編輯器游戲怎麼做圖片

1、打開源碼編輯器。可以直接上傳代碼片段生成圖片,支持所有的編程語言和代碼風格,背景色可以自定義,效果實時顯示,非常方便。
2、需要保存圖片的話,直接點擊右上角的Export按鈕就行,目前官方支持2種格式的圖片,一種是PNG,一種是SVG,輸入文件名後,直接就可以保存。以上是源碼編輯器游戲怎麼做圖片的操作方法。

Ⅵ 微信編輯器源碼可以插入php頁面嗎

不可以的,那個微信的編輯器是不開源的,你也找不到那個源碼來直接拿下來。

還有什麼不懂可以追問。

Ⅶ 跪求好心人分享源碼編輯器 V4.0 簡體中文版軟體免費百度雲資源

鏈接:

提取碼:mmvs

軟體名稱:源碼編輯器V4.0簡體中文版

語言:簡體中文

大小:214.50MB

類別:系統工具

介紹:源碼編輯器是一款非常專業的電腦編程軟體,通過圖文代碼的方式,讓青少年養成編程興趣,提高編碼學習效率。軟體內還提供了素材庫供用戶選擇使用,讓孩子在短時間內就能快速提升編程水平,可支持離線編程。

Ⅷ java語言寫一個文本編輯器的源代碼

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.*; //Date needed
import java.io.PrintWriter;
public class NotePad extends JFrame
{
JTextArea jta;
class newl implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
jta.setText("");
}
}

class openl implements ActionListener
{ public void actionPerformed(ActionEvent e)
{
JFileChooser jf=new JFileChooser();
jf.showOpenDialog(NotePad.this);

}

}
//保存文件的監聽
class savel implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
JFileChooser jf = new JFileChooser();
jf.showSaveDialog(NotePad.this);

}
}
//列印的監聽 ?
class printl implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
// PrintWriter p = new PrintWriter(NotePad.this);
}
}
//退出記事本的監聽
class exitl implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);//退出
}
}

//拷貝的監聽
class l implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
jta.();
}
}

//粘貼的監聽
class pastel implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
jta.paste();
}
}
//剪切的監聽
class cutl implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
jta.cut();
}
}
//查找的監聽

//添加日期的監聽
class datel implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
Date d=new Date();
jta.append(d.toString());
}
}

//構造函數
public NotePad()
{
jta=new JTextArea("",24,40);
JScrollPane jsp=new JScrollPane(jta);
JMenuBar jmb=new JMenuBar();
JMenu mFile=new JMenu("File");
JMenu mEdit=new JMenu("Edit");

JMenuItem mNew=new JMenuItem("New",KeyEvent.VK_N);
mNew.addActionListener(new newl());
mFile.add(mNew);

JMenuItem mOpen=new JMenuItem("Open",KeyEvent.VK_O);
mOpen.addActionListener(new openl());
mFile.add(mOpen);

JMenuItem mSave=new JMenuItem("Save");
mSave.addActionListener(new savel());
mFile.add(mSave);

mFile.addSeparator(); //添加分割線

JMenuItem mPrint = new JMenuItem("Print");
mPrint.addActionListener(new printl());
mFile.add(mPrint);

mFile.addSeparator(); //添加分割線

JMenuItem mExit=new JMenuItem("Exit");
mExit.addActionListener(new exitl());
mFile.add(mExit);
mFile.setMnemonic(KeyEvent.VK_F);

//編輯菜單的子菜單的處理
JMenuItem jmi;
jmi=new JMenuItem("Copy");
jmi.addActionListener(new l());
mEdit.add(jmi);

jmi=new JMenuItem("Cut");
jmi.addActionListener(new cutl());
mEdit.add(jmi);

jmi=new JMenuItem("Paste");
jmi.addActionListener(new pastel());
mEdit.add(jmi);

mEdit.addSeparator(); //添加分割線

jmi=new JMenuItem("Find");

mEdit.add(jmi);

jmi=new JMenuItem("FindNext");
mEdit.add(jmi);
mEdit.addSeparator();
jmi=new JMenuItem("Select All");
mEdit.add(jmi);
jmi=new JMenuItem("Date/Time");
jmi.addActionListener(new datel());
mEdit.add(jmi);

jmb.add(mFile);
jmb.add(mEdit);

this.setJMenuBar(jmb);

this.getContentPane().add(jsp);
this.setSize(200,200);
this.setVisible(true);
}
//主函數,程序入口點
public static void main(String s[])
{
new NotePad();
}

}

Ⅸ C# 圖片編輯器 源碼

去TAO 寶上找個人寫吧,或者去買個源代碼

Ⅹ 源碼編輯器4.0和源碼編輯器有什麼不同

源碼編輯器4.0比源碼編輯器性能體驗優化提升。修復了已知bug。
源碼編輯器是一款非常有趣的軟體,這款軟體非常適合小朋友使用,這款編程軟體其實就是一個動畫編輯軟體,可以編輯人物各種事件、控制動作、外觀、聲音、畫筆等等,非常容易上手還有助於益智。
無需編程功底。使用簡單,滑鼠點擊即可。條理清晰,快速完成作品。

熱點內容
cad解壓錯誤 發布:2024-03-29 15:01:45 瀏覽:78
存儲指令集 發布:2024-03-29 14:39:27 瀏覽:649
資料庫表刪除數據 發布:2024-03-29 14:39:26 瀏覽:367
出c語言整除 發布:2024-03-29 14:28:22 瀏覽:572
芬尼壓縮機 發布:2024-03-29 14:24:11 瀏覽:464
電腦數據實時上傳本地伺服器軟體 發布:2024-03-29 14:07:57 瀏覽:920
尋秦記源碼 發布:2024-03-29 13:56:17 瀏覽:496
linux的備份命令 發布:2024-03-29 13:41:22 瀏覽:383
csgo建議什麼配置 發布:2024-03-29 13:31:44 瀏覽:980
電腦ftp服務如何禁用 發布:2024-03-29 13:24:48 瀏覽:332