jframemainview.java

来自「This is the complete Editor Using java」· Java 代码 · 共 73 行

JAVA
73
字号
package com.JCreater;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
public class JFrameMainView {
	private static JSplitPane splitPane;
	private static JTabbedPane tabbedPane = new JTabbedPane(); 
	private static JTabbedPane tabedPaneFile;
	public static JTextArea textAreaFile;
	private static JScrollPane scrollPaneFile;
	private static JScrollPane scrollPaneOutput;
	private static JTextArea textAreaOutput;
	private static String selectedTabbed;
	public JFrame mainFrame;
	private static JFrameMainView INSTANCE = new JFrameMainView();
	public static final JFrameMainView getInstance() {
		return INSTANCE;
	}
	public static final void destoryInstance() {
		INSTANCE = null;
	}
	public static JSplitPane frameMainView() {
		textAreaFile = new JTextArea();
		textAreaOutput = new JTextArea();
		
		tabedPaneFile = addMyTabbedPane(textAreaFile, "Untitled 0");
		scrollPaneFile = new JScrollPane(tabedPaneFile, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
						 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        scrollPaneOutput = new JScrollPane(textAreaOutput, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 
        				   JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,scrollPaneFile, scrollPaneOutput);
		scrollPaneFile.setMinimumSize(new Dimension(800,300));
        scrollPaneOutput.setMinimumSize(new Dimension(800,100));
        scrollPaneFile.setPreferredSize(new Dimension(800,500));
		return splitPane;
	}
	public static JTabbedPane addMyTabbedPane(JTextArea textAreaFile, String title) {
		textAreaFile = new JTextArea();
		tabbedPane.add(title, textAreaFile);
		textAreaFile.getDocument().addDocumentListener(new MyTextAreaEvent());
		tabbedPane.addChangeListener(new TabbedPaneAction());
		tabbedPane.setSelectedIndex(tabbedPane.getTabCount()-1);
		setStatus(tabbedPane.getSelectedIndex());
		return tabbedPane;
	}
	public static void setStatus(int index) {
	    if (index > -1)
	    	selectedTabbed = " Selected Tab: " + index;
	    else
	    	selectedTabbed = " No Tab Selected";
	    System.out.println(selectedTabbed);
	  }
	public static void killTab() {
	    if (tabbedPane.getTabCount() > 0) {
	    	tabbedPane.removeTabAt(tabbedPane.getTabCount()-1);
	    	setStatus(tabbedPane.getSelectedIndex());
	    	tabbedPane.revalidate();
	    	tabbedPane.repaint();
	    }
	    else {
	    	setStatus(-1);
	    	tabbedPane.revalidate();
	    	tabbedPane.repaint();
	    }
	     
	  }
	
}

⌨️ 快捷键说明

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