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

📄 javasourcepanel.java

📁 java 调用windows的api
💻 JAVA
字号:
package org.jawin.browser.java;

import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import java.awt.*;
import java.io.IOException;

/**
 * A panel that is used to display potentially huge numbers of Java files
 *
 * Using JTabbedPanel just did not cut it as often too many files had to be displayed that
 * it could not cope
 *
 * This control also supports sorting of java source files
 *
 * <p>Title: Jawin Code Generation GUI</p>
 * <p>Description: GUI for exploring type libraries and generating Java code</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: Open Source Incentive</p>
 *
 * @author Josh Passenger
 * @version 1.0
 */

public class JavaSourcePanel extends JPanel
{
	private BorderLayout borderLayout = new BorderLayout();
	private JSplitPane splitPane = new JSplitPane();
	private JScrollPane listScrollPane = new JScrollPane();
	private JScrollPane editorScrollPane = new JScrollPane();
	private JTextArea textArea = new JTextArea();
	private JavaSourceListModel listModel = new JavaSourceListModel();
	private JavaSourceList list = new JavaSourceList(listModel);

	public JavaSourcePanel()
	{
		try
		{
			jbInit();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}

	private void jbInit() throws Exception
	{
		setLayout(borderLayout);
		textArea.setEditable(false);
		textArea.setTabSize(4);
		add(splitPane, BorderLayout.CENTER);
		splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
		splitPane.add(editorScrollPane, JSplitPane.LEFT);
		splitPane.add(listScrollPane, JSplitPane.RIGHT);
		listScrollPane.getViewport().add(list, null);
		editorScrollPane.getViewport().add(textArea, null);
		splitPane.setDividerLocation(400);

		registerListeners();
	}

	private void registerListeners()
	{
		list.addListSelectionListener(new ListSelectionListener()
		{
			public void valueChanged(ListSelectionEvent e)
			{
				selectionChanged();
			}
		});
	}

	public void clearAll()
	{
		list.clearSelection();
		listModel.clearAll();
		selectionChanged();
	}

	public void addSourceFiles(ArrayList sourceFiles)
	{
		listModel.addJavaSources(sourceFiles);
	}

	private void selectionChanged()
	{
		JavaSourceFile selected = (JavaSourceFile) list.getSelectedValue();

		if (selected == null)
		{
			textArea.setEnabled(false);
			textArea.setBackground(SystemColor.control);
			textArea.setText("");
		}
		else
		{
			textArea.setEnabled(true);
			textArea.setText(selected.getCode());
			textArea.setCaretPosition(0);
			textArea.setBackground(SystemColor.white);
		}
	}

	public void saveAll() throws IOException
	{
		for (int i = 0; i < listModel.getSize(); i++)
		{
			listModel.getJavaSourceAt(i).saveFile();
		}
	}

	public int getSourceCount()
	{
		return listModel.getSize();
	}
}

⌨️ 快捷键说明

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