Skip to main content

Posts

Showing posts with the label ide-editor

using Class.getResource() load resource file in Eclipse

There are many ways to load resource file in java app. What sun recommended is using Class.getResource(" resource_name ") or Class.getResourceAsStream(" resource_name ") then you will get URL and InputStream respectively. If resource_name is specified without "/", it will be prepend with Class package. So resource file must be in same place[folder structure] as the Class. What I love to do is call getResource() with "/" and put resource file at the root of package. This way i can have separate resource folder. below is in Eclipse, 1. From Package explorer right click src folder->click import 2. In import dialog, Choose General->File System ->next 3. from directory:->Browse to your resource folder. 4. to folder:-> I add "resource" as a folder name under src folder. then click "Finish". In the code, load resource with this.getClass().getResource("/resource/buttons1.png") or this.getClass().getResourceAs...

Make your eclipse look better on ubuntu

When using eclipse on ubuntu, extra space between items and fonts size make it look awkward. I try to adjust fonts by go to [Window->Preferences->General->Appearance->Colors and Fonts]. This will not much help, reduce fonts size does not change space between item. Here is Eclipse Europa before tweak. Anyway, at last I found the way to make eclipse look more compact from googling. Thank for Wesley and Vladimir Buell for this trick . Create ".gtkrc-2.0" in your home directory enable you to customize gtk object style[more about gtkrc-2.0]. Here is my ".gtkrc-2.0". pnix@pnix-a7n:~$ cat .gtkrc-2.0 style "gtkcompact" { font_name="Sans 8" GtkButton::default_border={0,0,0,0} GtkButton::default_outside_border={0,0,0,0} GtkButtonBox::child_min_width=0 GtkButtonBox::child_min_heigth=0 GtkButtonBox::child_internal_pad_x=0 GtkButtonBox::child_internal_pad_y=0 GtkMenu::vertical-padding=1 GtkMenuBar::internal_padding=0 GtkMenuItem::horizontal_paddin...

include external jar into your own exported jar

One problem that almost java guys have is create jar with external jar include. In eclipse it has export function to export project but there's no way to add external jar with this method. Today I found one solution, the project Fat Jar Eclipse Plug-In can take care this problem. Installation is just unzip it to eclipse folder then restart eclipse in shell or command line with this command "eclipse -clean". Now your eclipse already have fatjar plugin. To use it export the project, from your package explorer, right click on your project and select "Export...". You will get "Export Dialog"[see pic], choose Other->Fat Jar Exporter. From here you will know what to do next.:)

color your nano

nano editor is no syntax highlight for any language by default. It is only black and white as in the picture below. To enable syntax highlight, you can uncomment the line [# include "/usr/share/nano/ruby.nanorc"]in /etc/nanorc[for global effect]. Or if you just want this effect to your user only. create ~/.nanorc and include default[sample] language specific config file from /usr/share/nano. Here is my java syntax highlight .nanorc file include "/usr/share/nano/java.nanorc"

Backspace and Delete keys problem in vim

When I press arrow,backspace,del buttons in text editor, I expect something like "backspace" deletes the character to the left[of the cursor], "delete" deletes the character to the right and "arrow" should move cursor to correct direction in document. Since I move to Feisty Fawn. I just notice that Backspace and Delete Keys are not act as it should be in VIM editor e.g. , In insert mode, the arrow buttons will insert the letters A, B, C, D each followed by a CR. If I press backspace, the cursor moves back, but the letter doesn't go away. Also delete button will deletes all letters that on the right of cursor and change case of previous letter. Below is a pic when I type up, down, right, left, some text, backspace and del [Some web said] "backspace key" will sent ASCII character 8[decimal] and "delete key" sent 127[decimal] [try man ascii for a list of the ASCII characterset]. The backspace key also has the representation ^H [Ctrl-H]...