Venkatesh Chitnis

Greenhorn
+ Follow
since Nov 05, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Venkatesh Chitnis

May be this can help...

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

public class TestSlider extends JFrame
{
Container c = getContentPane();
public TestSlider()
{
JSlider slider = new JSlider(0,100);
slider.setForeground(Color.RED);
slider.setMajorTickSpacing(10);
slider.setMinorTickSpacing(5);
slider.setPaintLabels(true);
slider.setPaintTrack(true);
slider.setSnapToTicks(true);
c.add(slider);
setSize(400,400);
setVisible(true);
}
public static void main(String[] args)
{
TestSlider slider = new TestSlider();
}
}
20 years ago
Can you post your code?
20 years ago
Hi Lakshmi,

I can answer your question about Singleton Design pattern.
A Singleton Design pattern is meant to instantiate a class only once. In many cases it is absolutely essential to have a unique instance of a class.

Here's one of the ways to implement the Singleton pattern:

class SingletonPattern
{
// Constructor
protected SingletonPattern()
{
// Add your code here
}

private static SingletonPattern instance = null;

public static SingletonPattern getInstance()
{
if (instance == null)
return new SingletonPattern();
else
return instance;
}

This design allows access to the getInstance method, but at the same time does not allow access to the SingletonPattern object.
If you are writing a simple application, here are a few suggestions.
1) If you have a single text field to enter the date (assuming the format is mm/dd/yyyy), you can read the year first. You can check the condition if the is entered as desired; minimum value <= year <= maximum value.
If this condition is satisfied, you can check if the month and day entered is valid. java.util.Calendar provides with methods like getActualMinimum and getActualMaximum which you can use to check the validity of entered field.
2) A better solution is to provide a combobox from where the user can make his selection.
20 years ago
Try this...
fc.setFileView(new ImageFileView());
fc.setAccessory(new ImagePreview(fc));
instead of
fc.setFileView(new imageFileView());
fc.setAccessory(new imagePreview(fc));
20 years ago
Hi Sandeep,
A textfield can only handle events if you add Listeners to it.
Do you need anything more specific?
20 years ago
Since you are executing an encrypted file from an applet, the JVM puts restrictions on the applet.
That could be the reason you cannot execute the applet.
You might need to change the security settings in order to get the applet working.
20 years ago
Roberto,
The methods fillSquare and fillTriangle do not exist. What JDK are you using for compling this code?
Are you getting any specific error while executing this code?
20 years ago
I am running a Java client application on HP-UX(version 11.11). The application displays a file structure. On clicking a particular icon, it displays the contents of that folder.
On clicking the icon, a hourglass and a cursor appears (as it does in all Windows applications). However, the size of hourglass and cursor is not proportional to the size of the text (it's too large in comparison with the size of the text). Can anyone let me know about the cause of this and recommend a solution?
Thanks,
Venkatesh
20 years ago