Friday, November 6, 2009

Java GUI - using Eclipse (GridLayout)

I have spent the last few days searching online a tutorial with a decent explanation on how to create/use GUI functions in Eclipse using Java. Unfortunately, no luck. So after a number of hair pulling and frustrating hours I managed to get down a simple technique which works flawlessly and now I understand how to use the GridLayout properly. This guide is for those that have a general idea of the methods and functions used with GUI and their parameters, but if you want me to expand on something just leave a comment and I'll be glad to do that. At the bottom of the page you will find a screen shot with the code nicely organized.


Here are the steps to making your first GUI using Java. I will use one JComponent to illustrate the use and from there you can expand as much as you like. Here we go.

Step 1: Create a class, import javax.swing.*; , java.awt.*; and java.awt.event.*;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Boom extends JFrame {

}

Step 2: Declare the variables and initial objects you will use as private. We declare the variables and objects in the class because we want them to be accessible to all methods of the class.

public class Boom {
private JLabel entry;
private JTextField input;
private JButton display;

public String userInput;
}


Step 3: Create a constructor for the class you created. This is where you will place all of your code for GUI so that when you call the class everything will be initialized, created and drawn to the frame.

public class Boom extends JFrame {
private JLabel entry;
private JTextField input;
private JButton display;

public Boom()
{
}
}


Step 4: Create JPanel. I will post only the portion of the code we are creating but still within the public Boom() constructor.

JPanel p = new JPanel(new GridLayout(3,1));

Step 5: Finalize object declaration.

JPanel p = new JPanel(new GridLayout(3,1));
entry = new JLabel("Text to display:");
input = new JTextField(20);
display = new JButton("Display");


Step 6: Add objects to JPanel.

p.add(entry);
p.add(input);
p.add(display);


Step 7: Create and register handlers. These will be responsible to identify which handler reacts to which action, you will see what I mean in a second. (Still in the constructor). Note: Don't worry if the ButtonHandler is underlined as red because we are going to create it in the next few steps.

ButtonHandler b = new ButtonHandler();
display.addActionListener(b);


Step 8: Create a JFrame and set the necessary values to begin. Add the JPanel you created to the JFrame.


JFrame frame = new JFrame();
frame.setSize(300, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(p);
frame.setVisible(true);


Step 9: Create a private inner class with the same name as the handler object with ActionListener implementation. Here we are outside of the constructor, but still in the class itself, that's why this is called an inner class. Because we are using the same name for the class as the handler, the display button registered with this handler will only react to the ButtonHandler action event.

private class ButtonHandler implements ActionListener
{
}


Step 10: Within the private class, create a public void actionPerformed method with (ActionEvent e) parameters. Inside the curly braces set what you want to execute when the handler is triggered.

private class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == display)
{
userInput = input.getText();
JOptionPane.showMessageDialog(null, userInput);
}
}
}


Step 11: Create a new class with main method and call for Boom class.

public class Run {
public static void main(String[] args) {
new Boom();
}
}


Using this technique you can make as many panels as you want grouping your fields, buttons nicely and then simply adding them to the JFrame, like we did (frame.add(p);)

Image here: http://img691.imageshack.us/img691/9863/javagridlayout.jpg

Wednesday, November 4, 2009

Adobe Connect Now

Adobe launched a neat tool for elaboration, business, and personal use among team-members. The web-based interface allows users to:
  • communicate over the microphone;
  • share web-cameras;
  • share files;
  • chat;
  • remote desktop;
  • share desktop view;
This tool even has a built-in whiteboard which allows users to draw/type anything they want and let everyone in the room see what's going on.The room consists of an easy-to-use URL address which is customizable for easy memorization.

The incredible thing about this interface is that it doesn't require any additional software or application components to download, just make sure you have the latest Flash Player (plug-in) installed on your machine and you'll be up and running in no time.

Take advantage of this tool and learn more here: http://www.adobe.com/acom/connectnow/

iPhone Problems with Synchronization

It has been few weeks now since the issue regarding iPhone's sync function has been floating on Apple website. Many users are receiving the "error 0xE8000065" error during the synchronization process. Mostly the users experiencing the problem are using Windows 7 operating system. But the problem is not in Windows 7. The error has been vastly noticed in Windows Vista and motherboard built on Intel P55 Express chips.

Intel has been notified of the problem and is currently working to resolve the issue. It's assumed that the problem is with the BIOS or system configuration. Apple is asking consumers to submit an email with details of their machines where iPhone is used (connected). Meaning Apple is doing their own investigation as well. Microsoft is also up on their feet in search of the bug.

NVIDIA introduces Nexus

NVIDIA developed Nexus industry's first development environment for massive parallel computing. Nexus will be integrated into Visual Studio allow coders to analyze efficiency, performance and speed of the GPU and CPU at the same time.

For more information, click here.

How to Upload iPhone Ringtones for Free

Here is a simple guide to uploading your ringtones to iPhone phones. No additional software or hardware is necessary other than what came with the iPhone. During the process make sure your iPhone is already connected just to be safe.

1. Open iTunes, in the Library (of the PC not iPhone) locate the song you want to use as a ringtone (even if it's a full song).

2. Right mouse click the song and choose Get Info. Choose Options tab and place a check mark for Start Time and Finish Time.

3. Pick the 30-40 seconds of the song you want use as the ringtone and use the minute settings in the Start/Finish Time to set start and finish of the song. For example, the song I like is Good Girls Gone Bad by Cobra Starship. I want the first chorus of the song to be my ringtone. It begins at 00:44 and ends at 01:16. So, in the Options tab with Start and End Time check marks set I would set the Start Time to 00:44:00 and End Time to 01:16:00.

4. Click OK. This will create a copy of the song but only with the specified play time.

5. Right click and delete the file you just created, but choose Keep Files at the prompt. This will keep the file in iTunes folder but delete it from the application so you don't have duplicates when you sync your iPhone.

6. Go Start>My Documents>My Music>iTunes>iTunes Music, here locate the folder with either the song name you chose or the Artist name. Usually the folder is created based on the Artist's name.
7. Open the folder, if there is another one open it as well. Here you will find your song file with the extension .m4a

8. Simply right-click the file and choose Rename. Change only the extension from .m4a to .m4r and press Enter. (Optional: You can change the name of the file to your preference)
Note: Depending on your windows operating system your extension might not be visible during the rename stage of this guide because windows hides common extensions from users. In this case do the following. Open Control Panel, open Folder Options, select View tab, locate "Hide extensions for known file types" option and remove the check mark, click OK. Now the extensions are visible.

9. Open the file for Playback in iTunes by double-clicking the file. The file is automatically added to your computers Ringtones section.

10. Now, right-click Ringtones in your iPhone section and choose Sync. Done.

Congratulations you have the knowledge to upload as many ringtones to your iPhone as you like at no cost at all. Post your comments and experiences following this guide. Enjoy.

Wednesday, March 4, 2009

PlayStation 3: Video Settings

Quite an issue many PlayStation 3 users are experiencing after switching cables or TVs. I've experienced the same problem after buying my PlayStation 3 off someones hands.

If you recently switched from HDMI cable to A/V output (for older televisions) you'll notice that your PlayStation 3 is working fine but there is no display on the screen, the reason being is that you haven't changed your video settings to lower or higher resolution depending what you're switching from. But the problem you're experiencing is that you can't switch the video settings on your PlayStation 3 console because there is no display.

To solve this, all you have to do is plug your console in and make sure the red light (stand by) is on. At this point push and hold the reset/power button until you hear two (2) clicks. Doing this procedure once may not be enough, so do it several times but give a few seconds in between for the display to pop-up. First time may not work as your console will just start up, but turn it off and try again. This solved my problem and will yours as well. You either have to change the settings on your console before you switch TVs or perform this procedure after you switched TVs or even cables at times. Enjoy and happy gaming!

Monday, February 9, 2009

DAEMON Tools Pro 4.30.0304: working with image files

Daemon released a new version of their popular image working utility. Daemon Tools Pro gives you an ability to create and manage already created image files. The software works with all kinds of image extensions - .ccd, .pdi, .bwt, .cdi, .b5t, .nrg, .cue, .isz, .iso. Emulator is capable of converting files to the home extension - .mds.

The main advantage of this image utility is that it bypasses many protections CDs or DVDs may have against copying. The majority of protections that Daemon Tools may work with are SafeDisc, SecuROM, LaserLock, RMPS and others. When creating image files you can add a password protection to control who can and can not view the files.

The new version has updated language module, silent mode is fixed and many other issues have been taken care of.

Designers: Daemon's Home
Distribution: shareware
Operating System: Windows All
File Size: 11.5 MB
Download by clicking here.