Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- public class Elotet implements ItemListener{
- String[] tomb = {"LEHETOSEGEK","","VALAMI1", "VALAMI2", "VALAMI3"};
- JFrame foFrame = new JFrame();
- JPanel foPanel1 = new JPanel();
- JPanel foPanel1_1 = new JPanel();
- JComboBox comboBox = new JComboBox(tomb);
- GridLayout foGrid = new GridLayout(2,1);
- GridLayout foFrameGrid = new GridLayout(2,1);
- FlowLayout foFlow = new FlowLayout();
- public void startol(){
- comboBox.setEditable(true);
- comboBox.addItemListener(this);
- foFrame.setSize(400, 300);
- foFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- foPanel1.setLayout(foGrid);
- foPanel1_1.setLayout(foFlow);
- foPanel1_1.add(comboBox);
- foPanel1.add(foPanel1_1);
- foPanel1.setBackground(Color.GRAY);
- foFrame.setLayout(foFrameGrid);
- foFrame.add(foPanel1);
- foFrame.setVisible(true);
- }
- public static void main(String args[]){
- Elotet meghivas = new Elotet();
- meghivas.startol();
- }
- public void itemStateChanged(ItemEvent e) {
- String item1 = (String) e.getItem();
- if (item1 == "VALAMI1"){
- System.out.println(item1);
- }
- else if (item1 == "VALAMI2"){
- System.out.println(item1);
- }
- else if (item1 == "VALAMI3"){
- System.out.println(item1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement