Advertisement
Guest User

forras

a guest
Jul 30th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4.  
  5.  
  6. public class Elotet implements ItemListener{
  7.  
  8.  
  9. String[] tomb = {"LEHETOSEGEK","","VALAMI1", "VALAMI2", "VALAMI3"};
  10. JFrame foFrame = new JFrame();
  11. JPanel foPanel1 = new JPanel();
  12. JPanel foPanel1_1 = new JPanel();
  13. JComboBox comboBox = new JComboBox(tomb);
  14.  
  15. GridLayout foGrid = new GridLayout(2,1);
  16. GridLayout foFrameGrid = new GridLayout(2,1);
  17. FlowLayout foFlow = new FlowLayout();
  18.  
  19. public void startol(){
  20.  
  21. comboBox.setEditable(true);
  22. comboBox.addItemListener(this);
  23.  
  24. foFrame.setSize(400, 300);
  25. foFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  26.  
  27. foPanel1.setLayout(foGrid);
  28. foPanel1_1.setLayout(foFlow);
  29. foPanel1_1.add(comboBox);
  30. foPanel1.add(foPanel1_1);
  31.  
  32. foPanel1.setBackground(Color.GRAY);
  33. foFrame.setLayout(foFrameGrid);
  34. foFrame.add(foPanel1);
  35. foFrame.setVisible(true);
  36. }
  37.  
  38.  
  39. public static void main(String args[]){
  40.  
  41. Elotet meghivas = new Elotet();
  42. meghivas.startol();
  43.  
  44.  
  45. }
  46.  
  47.  
  48. public void itemStateChanged(ItemEvent e) {
  49.  
  50. String item1 = (String) e.getItem();
  51.  
  52. if (item1 == "VALAMI1"){
  53. System.out.println(item1);
  54. }
  55. else if (item1 == "VALAMI2"){
  56. System.out.println(item1);
  57. }
  58. else if (item1 == "VALAMI3"){
  59. System.out.println(item1);
  60.  
  61. }
  62. }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement