Fri Jul 27, 2012 9:21 am
if (command == "hashmapBox")
{
HashMap<String, String> lookup = new HashMap<String, String>();
lookup.put("switch name", " 1.3.6.1.2.1.1.5.0");
lookup.put("another name", " 1.3.6.1.2.1.1.4.0");
System.out.println(lookup.get("another name"));
Set s = lookup.entrySet();
Iterator i = s.iterator();
while (i.hasNext()) {
System.out.println(i.next());
}
}
Fri Jul 27, 2012 10:18 pm
JButton loadBts = new JButton("Load");
loadBts .addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// change text value here.
}
});
JComboBox comboBox= new JComboBox();
comboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
// change the text field value here.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Sat Jul 28, 2012 5:01 am
Sat Jul 28, 2012 8:21 am
Sat Jul 28, 2012 3:20 pm
Sat Jul 28, 2012 3:43 pm
OIDLabel = new JLabel("OID:");
OIDField = new JTextField(20);
OIDField.setEditable(true);
hashmapBox = new JComboBox();
hashmapBox.addItem("switch name");
hashmapBox.addItem("another name");
if (command == "hashmapBox")
{
HashMap<String, String> lookup = new HashMap<String, String>();
lookup.put("switch name", " 1.3.6.1.2.1.1.5.0");
lookup.put("another name", " 1.3.6.1.2.1.1.4.0");
System.out.println(lookup.get("another name"));
Set s = lookup.entrySet();
Iterator i = s.iterator();
while (i.hasNext()) {
System.out.println(i.next());
}
}
Sat Jul 28, 2012 4:05 pm
import java.awt.*;
import java.awt.event.*;
public class AL extends Frame implements WindowListener,ActionListener {
TextField text = new TextField(20);
Button b;
private int numClicks = 0;
public static void main(String[] args) {
//AL myWindow = new AL("My first window");
myWindow.setSize(350,100);
myWindow.setVisible(true);
}
public AL(String title) {
super(title);
setLayout(new FlowLayout());
addWindowListener(this);
b = new Button("Click me");
add(b);
add(text);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
numClicks++;
text.setText("Button Clicked " + numClicks + " times");
}
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
public void windowOpened(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
}
Sat Jul 28, 2012 4:36 pm
annette wrote:this is the coding..
- Code:
OIDLabel = new JLabel("OID:");
OIDField = new JTextField(20);
OIDField.setEditable(true);
hashmapBox = new JComboBox();
hashmapBox.addItem("switch name");
hashmapBox.addItem("another name");
if (command == "hashmapBox")
{
HashMap<String, String> lookup = new HashMap<String, String>();
lookup.put("switch name", " 1.3.6.1.2.1.1.5.0");
lookup.put("another name", " 1.3.6.1.2.1.1.4.0");
System.out.println(lookup.get("another name"));
Set s = lookup.entrySet();
Iterator i = s.iterator();
while (i.hasNext()) {
System.out.println(i.next());
}
}
hashmapBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
// change the text field value here.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Sat Jul 28, 2012 4:39 pm
annette wrote:i tried to implement this coding with the coding i gave above to add action listener and all bus i rely dono how to do it.
- Code:
import java.awt.*;
import java.awt.event.*;
public class AL extends Frame implements WindowListener,ActionListener {
TextField text = new TextField(20);
Button b;
private int numClicks = 0;
public static void main(String[] args) {
//AL myWindow = new AL("My first window");
myWindow.setSize(350,100);
myWindow.setVisible(true);
}
public AL(String title) {
super(title);
setLayout(new FlowLayout());
addWindowListener(this);
b = new Button("Click me");
add(b);
add(text);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
numClicks++;
text.setText("Button Clicked " + numClicks + " times");
}
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
public void windowOpened(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
}
hashmapBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
// change the text field value here.
throw new UnsupportedOperationException("Not supported yet.");
}
});
Sat Jul 28, 2012 4:49 pm
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.