Set up wallpaper for jedit (add wallpaper for jedit)
Last Update:2017-02-28
Source: Internet
Author: User
1). Premises (condition) + jedit4.2final+ jdk 1.42). Step (steps) 1. Add this in Org.gjt.sp.jedit.textarea.TextAreaPainterin method Paintcomponent (...) after: extensionmgr.paintscreenlinerange (TextArea, GFX, firstinvalid, lastinvalid, y, height);add: {//Paint wallpaper after-should be paint rectangle rect = This.getvisiblerect (); wallpaper.paintwallpaper (GFX, Rect.x, Rect.y, rect.width, rect.width, this); } 2. Add in org.gjt.sp.jedit.textarea.jedittextarea // {{{ Changewallpaperdialog () method //for Change the wallpaper /** * Displays the ' changewallpaperdialog ' dialog box. * @author neoedmund & nbsp */ public void Changewallpaperdialog () { if (Wallpaper.changewallpaper (this)) { repaint (); } }}}3. Add new Class org.gjt.sp.jedit.textarea.wallpaper/* * Created on 2005-3-26 */package Org.gjt.sp.jedit.textarea;import Java.awt.alphacomposite;import Java.awt.composite;import Java.awt.Graphics2D; Import Java.awt.image.bufferedimage;import java.io.file;import java.io.fileinputstream;import java.io.IOException; Import Java.io.inputstream;import Javax.imageio.imageio;import Javax.swing.jcomponent;import javax.swing.jfilechooser;/** * @author neoe */public class wallpaper { static bufferedimage pic; private static final String defalut_img = "org/gjt/sp/jedit/icons/ Wallpaper.jpg "; static{ system.out.println (" Hello Wallpaper "); loadpic (classloader .getsystemresourceasstream (defalut_img)); } static alphacomposite alpha = alphacomposite.getinstance ( alphacomposite.src_over, 0.2f); /** * @param gfx * @param width * @param height */&NBSP ; public static void Paintwallpaper (graphics2d g, int cx, int cy, int width, int height, jcomponent view) {&NB sp; if (pic==null) { &nbsP return; } int y = 0 ; int w = pic.getwidth (); int h = Pic.getheight (); composite old = G.getcomposite (); g.setcomposite (Alpha); while (true) { int x = 0; while (true) { & nbsp g.drawimage (pic, cx+x, cy+y, view); x + w; if (w <= 0 | | x >= width) { & nbsp break; } } y + + h; if (H <= 0 | | Y >= height) { break; } } G.setcomposite (old); } /** * @param in */ private static void Loadpic (InputStream in) { try { pic = Imageio.read (in); } catch ( IOException e) { e.printstacktrace (); } } static File f; /** * */ public static Boolean Changewallpaper ( JComponent parent) { jfilechooser JFC = new JFileChooser (f); & nbsp; int ReturnVal = jfc.showopendialog (parent); if (returnval = = jfilechooser.approve_option) { f = Jfc.getselectedfile (); try { loadpic (New FileInputStream (f)); return true;  } catch (IOException E1) { e1.printStackTrace (); } } return false; }}4. Copy default wallpaper whatever you to org/gjt/sp/jedit/icons/wallpaper.jpg5. Add this into ORG\GJT p\jedit\actions.xml<action name= "Change-wallpaper" > <CODE> textarea.changewallpaperdialog (); </CODE></ACTION> 6. Change Org\gjt p\jedit\jedit_gui.props, add "change-wallpaper" in tool bar#{{{tool Barview.toolbar=new-file Open-file Close-buffer save-print Page-setup-\ undo redo Cut Copy paste-find Find-next-new-view unsplit \ split-horizontal split-vertical-buffer-options global-options-\ Plugin-manager-help-change-wallpaper.........change-wallpaper.icon=help.png........change-wallpaper.label= Change $Wallpaper 7. Last step, rebuild SOURCE, restart JEdit, have fun. Notes:i don ' t know if it's something slowdown, but I like it:)