Child pages
  • Hol kell elhelyeznem az eseménykezelőt ?
Skip to end of metadata
Go to start of metadata

 

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

 

 

/* FrameDemo.java requires no other files. */

public class FrameDemo {

   

    private static void createAndShowGUI() {

       

        JFrame frame = new JFrame("FrameDemo");

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

 

     

 

    JPanel panelAlso = new JPanel(new FlowLayout());

    DatumPanel dp = new DatumPanel("HUN");

    MatchPanel mp = new MatchPanel();

 

    Container cp = frame.getContentPane();

 

    cp.add(dp.getPanel(), BorderLayout.PAGE_START);

    cp.add(mp.getPanel(), BorderLayout.CENTER);

    cp.add(panelAlso, BorderLayout.PAGE_END);

 

        

    //honapComboBox.setSelectedIndex(12);

    //honapComboBox.addActionListener();

    

    

    JLabel alsoLabel = new JLabel("Alsó Panel");

    panelAlso.add(alsoLabel);

 

    dp.getPanel().setPreferredSize(new Dimension(575, 100));

    panelAlso.setPreferredSize(new Dimension(575, 100));

        //Display the window.

        frame.pack();

        frame.setVisible(true);

    }

 

    public static void main(String[] args) {

        //Schedule a job for the event-dispatching thread:

        //creating and showing this application's GUI.

        javax.swing.SwingUtilities.invokeLater(new Runnable() {

            public void run() {

                createAndShowGUI();

            }

        }); //main

    }

} //class end

 

class DatumPanel {

    JPanel panelFelso;

    JLabel napLabel, honapLabel, evLabel;

    JTextField napTextField, evTextField;

    JComboBox honapComboBox;

    String[] honapokENG = { "January", "February", "March", "April", "May", "June", "July", "August", "September",             "October", "November", "December" };

    String[] honapokHUN = { "Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus",             "Szeptember", "Október", "November", "December" };

 

    public DatumPanel(){

        napLabel = new JLabel("Days");

        napTextField = new JTextField("Days", 8);

        honapLabel = new JLabel("Months");

        honapComboBox = new JComboBox(honapokENG);

        evLabel = new JLabel("Years");

        evTextField = new JTextField("Év", 4);

        init();

    }

    public DatumPanel(String lang){

        if (lang == "HUN"){

        napLabel = new JLabel("Nap");

        napTextField = new JTextField("Napok", 8);

        honapLabel = new JLabel("Hónap");

        honapComboBox = new JComboBox(honapokHUN);

        evLabel = new JLabel("Év");

        evTextField = new JTextField("Év", 4);

        init();

        }

    }

    void init(){

        panelFelso = new JPanel(new FlowLayout(FlowLayout.LEFT));

        panelFelso.add(napLabel);

    panelFelso.add(napTextField);

    panelFelso.add(honapLabel);

    panelFelso.add(honapComboBox);

    panelFelso.add(evLabel);

    panelFelso.add(evTextField);

    }

    public JPanel getPanel(){

    return panelFelso;

    }

    

    //honapComboBox.setSelectedIndex(12);

    //honapComboBox.addActionListener();

    

    

    

} //class end

 

class MatchPanel {

    JPanel matchPanel;

    JLabel matchIDLabel, arenaNameLabel, attendanceLabel, weatherLabel, weatherPicLabel;

    JTextField matchJTF, attendanceJTF;

    JComboBox arenaNameJCB, weatherJCB;

    String [] arenaName = {"stadion1", "stadion2stadion2stadion2stadion2", "stadion3", "stadion4stadion4stadion4",             "stadion5", "stadion6"};

    String [] weatherName = {"Esős", "Borús", "Részben felhős", "Napos"};

    public MatchPanel(){

        matchIDLabel = new JLabel("MatchID");

        matchJTF = new JTextField("index", 12);

        arenaNameLabel = new JLabel("Arena");

        arenaNameJCB = new JComboBox(arenaName);

        attendanceLabel = new JLabel("Nézőszám");

        attendanceJTF = new JTextField("nézők", 6);

        weatherLabel = new JLabel("Időjárás");

        weatherJCB = new JComboBox(weatherName);

 

        init();

    }

    void init(){

        matchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));

        matchPanel.add(matchIDLabel);

        matchPanel.add(matchJTF);

        matchPanel.add(arenaNameLabel);

        matchPanel.add(arenaNameJCB);

        matchPanel.add(attendanceLabel);

        matchPanel.add(attendanceJTF);

        matchPanel.add(weatherLabel);

        matchPanel.add(weatherJCB);

    }

    public JPanel getPanel(){

    return matchPanel;

    }

 

} //class end

      
      
Page viewed times
#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
  • No labels