nirupama singhal

Greenhorn
+ Follow
since Feb 23, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by nirupama singhal

Hello Friends
Can any body tell me how to change color of title bar of a frame??
Thanx in advance
Nirupama
22 years ago
Hi!!!
got the logic behind the problem. thank u all 4 the nice replies
Regards
Nirupama
Hello Friends
I am very new 2 this forum. Can any body explain the below
Regards
Nirupama
Program 1:-
class Ternary1
{
public static void main(String args[])
{
boolean t=true;
byte b;
b = t ? 100 : 120 ;
System.out.println("b=" +b);
}
}
The above program doesn't compile saying that explicit cast needed to convert int to byte
Program 2:-
class Ternary2
{
public static void main(String args[])
{
byte b;
b = true ? 100 : 120 ;
System.out.println("b=" +b);
}
}
This program compiles and runs successfully. But if i take 128 instead of 100 'n' 120 it again does not work.

class Ternary3
{
public static void main(String args[])
{
int b;
b = true ? 100.3 : 120.5 ;
System.out.println("b=" +b);
}
}
While the above does not work.
Hello Friends
Can any body tell me that is there any tool or api available such that it firstly found any run time enviorment available 4 java . if not it downloads from the site.also is there any option to jre available to run java application on windows platform.
Regards
Nirupama
22 years ago
hello friends
can any body tell me , i want to know that if i can run a java application on a m/c having no support for jvm on window platform . can i give reference to microsoft java virtual m/c or how do i give the jre support with my application
regards
nirupama
22 years ago
Hello everybody
I have added JToolTip to the menu items of JPopupMenu. But the problem is tooltip gets flickered at the last menu item. what may b the problem. pls help me
Thanx
Nirupama
22 years ago
Hello Friends
I am working on a java application . I have taken a JFrame having a image covering whole frame. i have added a combo box to this frame 'n' an animated image(a single gif image). now the problem is it is repainting the frame with the movement of logo resulting in flickering in combo box .whats the problem . i simply used Toolkit.getDefaultToolkit().getImage(image); for both the animated 'n' background image. can anybody tell me about this problem.
thanks
nirupama
22 years ago
Hello Cindy
Firstly i must thanks 4 the reply 'n' telling about my mistake. Cindy , I tried again but the problem is same, not listening to key board events with this code.its listening to mouse events but not key board events
Thanx
Nirupama
22 years ago
Hello Cindy,
Firstly Thank u so much 4 the nice reply. ya as u said the popup is invoked 'n' its working too fine with mouse events. But the popup menu is not listening to key board events like up arrow, down arrow key or enter . these key board events work too fine with JMenu, PopupMenu but not with JPopupMenu. I am not able to understand whats the problem with my code.
Regards
Nirupama
22 years ago
Hello Friends
Can any body throw some light why key board events is not listening to the following code. i also tried applying KeyListener to the PopupMenu but still it didn't help.
Thanx is this regards
Nirupama
The code is--
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class PopupMenuExample extends JPanel implements ActionListener, PopupMenuListener , MouseListener
{
public JPopupMenu popup;
public PopupMenuExample()
{
popup = new JPopupMenu();
JMenuItem item;
popup.add(item = new JMenuItem("Left"));
item.setHorizontalTextPosition(JMenuItem.LEFT);
item.addActionListener(this);

popup.add(item = new JMenuItem("Center"));
item.setHorizontalTextPosition(JMenuItem.CENTER);
item.addActionListener(this);


popup.add(item = new JMenuItem("Right"));
item.setHorizontalTextPosition(JMenuItem.RIGHT);
item.addActionListener(this);

popup.addPopupMenuListener(this);
addMouseListener(this);

}
public void mousePressed(MouseEvent event)
{
checkPopup(event);
}
public void mouseClicked(MouseEvent event)
{
checkPopup(event);
}
public void mouseEntered(MouseEvent event)
{
}
public void mouseExited(MouseEvent event)
{
}
public void mouseReleased(MouseEvent event)
{
checkPopup(event);
}

private void checkPopup(MouseEvent event)
{
if(event.isPopupTrigger())
{
popup.show(this, event.getX(), event.getY());
}
}
public void popupMenuWillBecomeVisible(PopupMenuEvent event)
{
System.out.println("popup menu will be visible!");
}

public void popupMenuWillBecomeInvisible(PopupMenuEvent event)
{
System.out.println("popup menu will be invisible!");
}
public void popupMenuCanceled(PopupMenuEvent event)
{
System.out.println("popup menu is hidden!");
}

public void actionPerformed(ActionEvent event)
{
System.out.println("Popup menu item["+event.getActionCommand()+"]was pressed.!");
}
public static void main(String s[])
{
JFrame frame = new JFrame("popup menu example");
frame.setContentPane(new PopupMenuExample());
frame.setSize(300,300);
frame.setVisible(true);
}
}
22 years ago
hi!!
can any body whats protocol exception? when it is thrown? whats TCP error.
thanks
nirupama
22 years ago
Well Bodie
the code is given below. pls check it out where the problem is
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.plaf.basic.*;
public class PopupMenuExample extends JPanel implements ActionListener, PopupMenuListener , MouseListener,KeyListener
{
public JPopupMenu popup;
public PopupMenuExample()
{
popup = new JPopupMenu();
JMenuItem item;
popup.add(item = new JMenuItem("Left"));
item.setHorizontalTextPosition(JMenuItem.RIGHT);
item.addActionListener(this);

popup.add(item = new JMenuItem("Center"));
item.setHorizontalTextPosition(JMenuItem.RIGHT);
item.addActionListener(this);

item.setMnemonic(KeyEvent.VK_T);
popup.add(item = new JMenuItem("Right"));
item.setHorizontalTextPosition(JMenuItem.RIGHT);
item.addActionListener(this);

popup.add(new JMenuItem("Full"));
item.setHorizontalTextPosition(JMenuItem.RIGHT);
item.addActionListener(this);

popup.addSeparator();
popup.add(item = new JMenuItem("Settings ..."));
item.addActionListener(this);

popup.setLabel("Justification");
popup.setBorder(new BevelBorder(BevelBorder.RAISED));
popup.addPopupMenuListener(this);
addMouseListener(this);
popup.addKeyListener(this);


}
public void mousePressed(MouseEvent e)
{
checkPopup(e);
}
public void mouseClicked(MouseEvent e)
{
checkPopup(e);
}
public void mouseEntered(MouseEvent e)
{
}
public void mouseExited(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e)
{
checkPopup(e);
}

private void checkPopup(MouseEvent e)
{
if(e.isPopupTrigger())
{
popup.show(this, e.getX(), e.getY());
}
}
public void popupMenuWillBecomeVisible(PopupMenuEvent e)
{
System.out.println("popup menu will be visible!");
}

public void popupMenuWillBecomeInvisible(PopupMenuEvent e)
{
System.out.println("popup menu will be invisible!");
}
public void popupMenuCanceled(PopupMenuEvent e)
{
System.out.println("popup menu is hidden!");
}

public void actionPerformed(ActionEvent event)
{
System.out.println("Popup menu item["+event.getActionCommand()+"]was pressed.!");
}
public void keyTyped(KeyEvent e)
{
System.out.println("key typed");
}
public void keyReleased(KeyEvent e)
{
System.out.println("key released");
}
public void keyPressed(KeyEvent e)
{
System.out.println("key pressed");
}

public static void main(String s[])
{
JFrame frame = new JFrame("popup menu example");
frame.setContentPane(new PopupMenuExample());
frame.setSize(300,300);
frame.setVisible(true);
}
22 years ago
Well Bodie, as per ur suggestion i tried addKeyListener() also but JPopupMenu is not listening any key board events even navigation keys . what may be the problem. pls suggest something
thanks
nirupama

Originally posted by Bodie Minster:
JPopupMenu inherits from JComponent, which inherits from Container, which inherits from Component. The Component class includes a method addKeyListener(), so you should be able to make this work.


22 years ago
hi!! can any body tell me how to find out whether TCP/IP 'n' other net services r enabled on a system thru a java program. i have to find out for windows platform.
Thanks
Nirupama
22 years ago
Hi!!
I am working with JPopupMenu. But the probelm is Popupmenu cannot able to listen keyboards events.what may be the error? can some ont throw some light on my problem.
Thanks
nirupama
22 years ago