Design Java UI Like Visual Basic

One of the most frustrating and time-consuming tasks in Java is creating basic, boring, ordinary UI.  As in, windows, buttons, scroll bars, text fields, etc.

This is in stark contrast to, say, Visual Basic, where you can just drag and drop elements onto a form, and what you see is what you get.  In Java, if you want anything other than just the basics, you're going to have to do a lot of typing.

That is, unless, you are using the WindowBuilder Engine and Eclipse.

  • In Eclipse (3.7 at time of this writing), go to Help -> Install New Software.
  • Enter this address:
    • http://download.eclipse.org/windowbuilder/WB/integration/3.7
  • Download everything listed, then restart Eclipse:

After this, right-click in your project's src folder to create a new item.  Chose "other", then select the "Application Window" under Window Builder->Swing Designer:

Open the file you've created, and notice something cool-- you now have a "design" tab at the bottom of the code window.  Click it.  You now see a screen like so:


Notice it now looks a great deal like Visual Basic?

The True Price of Using LED Lights

LED light bulbs have recently become much cheaper and more reliable, but what is the real price of ownership?  How long do you have to use them before you "break even" compared to traditional lights?  Below, I do the math so you don't have to!

Some caveats:  I am using 60 watts (eqv) as the base measurement, and prices from Walmart.  At the time of this writing, a reliable LED bulb can be bought for $8, a compact florescent for $3.85, and a standard incandescent for about $1.50.

I am using a rate for electricity costs of 11 cents per kilowatt hour.  Your mileage may vary!

Replacement price:  Factored into these values is the assumption that you will have to pay for bulb replacements as well!  An incandescent bulb only lasts for 1,000 hours.  A CFL bulb for about 10,000.  And the LED bulb in question for 30,000 hours.

At 8 - 10 hours of use per day, 10,000 hours represents around 3 years of real-world use.

Let the data begin!

Hrs of use 60W Incandescent 13W CFL 11W LED
1 $1.51 $3.85 $8.00
100 $2.16 $3.99 $8.12
1,000 $9.60 $5.28 $9.21
2,000 $19.20 $10,56 $18.42
3,000 $28.80 $15.84 $27.63
4,000 $38.40 $21.12 $36.84
5,000 $48.00 $26.40 $46.05

So far, you will notice that the clear winner is the 13W compact florescent bulb (it's the "curly-Q" kind.  Notice, too, the false economy of using the cheaper incandescent bulbs.  Their low price is quickly outpaced by their electricity consumption and frequent replacements.

But, where things start to get interesting is once we start measuring hours by the 10-thousand.  This is because CFL's are only rated for 10,000 hours, and now we must replace them every 10,000 hours!

Hrs of use 60W Incandescent 13W CFL 11W LED
10,000 $96.00 $56.65 $55.26
20,000 $192.00 $121.30 $110.52
30,000 $288 $169.95 $173.78*
40,000 $384 $226.60 $229.04
50,000 $480 $283.25 $284.30

* The jump in price for LED at 30,000 is because we must buy another $8.00 bulb, as it is only rated for 30,000 hours.

Conclusion

After 10,000 hours, the cost of electricity & bulb cost is very close for the CFL and LED bulb, differing by only a few dollars.  Personally, I would stick with the LED bulb.  The extra couple dollars in price (every 30,000 hours, or 9 years) is offset by saving me time not having to change any bulbs!

Also, LED bulbs run cooler, contain no mercury, and generally don't shatter because they are encased in plastic instead of glass (usually).

Also, something to keep in mind:  These prices are based on the time of this writing (2014).  LED prices will continue to drop and drop, and their wattage may lower as well, to become even more competitive.

 

Every Drupal Site Should Be Using Boost

Every Drupal site-- whether 6, 7, or (in the future) 8, should be using the Boost module rather than the default caching system.  If you've never heard of the Boost module, then you're in luck-- that's what the rest of this blog post is about!

 

Drupal - Slow and a Memory Hog!

When a visitor comes to your drupal site, several things have to take place.  Your web server (probably Apache) realizes it's a request for Drupal.  It then hands off execution to PHP.

PHP (through Drupal's bootstrap) must then include() and execute dozens or even hundreds of .module, .inc, and .php files from the various modules you have installed.

Those modules might make dozens or hundreds of calls to your database, gathering all the data needed to display the page to the user.

Finally, the HTML is created and handed down to the user's browser for display to the user.

As you can see, this is a slow and memory-intensive process!  If your site is even remotely popular, it can slow down your server or even cause you to run out of memory on the server.  Never a good thing.

Best Free Apps for Android - The App

If you are anything like me, you like finding nifty apps for your android phone, but are also too much of a cheapskate to actually pay for such an app unless it's really remarkable.

Well, I decided to assemble the best free apps for android I could find into its own app, where you can download and even launch directly from the app itself.

It's called simply Best Free Apps!, and it was released under my more legitimate software company, Offworld Software.

The list of apps are categorized and hand-curated.  Unfortunately, a lot of free apps on the marketplace lure you in, but then bombard you with advertising notifications or popups.  There's none of that in Best Free Apps!, just a basic banner ad at the bottom.

Check it out!

Download from Google Play

PastePage - Instantly create a web page, no login required

Have you ever wanted to just put something out there on the web, but you didn't want to go through the trouble of setting up a Blogger account, or similar service?

If so, you should check out my new project: PastePage.  Inspired by pastebin.com (an excellent developer resource), PastePage lets you instantly create a web page with no registration or login required.

Just go to pastepage.net, make your basic page, and hit Save.  It will create a new page with a short, random URL, for easy posting to Facebook, twitter, emails, etc.

If you do decide to register, you can edit your old posts (even ones you've saved while not logged in, thanks to a cookie system).

Check it out!

Backblaze - Online Backups on the Cheap

My online backup system of choice, Backblaze, has saved my caboose a few times, so I thought it was time I pay it forward and tell others about this really cool service.

Full disclosure: I am not being paid by Backblaze, and I am receiving no commission for linking to them.

You've probably heard about other online backup services, like Carbonite.  If you haven't, here's the quick version:  files and directories you specify on your computer get backed up, through the Internet, to a remote server while your computer isn't being used.

They are only backed up when they change, so, for example, if you are a programmer, only the files you have altered will get re-sent to the cloud, minimizing the amount of network traffic going out each day.

It's essential that if you need important backups, they be offsite.  That way a fire, flood, lightening strike, theft, etc, won't cripple you; you can always log in and retrieve your data through the web.

Anyway, like Carbonite, Backblaze is $5/month.  Unlike Carbonite, though, it will back up any file by default, just about any size, and I personally just find it easier to use.  $5 a month is the cheapest insurance you can buy for your data.

Another great feature is you can restore files up to a month old.  I had to use this today:  I accidentally did something that ruined a git repository for a project I am working on.  Rather than try to piece it back together again, I logged into Backblaze and downloaded a snapshop of the entire directory as of 11pm last night.  Within minutes I was downloading a zip file of that directory.  So nice.

In case you were wondering Backblaze (and probably Carbonite as well) give you unlimited storage and bandwidth, so feel free to tell it to back up your 2TB hard drive, though realistically I only back up certain directories on my computer.  No need to back up C:\Windows or Program Files.

I also back up my websites by having my site's files and db downloaded every night to my hard drive, which Backblaze then backs up automatically.

So check it out!

 

Android Games with Gamepad Support

If you happen to own an Android-based phone or tablet, and you also happen to enjoy playing games with a real gamepad instead of on-screen controls, then you are in luck.

I recently started a new site, specifically for the purpose of keeping up with games that have these options.  It's called simply Android Gamepad Games (androidgamepadgames.com).

There's also now an official app on the Google Play store!  Check it out here.  You can even launch your games directly from the app, making it more like a console experience.

The list can be sorted, and entries includes a screenshot taken from the Google Play store.  The list is hand-curated by yours truly, but updates can easily be submitted if you notice a problem.

Enjoy!

 

LibGDX Keycodes to Strings

If anyone out there is using the wonderful libGDX library for their mobile games, and are using the wonderful Controllers library that goes along with it, perhaps you've run into a problem which I found:  I wanted a way to let the player see the names of they keys they had mapped on the keyboard to different controls.

Well, in order to do that, I needed to know what the English names were associated with they keycodes delivered, for example, to the keyDown method.

So, I made a HashMap for my own uses, and thought I'd put it here.  It isn't complete, but it has most of the keys.  Enjoy!

public static HashMap<Integer, String> keycodeNames 
                          = new HashMap<Integer, String>();
 
  static {
    keycodeNames.put(7, "NUM_0");
    keycodeNames.put(8, "NUM_1");
    keycodeNames.put(9, "NUM_2");
    keycodeNames.put(10, "NUM_3");
    keycodeNames.put(11, "NUM_4");
    keycodeNames.put(12, "NUM_5");
    keycodeNames.put(13, "NUM_6");
    keycodeNames.put(14, "NUM_7");
    keycodeNames.put(15, "NUM_8");
    keycodeNames.put(16, "NUM_9");
    keycodeNames.put(29, "A");
    keycodeNames.put(57, "ALT_LEFT");
    keycodeNames.put(58, "ALT_RIGHT");
    keycodeNames.put(75, "APOSTROPHE");
    keycodeNames.put(77, "@");
    keycodeNames.put(30, "B");
    keycodeNames.put(4, "BACK");
    keycodeNames.put(73, "\\");
    keycodeNames.put(31, "C");
    keycodeNames.put(5, "CALL");
    keycodeNames.put(27, "CAMERA");
    keycodeNames.put(28, "CLEAR");
    keycodeNames.put(55, ",");
    keycodeNames.put(32, "D");
    keycodeNames.put(67, "BACKSPACE");
    keycodeNames.put(112, "FORWARD_DEL");
    keycodeNames.put(23, "CENTER");
    keycodeNames.put(20, "DOWN");
    keycodeNames.put(21, "LEFT");
    keycodeNames.put(22, "RIGHT");
    keycodeNames.put(19, "UP");
    keycodeNames.put(33, "E");
    keycodeNames.put(6, "ENDCALL");
    keycodeNames.put(66, "ENTER");
    keycodeNames.put(65, "ENVELOPE");
    keycodeNames.put(70, "=");
    keycodeNames.put(64, "EXPLORER");
    keycodeNames.put(34, "F");
    keycodeNames.put(80, "FOCUS");
    keycodeNames.put(35, "G");
    keycodeNames.put(68, "GRAVE");
    keycodeNames.put(36, "H");
    keycodeNames.put(79, "HEADSETHOOK");
    keycodeNames.put(3, "HOME");
    keycodeNames.put(37, "I");
    keycodeNames.put(38, "J");
    keycodeNames.put(39, "K");
    keycodeNames.put(40, "L");
    keycodeNames.put(71, "[");
    keycodeNames.put(41, "M");
    keycodeNames.put(90, "FAST_FORWARD");
    keycodeNames.put(87, "NEXT");
    keycodeNames.put(85, "PLAY_PAUSE");
    keycodeNames.put(88, "PREVIOUS");
    keycodeNames.put(89, "REWIND");
    keycodeNames.put(86, "STOP");
    keycodeNames.put(82, "MENU");
    keycodeNames.put(69, "MINUS");
    keycodeNames.put(91, "MUTE");
    keycodeNames.put(42, "N");
    keycodeNames.put(83, "NOTIFICATION");
    keycodeNames.put(78, "NUM");
    keycodeNames.put(43, "O");
    keycodeNames.put(44, "P");
    keycodeNames.put(56, ".");
    keycodeNames.put(81, "+");
    keycodeNames.put(18, "#");
    keycodeNames.put(26, "POWER");
    keycodeNames.put(45, "Q");
    keycodeNames.put(46, "R");
    keycodeNames.put(72, "]");
    keycodeNames.put(47, "S");
    keycodeNames.put(84, "SEARCH");
    keycodeNames.put(74, ";");
    keycodeNames.put(59, "SHIFT_LEFT");
    keycodeNames.put(60, "SHIFT_RIGHT");
    keycodeNames.put(76, "/");
    keycodeNames.put(1, "SOFT_LEFT");
    keycodeNames.put(2, "SOFT_RIGHT");
    keycodeNames.put(62, "SPACE");
    keycodeNames.put(17, "STAR");
    keycodeNames.put(63, "SYM");
    keycodeNames.put(48, "T");
    keycodeNames.put(61, "TAB");
    keycodeNames.put(49, "U");
    keycodeNames.put(0, "UNKNOWN");
    keycodeNames.put(50, "V");
    keycodeNames.put(25, "VOLUME_DOWN");
    keycodeNames.put(24, "VOLUME_UP");
    keycodeNames.put(51, "W");
    keycodeNames.put(52, "X");
    keycodeNames.put(53, "Y");
    keycodeNames.put(54, "Z");
    keycodeNames.put(129, "CONTROL_LEFT");
    keycodeNames.put(130, "CONTROL_RIGHT");
    keycodeNames.put(131, "ESCAPE");
    keycodeNames.put(132, "END");
    keycodeNames.put(133, "INSERT");
    keycodeNames.put(92, "PAGE_UP");
    keycodeNames.put(93, "PAGE_DOWN");
    keycodeNames.put(94, "PICTSYMBOLS");
    keycodeNames.put(95, "SWITCH_CHARSET");
    keycodeNames.put(255, "BUTTON_CIRCLE");
    keycodeNames.put(96, "BUTTON_A");
    keycodeNames.put(97, "BUTTON_B");
    keycodeNames.put(98, "BUTTON_C");
    keycodeNames.put(99, "BUTTON_X");
    keycodeNames.put(100, "BUTTON_Y");
    keycodeNames.put(101, "BUTTON_Z");
    keycodeNames.put(102, "BUTTON_L1");
    keycodeNames.put(103, "BUTTON_R1");
    keycodeNames.put(104, "BUTTON_L2");
    keycodeNames.put(105, "BUTTON_R2");
    keycodeNames.put(106, "BUTTON_THUMBL");
    keycodeNames.put(107, "BUTTON_THUMBR");
    keycodeNames.put(108, "BUTTON_START");
    keycodeNames.put(109, "BUTTON_SELECT");
    keycodeNames.put(110, "BUTTON_MODE");
    keycodeNames.put(144, "NUMPAD_0");
    keycodeNames.put(145, "NUMPAD_1");
    keycodeNames.put(146, "NUMPAD_2");
    keycodeNames.put(147, "NUMPAD_3");
    keycodeNames.put(148, "NUMPAD_4");
    keycodeNames.put(149, "NUMPAD_5");
    keycodeNames.put(150, "NUMPAD_6");
    keycodeNames.put(151, "NUMPAD_7");
    keycodeNames.put(152, "NUMPAD_8");
    keycodeNames.put(153, "NUMPAD_9");
  }

 


Software License Fine Print

This code is considered "open source," and is released under the GNU Public License version 3 or any later version (http://www.gnu.org/copyleft/gpl.html). In a nut shell, you can change this code however you want, and redistribute it, but ONLY if it is ALSO under the GNU Public License version 3 or later.  This code/software is given "as-is", with no warranty or guarantee.

If you use this code/software, I would appreciate credit and a link back to this site (richardpeacock.com), though this is not required.

Alex the Alien

Who doesn't like new games?  No one, that's who.  And you're not no one, then you may enjoy my latest game: Alex the Alien and the Mummy's Pyramid.

I just released it for the new Android-powered OUYA system, though I'm planning to also release it for the Google Play and Amazon App Store android marketplaces too.

You play as Alex, a little alien who has become trapped in a mummy's pyramid, and now much solve the puzzle of each level to make it to the exit.

But you can read more about it on my other site, offworldsoftware.com.

You can also see the complete write-up on the site OUYAlytics.com.

Sample screenshot:

Dropbox and Eclipse IDE

Even though I have already written about the usefulness of Dropbox for programmers, I'd like to share another tip specifically for the Eclipse IDE, and any IDE based on Eclipse.

You may not have realized it, but Eclipse (and derivatives-- Aptana, Titanium, etc) can be run as a "portable" application.  Meaning, you can just copy the entire Eclipse directory to another computer or, say, a USB drive, and it will run exactly the same, with all of your settings in tact.

This means it is a perfect friend for Dropbox.  I place my Eclipse IDEs in folders under Dropbox, and make sure my Workspace is pointed to a folder within Dropbox, and presto-- my projects, settings, etc, are on all of my computers and ready to go.

And any changes I made to my source code, preferences, layout, etc, are automatically spread to my other computers.

Now, this does require that your Dropbox folder is at the same path location on all of your computers.  But, luckily, Dropbox lets us specify exactly what path to use.  So, for example, you could just make sure that your Dropbox folder is always at C:\dropbox.

 

Syndicate content