⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javaide.java

📁 的说法科斯洛伐路上看到伐楼上的开发1科林麦克;
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		}

		itemName = strItem[3];
		if (s.equals(itemName[0])) {
			runCompiler();
			tabPane.repaint();
			labelState.repaint();
		}
		if (s.equals(itemName[1])) {
			runApplication();
			tabPane.repaint();
			labelState.repaint();
		}
		if (s.equals(itemName[2])) {
			runApplet();
			tabPane.repaint();
			labelState.repaint();
		}
		if (s.equals(itemName[3])) {
			runJavaDoc();
			tabPane.repaint();
			labelState.repaint();
		}
		itemName = strItem[4];

		if (s.equals(itemName[0]))
			configDialog.setVisible(true);
		if (s.equals(itemName[1])) {
			LookAndFeel.lookCount = ++LookAndFeel.lookCount
					% LookAndFeel.strLook.length;
			setLookAndFeel();
		}
		itemName = strItem[5];
		if (s.equals(itemName[0]))
			try {
				Runtime.getRuntime().exec(
						config.getBrowserPath() + " "
								+ config.getReferenceUrl());
			} catch (Exception ex) {
			}
		if (s.equals(itemName[1]))
			try {
				Runtime.getRuntime().exec(
						config.getBrowserPath() + " "
								+ "http://blog.csdn.net/cping1982");
			} catch (Exception ex1) {
			}
		if (s.equals(itemName[2]))
			new VersionDialog(this);
	}

	/**
	 * 默认类型
	 * 
	 */
	public void openProtoType() {
		String as[] = new String[config.getProtoTypeLength()];
		String s = "";
		for (int i = 0; i < config.getProtoTypeLength(); i++)
			as[i] = config.getProtoTypeName(i);

		String s1 = (String) JOptionPane.showInputDialog(this, "选择类型",
				"JavaIDE : 确定", 3, null, as, as[0]);
		if (s1 == null) {
			labelState.setText("取消");
			return;
		}
		for (int j = 0; j < as.length; j++)
			if (s1.equals(as[j]))
				s = config.getProtoTypePath(j);

		try {
			Editor editor = getCurrentEditor();
			if (!editor.getText().equals(""))
				addNewElement();
			editor = getCurrentEditor();
			File file = new File(s);
			editor.openFile(file);
			editor.setCurrentFile(null);
			tabPane.setTitleAt(tabPane.getSelectedIndex(), "未命名");
			labelState.setText("基础类型读取");
			JOptionPane.showMessageDialog(this, "打开选定文档类型", "JavaIDE : 确定", 1);
			searchDialog.change(editor.getJavaText(), "选择");
		} catch (Exception ex) {
			labelState.setText(ex.getMessage() + ",打开默认类型失败");
		}
	}

	public void openFile() {
		File file;

		int state = fileChooser.showOpenDialog(this);
		if (state != JFileChooser.APPROVE_OPTION) {
			return;
		}

		int j = 0;
		file = fileChooser.getSelectedFile();

		if (file.equals(((Editor) vectorEdit.elementAt(j)).getCurrentFile())) {
			try {
				tabPane.setSelectedIndex(j);
				JOptionPane.showMessageDialog(this, file.getAbsolutePath()
						+ "已经被打开。", "JavaIDE : 确认", 1);
			} catch (Exception ex1) {
			}
			return;
		}

		j++;

		Editor editor = getCurrentEditor();
		if (!editor.getText().equals(""))
			addNewElement();
		editor = getCurrentEditor();
		try {
			editor.openFile(file);
		} catch (Exception ex) {
			labelState.setText(ex.getMessage() + ",读取失败");
		}
		tabPane.setTitleAt(tabPane.getSelectedIndex(), file.getName());
	}

	public void closeSheet() {
		Editor editor = getCurrentEditor();
		if (tabPane.getTabCount() > 1) {
			int i = tabPane.getSelectedIndex();
			String s = editor.getCurrentName();
			if (editor.changeDocument()) {
				if (s == null)
					s = "未命名";
				String s1 = "第" + (i + 1) + "文档[" + s + "]关闭.";

				int j = JOptionPane.showConfirmDialog(this, s1, "JavaIDE : 提示",
						1);
				if (j == 2)
					return;
				if (j == 0)
					overWrite();
			}
			tabPane.remove(i);
			vectorEdit.remove(i);
			try {
				tabPane.setSelectedIndex(0);
			} catch (Exception ex) {
			}
			labelState.setText("");
		} else {

			JOptionPane
					.showMessageDialog(this, "没有可以关闭的文档!", "JavaIDE : 提示", 1);
		}
	}

	public void runCompiler() {
		Editor editor = getCurrentEditor();
		if (editor.changeDocument()) {
			int i = JOptionPane.showConfirmDialog(this, "是否要编译当前文件?",
					"JavaIDE : 编译", 0);
			if (i == 1)
				return;
		}
		if (editor.getCurrentFile() != null) {
			try {
				String s1 = editor.getCurrentAbusolutePath();
				if (config.getCreateBatFile()) {
					File file = new File(editor.getCurrentParent() + "/"
							+ editor.getOnlyName() + ".bat");
					if (!file.exists()) {
						BufferedWriter bufferedwriter = new BufferedWriter(
								new FileWriter(file));
						bufferedwriter.write(config.getJavaPath()
								+ "javac -classpath "
								+ addDoubleQuote(editor.getCurrentParent())
								+ ";" + addDoubleQuote(config.getClassPath())
								+ " " + addDoubleQuote(s1) + "\r\npause");
						bufferedwriter.close();
					}
				}
				Process process = Runtime.getRuntime().exec(
						config.getJavaPath() + "javac -classpath "
								+ addDoubleQuote(editor.getCurrentParent())
								+ ";" + addDoubleQuote(config.getClassPath())
								+ " " + addDoubleQuote(s1));
				BufferedReader bufferedreader = new BufferedReader(
						new InputStreamReader(process.getErrorStream()));
				String s2 = "";
				for (String s3 = ""; (s3 = bufferedreader.readLine()) != null;)
					s2 = s2 + s3 + "\n";

				bufferedreader.close();
				if (s2.equals("")) {
					s2 = strMes[Math.abs((new Random()).nextInt())
							% strMes.length];
					File file1 = null;
					if (config.getCreateJarFile()) {
						file1 = File.createTempFile("Jar", ".man", new File(
								editor.getCurrentParent()));
						BufferedWriter bufferedwriter1 = new BufferedWriter(
								new FileWriter(file1));
						bufferedwriter1.write("Main-Class: "
								+ editor.getOnlyName() + "\n");
						bufferedwriter1.close();
						String as[] = { config.getJavaPath() + "jar", "cfm",
								editor.getOnlyName() + ".jar", file1.getName(),
								"*.class" };
						Process process1 = Runtime.getRuntime().exec(as, null,
								new File(editor.getCurrentParent()));
						BufferedReader bufferedreader1 = new BufferedReader(
								new InputStreamReader(process1.getInputStream()));
						String s4;
						while ((s4 = bufferedreader1.readLine()) != null)
							s2 = s2 + s4 + "\n";
						bufferedreader1.close();

						if (!config.getClassPath().equals("")) {
							for (StringTokenizer stringtokenizer = new StringTokenizer(
									config.getClassPath(), ";"); stringtokenizer
									.hasMoreTokens();) {
								File file2 = new File(stringtokenizer
										.nextToken());
								try {
									File afile[] = file2
											.listFiles(new ClassFilter());
									for (int j = 0; j < afile.length; j++) {
										String as1[] = {
												config.getJavaPath() + "jar",
												"uf",
												editor.getOnlyName() + ".jar",
												"-C", file2.getName(),
												afile[j].getName() };
										Process process2 = Runtime
												.getRuntime()
												.exec(
														as1,
														null,
														new File(
																editor
																		.getCurrentParent()));
										BufferedReader bufferedreader2 = new BufferedReader(
												new InputStreamReader(process2
														.getInputStream()));
										String s5;
										while ((s5 = bufferedreader2.readLine()) != null)
											s2 = s2 + s5 + "\n";
										bufferedreader2.close();
									}

								} catch (Exception ex1) {
								}
							}

						}
					}
					if (file1 != null)
						file1.delete();
				}
				new ErrorDialog(this, s2, editor.getJavaText());
			} catch (Exception ex) {
				JOptionPane.showMessageDialog(this, "执行javac命令失败!",
						"JavaIDE : 编译文件", 1);
				labelState.setText(ex.getMessage() + ",编译失败!");
			}
		} else {

			JOptionPane
					.showMessageDialog(this, "当前文档未保存!", "JavaIDE : 编译文件", 1);
		}
	}

	public void runApplication() {
		Editor editor = getCurrentEditor();
		if (editor.getCurrentFile() != null) {
			String name = getName(editor, 1);
			if (!(new File(name + ".class")).exists()) {

				JOptionPane.showMessageDialog(this, "没有找到类文件!", "JavaIDE : 运行",
						1);
				return;
			}
		} else {
			JOptionPane
					.showMessageDialog(this, "当前文档未保存!", "JavaIDE : 编译文件", 1);
			return;
		}
		if (editor.changeDocument()) {
			int i = JOptionPane.showConfirmDialog(this, "是否要保存当前文档?",
					"JavaIDE : 运行", 0);
			if (i == 1)
				return;
		}
		File file = new File(getName(editor, 1) + ".class");
		if (editor.getCurrentFile().lastModified() > file.lastModified()) {
			int j = JOptionPane.showConfirmDialog(this, "是否变更class?",
					"JavaIDE : 运行", 0);
			if (j == 1)
				return;
		}
		String name = getName(editor, 0);
		setState(1);

		String result = "";

		try {
			Process process = null;
			String as[] = { config.getJavaPath() + "java", "-cp",
					editor.getCurrentParent() + ";" + config.getClassPath(),
					name };
			process = Runtime.getRuntime().exec(as, null,
					new File(editor.getCurrentParent()));
			BufferedReader bufferedreader = new BufferedReader(
					new InputStreamReader(process.getInputStream()));
			String value;
			while ((value = bufferedreader.readLine()) != null)
				result = result + value + "\n";
			bufferedreader.close();
			bufferedreader = new BufferedReader(new InputStreamReader(process
					.getErrorStream()));
			while ((value = bufferedreader.readLine()) != null)
				result = result + value + "\n";
			bufferedreader.close();
			if (result.equals(""))
				result = "操作完毕";
			labelState.setText(result);
		} catch (Exception ex) {
		}
		setState(0);
		toFront();

	}

	public void runApplet() {
		Editor editor;
		int k = 800;
		int l = 600;
		editor = getCurrentEditor();
		if (editor.getCurrentFile() != null) {
			String name = getName(editor, 1);
			if (!(new File(name + ".class")).exists()) {
				JOptionPane.showMessageDialog(this, "class文件不存在!",
						"JavaIDE : 运行", 1);
				return;
			}
		} else {

			JOptionPane
					.showMessageDialog(this, "当前文档未保存!", "JavaIDE : 编译文件", 1);
			return;
		}
		String name = getName(editor, 1) + ".class";
		File file = new File(name);
		if (editor.getCurrentFile().lastModified() > file.lastModified()) {
			int j = JOptionPane.showConfirmDialog(this, "class已更新,是否替换?",
					"JavaIDE : 运行", 0);
			if (j == 1)
				return;
		}
		File runfile;
		try {
			runfile = File.createTempFile("html", ".html", new File(editor
					.getCurrentParent()));
			runfile.deleteOnExit();
			BufferedWriter bufferedwriter = new BufferedWriter(new FileWriter(
					runfile));
			name = toNamePart(name);
			bufferedwriter.write("<APPLET WIDTH=\"" + k + "\" HEIGHT=\"" + l
					+ "\" CODE=\"" + name + "\"></APPLET>");
			bufferedwriter.close();
			if (config.getCreateHtmlFile()) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -