Archive for the 'Programming' Category

We need to create a process object, and then wait for the process to finish. This launches an external program (notepad in this example):

Process process = Runtime.getRuntime().exec("C:\\windows\\system32\\notepad.exe");
process.waitFor();

And that’s all there is to it! The included code will obviously only work if you have a program called notepad.exe at that given location, and you’ll also need to enclose it in a try / catch block (see the attached file if you’re not sure how.)

Tags: , , , ,

A tool tip can show simple HTML tags when surrounded by the tags <HTML> and </HTML). This example shows how to include an image in a tool tip by using the <IMG> tag. See the javax.swing.text.html.HTML class documentation for a list of other supported tags.

String imageName = “file:image.jpg”;
component.setToolTipText(”<html>Here is an image <img src=”+imageName+”></html>”);

Tags: , , , , , , ,

A tool tip can show simple HTML tags when surrounded by the tags <HTML> and </HTML>. This example shows how to create multiple lines by using the <BR> tag. See the javax.swing.text.html.HTML class documentation for a list of supported tags.

// Show two lines in the tool tip
component.setToolTipText(”<html>”+”This is a”+”<br>”+”tool tip”+”</html>”);

// By default, the lines are left justified. Center the lines.
component.setToolTipText(”<html><center>”+”This is a”+”<br>”+”tool tip”+”</center></html>”);

// Italicize the second line
component.setToolTipText(”<html>”+”This is a”+”<br><i>”+”tool tip”+”</i></html>”);

Tags: , , , , , , ,

By default, a tool tip stays visible for 4 seconds. This example demonstrates how to keep the tool tip showing as long as the cursor is in the component.

// Get current delay
int dismissDelay = ToolTipManager.sharedInstance().getDismissDelay();

// Keep the tool tip showing
dismissDelay = Integer.MAX_VALUE;
ToolTipManager.sharedInstance().setDismissDelay(dismissDelay);

Tags: , , , , , , ,

By default, when the cursor enters a component, there is a 750-millisecond  delay before the tool tip is displayed.  This example demonstrates how to show the tool tip immediately.

// Get current delay
int initialDelay = ToolTipManager.sharedInstance().getInitialDelay();

// Show tool tips immediately
ToolTipManager.sharedInstance().setInitialDelay(0);

// Show tool tips after a second
initialDelay = 1000;
ToolTipManager.sharedInstance().setInitialDelay(initialDelay);

Tags: , , , , , , ,

By default, tool tips are enabled for the entire application. So if a component has a tool tip text, it will be displayed. To enable or disable tool tips for the entire application, ToolTipManager.setEnabled() is used. Note: Enabling or disabling the tool tip for a particular component can be done only by adding or removing the tool tip text on the component.

// Enable tool tips for the entire application
ToolTipManager.sharedInstance().setEnabled(true);

// Disable tool tips for the entire application
ToolTipManager.sharedInstance().setEnabled(false);

Tags: , , , , , , ,

By default, when a tool tip of a component appears, its northwest corner appears at the same x-coordinate as the cursor and 20 pixels lower than the y-coordinate of the cursor. To change this default location for a component, the getToolTipLocation() method of the component must be overridden.

// Set the location of the tool tip such that its nw corner
// coincides with the nw corner of the button
JButton button = new JButton(”My Button”) {
public Point getToolTipLocation(MouseEvent event) {
return new Point(0, 0);
}
};

// Set the location of the tool tip such that its nw corner
// coincides with the bottom center of the button
button = new JButton(”My Button”) {
public Point getToolTipLocation(MouseEvent event) {
return new Point(getWidth()/2, getHeight());
}
};

// Use the default tool tip location
button = new JButton(”My Button”) {
public Point getToolTipLocation(MouseEvent event) {
return null;
}
};

// Set the tool tip text
button.setToolTipText(”aString”);

Tags: , , , , , , ,

Setting a Tool Tip

If a JComponent such as a JButton, JLabel, JTextField, JComboBox, etc. is created using an action, the component will be created with the tool tip text in the action . However, if the action does not have any tool tip text or if it must be changed, use JComponent.setToolTipText() is used.

JComponent button = new JButton(”Label”);

// Set tool tip text
button.setToolTipText(”tool tip text”);

Tags: , , , , , , ,

Mobile Application Tutorial using J2ME

click here to DOWNLOAD
click here to DOWNLOAD mirror

Tags: , , , , ,

Read the rest of this entry »

Tags: , , , , , , , ,

Read the rest of this entry »

Tags: , , , , , , , ,