Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!

Timothy Leong

Ranch Hand
+ Follow
since May 25, 2005
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Timothy Leong

Dear all,

I want to write a java application and run it on a Nokia phone.
This application will control using the Nokia IR port with another circuit board with IR comm port.

How do I start doing it? How do I program the Nokia IR port? Thanks a lot
13 years ago
after countless trial and error
I realise it's the bold coding that causes the lag and distortion of my GUI
However I still unable to solve the problem

14 years ago
sorry just to add.

The clock not only lag and it also causes my other components in JFrame to be distorted as well.
14 years ago
Hi guys, I have a status bar created using JLabels in StatusBar class.

This status bar can display the current system time.
This status bar is added onto JFrame. My JFrame has other components like JToolBar, JMenubar another JPanel etc.

I tried using Timer in my StatusBar class. However, I experience lag on my screen. It actually takes 20 sec for the clock to actually work.
How can I make my clock to work straight away? Thanks

public class StatusBar extends JPanel
DateTime currDateTime = new DateTime();
java.util.Timer fTimer = null;

JLabel messageLabel;
JLabel userLabel;
JLabel dateLongLabel;
JLabel timeLabel;

public int i =0;

public StatusBar()
fTimer = new java.util.Timer ();
Color Transparent=new Color(0,0,0,0);
Border border = LineBorder.createGrayLineBorder();

timeLabel = new JLabel( );
dateLongLabel.setPreferredSize(new Dimension(100,30));
timeLabel.setText("TIME ");

Box sbar = Box.createHorizontalBox();

class UpdateTime extends java.util.TimerTask {
public void run () {
final DateFormat df = new SimpleDateFormat("" + " " + i);
timeLabel.setText(df.format(new Date()));
fTimer.schedule (new UpdateTime (), 0, 1000);

14 years ago
If I want to store the dimensions when the java Frame first loads. I should call getHeight, getWidth from the constructor right? But the value I gotten is 0. Is there anyway I can get the initial value?
14 years ago
when a user resize the java application, how can I get dimensions before resized and dimensions after resize??
14 years ago
hi guys,

Suppose I have many panels. How can I call a component in a particular panel from another panel?

For example, I have a panel 1 with a Jbutton. I have another panel 2 with a JLabel. both panels are in different class. Is there a way to get JLabel object of panel 2 from panel 1 so that I can change the Label content?
14 years ago
Wow , thanks Craig. However I have done the GUI myself but my coding is not as professional as yours.

btw, I need to do some event handling.

When user click "F6", the elevator will move up/down to Level 6.
Do I have to use 2 listeners??

1 actionevent listener for UITest to handle buttons
and 1 actionevent listener for CenterPanel for timer to draw elevator??

This is what I have done. Can the experts here suggest to me what's the most efficient way of handling buttons and painting the elevator?

Thank you very much.
15 years ago
hi Dittmer, thanks for your reply.

This is my classpath setting in Environment Variables.

C:\Program Files\Java\jdk1.5.0_02\lib\tools.jar

normally how does classpath directory looks like?
15 years ago
hi guys,

I have the following code

I compile the program and create html coding. however my java app failed to run. It says "Loading java applet failed".

I even ran it as java Tutorial1

This is what I get.....
Exception in thread "main" java.lang.NoClassDefFoundError: Tutorial1

What can I do to make the program going? Thank you
15 years ago
hi Ulf Dittmer, where do you mean by Border concept?
Are you saying that I should have 1 row of F8 , 1 row of F7......
each row has 3 columns??
All rows are added into a frame?
15 years ago
Dear All, how do you create the interface like this?

This is an elevator may go up and down to pick up or send the passenger. When the passenger presses a left button, say �F3�, the elevator goes up from F1. After it arrives, the passenger presses a right button, say �F7�, the elevator goes up and stops on F7. After then it checks whether there is any left button pressed. Assume that the initial position of the elevator is on the first floor (F1), and the display information about the elevator will be updated

This is what I think

I should have 4 panels in a Frame in GridLayout
1 on top as label panel
1 on the left as button panel outside the lift
1 on the right as button panel in the lift
1 which shows the location of the lift.

There's a problem which I cannot understand. How should I draw the line of every storey and make sure the line coincides with the buttons and every components are still in proportion when user max or min the applet??

Thank you very much
15 years ago

how do you find out the ancestors of the particular node?
I'm thinking of storing the ancestors inside the queue.
Can some1 guide me how to solve this? Thanks in advance
15 years ago
yup the key item is in integer form

I have a customer class with name, address and a superclass KeyedItem with Comparable searchKey

I have 2 customers record (account id=20 and account id = 10)

my concern is to
1. add the account id together -> 30
2. copy the first customer record (account id=20) to account id=30

tt's the reason y i cast customer becoz I want to get the object of customer account id 20, change the search key to 30 only while retaining the original values of address and name.

but i find that my code is not robust
15 years ago
hi guys, I am practising with Trees
The code below is belong to a class called BinaryTree
please take a look at the bold portion, i did a Customer casting. As a result, this method is not generic and robust anymore because the whole BinaryTree class can only be used on Customer class but not other classes.
My searchkey is Comparable type which is used to uniquely identify the class.

what should i do so that I no need to use (Customer) casting??

I tried using tmpn1.getClass() tmpn1.getItem()).setKey((Comparable) (v1+v2)); but it doesn;t work.

15 years ago