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

📄 mainframe.java

📁 java写字板 功能于windows自带的写字板相似
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	

 // </editor-fold> 
       // <editor-fold defaultstate="collapsed" desc=" 加鼠标事件事件区e.getSource ">    
    /*   public void actionPerformed(ActionEvent e)
    {
      
        if(e.getSource()==File_Exit)
        {
            Exit();
        }
        else if(e.getSource()==Help_AboutUs)
        {
            AboutMe();
        }
        else if(e.getSource()==Format_NewLine)
        {
            if(Format_NewLine.isSelected())
            {
                TextArea.setLineWrap(true);
                StatusBar.setEnabled(false);
                Status_Bar.setVisible(false);    
            }
            else
            {
                TextArea.setLineWrap(false);
                StatusBar.setEnabled(true);
                Status_Bar.setVisible(true);    
            }
        }
           else if(e.getSource() == File_New || e.getSource() == new_tool)
           {////新建文件
			NewFile();
		}
		else if(e.getSource() == File_Open || e.getSource() == open_tool)
                {////打开文件
			OpenFile();
		}
		else if (e.getSource() == File_Save || e.getSource() == save_tool)
                {///保存文件			
			SaveFile();
		}
		else if (e.getSource() == File_SaveAs)
                {////另存文件
			SaveAsFile();
		}
		
               else if(e.getSource() == Edit_Cut || e.getSource() == Mouse_Cut || e.getSource() == cut_tool)
                {
			TextArea.cut();
		}
		else if(e.getSource() == Edit_Copy || e.getSource() == Mouse_Copy || e.getSource() == copy_tool)
                {
			TextArea.copy();
		}
		else if(e.getSource() == Edit_Paste || e.getSource() == Mouse_Paste || e.getSource() == paste_tool)
                {
			TextArea.paste();
		}
		else if(e.getSource() == Edit_Del || e.getSource() == Mouse_Del || e.getSource() == delete_tool)
                {
			TextArea.replaceSelection("");
		}
		else if(e.getSource() == Edit_SelectAll || e.getSource() == Mouse_SelectAll)
                {/////////////全选
			TextArea.selectAll();
		}
		else if(e.getSource() ==datetime||e.getSource()==datetime_tool)
                {  ////时间/日期
			int inpoint = TextArea.getCaretPosition();//取得当前光标位置
            Date dt = new Date();
            String strdate = dt.toLocaleString();
            TextArea.insert(strdate,inpoint);
		}
		else if(e.getSource() == Edit_Back || e.getSource() == Mouse_Back||e.getSource()==back_tool)
                {
		}
		else if(e.getSource() == Status_Bar)
                {
          Get_XY();
         
		  
		}
		else if(e.getSource() == Tool_Bar)
                {////选择是否显示工具条
			if(Tool_Bar.isSelected())
                        {
			ToolBar.setVisible(true);
                        }
			else 
                        {
			ToolBar.setVisible(false);
                        }
		}
        else if(e.getSource() == Format_Bar)
                {////选择是否显示工具条
			if(Format_Bar.isSelected())
                        {
			FormatBar.setVisible(true);
                        }
			else 
                        {
			FormatBar.setVisible(false);
                        }
		}
		else if(e.getSource() == Format_Font)
                {////字体
		   ff = new FontTest(MainFrame.this,"字体",fonttext);
		    TextArea.setFont(ff.font);
            //LogicEvent.SetTextFont(MainFrame.this,"字体",fonttext);
           
            
		}
		else if(e.getSource() == Format_Color || e.getSource() == Mouse_Color || e.getSource() == forcolor_format)
                {////字体颜色选择
			JColorChooser jColor = new JColorChooser(); //调用颜色面板,设置前景就可更改字体颜色
            Color fcolor=TextArea.getForeground(); 
           TextArea.setForeground( jColor.showDialog(TextArea,"选择字体颜色",fcolor)); 
		}
		
       else if(e.getSource() == Edit_Find || e.getSource() == Mouse_Find || e.getSource() == find_tool){
            ft=new FindText();
       }
  
  
       else if(e.getSource() == Edit_Replace || e.getSource() ==Mouse_Replace){
       	    rp =new Replace();
         
       }
       else if(e.getSource()==fontfamily_format||e.getSource()==fontsize_format||e.getSource()==fontbold_format||e.getSource()==fontitcal_format||e.getSource()==fontu_format)
       { 
            int i=new Integer((String) fontsize_format.getSelectedItem());
            if(e.getSource()==fontbold_format)
            {
                fontstatus=Font.BOLD;
            }
              if(e.getSource()==fontitcal_format)
            {
                fontstatus+=Font.ITALIC;
            }
             if(e.getSource()==fontu_format)
            {
               // fontstatus+=Font.
            }
           
                    fonttext=new Font((String)fontfamily_format.getSelectedItem(),fontstatus,i);
            TextArea.setFont(fonttext);
       }
    
    } 
     *  */
           // </editor-fold>
        // <editor-fold defaultstate="collapsed" desc=" 事件函数区 ">   
     public void actionPerformed(ActionEvent e)
    {
     
        if(e.getSource()==File_Exit)
        {
            Exit();
        }
        else if(e.getSource()==Help_AboutUs)
        {
            AboutMe();
        }
        else if(e.getSource()==Format_NewLine)
        {
            if(Format_NewLine.isSelected())
            {
                TextArea.setLineWrap(true);
               
            }
            else
            {
                TextArea.setLineWrap(false);
               
            }
        }
           else if(e.getSource() == File_New || e.getSource() == new_tool)
           {////新建文件
			NewFile();
		}
		else if(e.getSource() == File_Open || e.getSource() == open_tool)
                {////打开文件
			OpenFile();
		}
		else if (e.getSource() == File_Save || e.getSource() == save_tool)
                {///保存文件			
			SaveFile();
		}
		else if (e.getSource() == File_SaveAs)
                {////另存文件
			SaveAsFile();
		}
		
               else if(e.getSource() == Edit_Cut || e.getSource() == cut_tool)
                {
			TextArea.cut();
		}
		else if(e.getSource() == Edit_Copy|| e.getSource() == copy_tool)
                {
			TextArea.copy();
		}
		else if(e.getSource() == Edit_Paste|| e.getSource() == paste_tool)
                {
			TextArea.paste();
		}
		else if(e.getSource() == Edit_Del|| e.getSource() == delete_tool)
                {
			TextArea.replaceSelection("");
		}
		else if(e.getSource() == Edit_SelectAll)
                {/////////////全选
			TextArea.selectAll();
		}
		else if(e.getSource() ==datetime||e.getSource()==datetime_tool)
                {  ////时间/日期
			int inpoint = TextArea.getCaretPosition();//取得当前光标位置
            Date dt = new Date();
            String strdate = dt.toLocaleString();
            TextArea.insert(strdate,inpoint);
		}
		else if(e.getSource() == Edit_Back||e.getSource()==back_tool)
                {
		}
		else if(e.getSource() == Status_Bar)
                {
         Get_Status();
         
		  
		}
		else if(e.getSource() == Tool_Bar)
                {////选择是否显示工具条
			if(Tool_Bar.isSelected())
                        {
			ToolBar.setVisible(true);
                        }
			else 
                        {
			ToolBar.setVisible(false);
                        }
		}
        else if(e.getSource() == Format_Bar)
                {////选择是否显示格式条
			if(Format_Bar.isSelected())
                        {
			FormatBar.setVisible(true);
                        }
			else 
                        {
			FormatBar.setVisible(false);
                        }
		}
		else if(e.getSource() == Format_Font)
                {////字体
		   ff = new FontTest(MainFrame.this,"字体",fonttext);
		    TextArea.setFont(ff.font);
            //LogicEvent.SetTextFont(MainFrame.this,"字体",fonttext);
           
            
		}
		else if(e.getSource() == Format_Color || e.getSource() == forcolor_format)
                {////字体颜色选择
			JColorChooser jColor = new JColorChooser(); //调用颜色面板,设置前景就可更改字体颜色
            Color fcolor=TextArea.getForeground(); //取得前景色
           TextArea.setForeground( jColor.showDialog(TextArea,"选择字体颜色",fcolor)); 
		}
		
       else if(e.getSource() == Edit_Find|| e.getSource() == find_tool){
            ft=new FindText(this,"查找");
       }
  
  
       else if(e.getSource() == Edit_Replace){
       	    rp =new Replace(this,"替换");
         
       }
       else if(e.getSource()==fontfamily_format||e.getSource()==fontsize_format||e.getSource()==fontbold_format||e.getSource()==fontitcal_format||e.getSource()==fontu_format)
       { 
            int i=new Integer((String) fontsize_format.getSelectedItem());
            if(e.getSource()==fontbold_format)
            {
                fontstatus=Font.BOLD;
            }
              if(e.getSource()==fontitcal_format)
            {
                fontstatus+=Font.ITALIC;
            }
             if(e.getSource()==fontu_format)
            {
               // fontstatus+=Font.
            }
           
                    fonttext=new Font((String)fontfamily_format.getSelectedItem(),fontstatus,i);
            TextArea.setFont(fonttext);
       }
    
    } 
    // </editor-fold> 
  
    public static void main(String[] args) 
    {
         java.awt.EventQueue.invokeLater(new Runnable() 
         {
            public void run() 
            {
                new MainFrame().setVisible(true);
            }
        });
    }

    
}

⌨️ 快捷键说明

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