• Java Swing class iearxiyasi Swing API 18 ta public paketlardan iborat
  • SWING Layots
  • 1.4. Dasturdan natija olish, uni taxlildan o’tkazish va Tizimli dasturiy taminotdan foydalanish texnologiyasi.
  • Секреты программирования для Internet на Java
  • Программирование на Java. Путеводитель
  • JAVA: SWING Java/SWING nima




    Download 114.06 Kb.
    bet4/4
    Sana19.03.2017
    Hajmi114.06 Kb.
    #335
    1   2   3   4
    JAVA: SWING

    Java/SWING nima JAVA uchun GUI Framework

    • JAVA dasturlarini “look and feel” holatiga keltirish

    • Java Foundation Classes (Sun Microsystems) bir qismi

    • IFC (Netscape) va JFC (Sun Microsystems) qo’shilgani

    • Java Standard Edition 1.2 versiyasidan boshlab paket shaklida qo’shilgan

    • GUI controllar java dastur orqali generatsiya qilinadi

    • Ko’rinishi va funksionallkin jihatidan Windows, Mac va Linux OS’laridaka

    Java Swing class iearxiyasi



    Swing API 18 ta public paketlardan iborat

    javax.accessibility

    javax.swing.plaf

    javax.swing.text

    javax.swing

    javax.swing.plaf.basic

    javax.swing.text.html

    javax.swing.border

    javax.swing.plaf.metal

    javax.swing.text.html.parser

    javax.swing.colorchooser

    javax.swing.plaf.multi

    javax.swing.text.rtf

    javax.swing.event

    javax.swing.plaf.synth

    javax.swing.tree

    javax.swing.filechooser

    javax.swing.table

    javax.swing.undo

    SWING Layots

    AWT va Swing klaslarining layout manager’lari:

    BorderLayout

    BoxLayout

    CardLayout

    FlowLayout

    GridBagLayout

    GridLayout

    GroupLayout

    SpringLayout



    Java/SWING BorderLayot

    BorderLayout

    Har bir content pane boshlang’ichda BorderLayout inisalizatsiya qilinadi. BorderLayout componentlarni 5 ta maydonga qo’yadi: top, bottom, left, right, va center.



    1.4. Dasturdan natija olish, uni taxlildan o’tkazish va Tizimli dasturiy taminotdan foydalanish texnologiyasi.
    import javax.swing.*;

    import java.awt.*;

    import java.awt.event.ActionEvent;

    import java.awt.event.ActionListener;

    import java.io.*;
    /**

    * Created with IntelliJ IDEA.

    * User: HUSAN

    * Date: 20.01.14

    * Time: 0:28

    * To change this template use File | Settings | File Templates.

    */

    public class Dic extends JFrame {



    private void init() {

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setSize(600, 500);

    setLayout(new BorderLayout());

    setLocationRelativeTo(null);

    setResizable(false);

    }

    private JPanel topPanel; //shimol



    private JPanel eastPanel; //sharq

    private JPanel westPanel; //g'arb

    private JPanel southPanel; //janub
    private JLabel label = new JLabel("So'zni kiriting");

    private JTextField textField1 = new JTextField(10);

    private JTextArea natija1 = new JTextArea("Lug'at" ,15, 20);

    private JTextArea natija2 = new JTextArea("Lug'at" ,15, 20);


    public Dic(String title) {

    super(title);

    init();

    fillForm();

    setVisible(true);

    }

    private void fillForm() {


    final JButton Ok = new JButton("OK");

    Ok.addActionListener(new ActionListener() {

    @Override

    public void actionPerformed(ActionEvent e) {

    String suz = textField1.getText();

    String bh = suz.substring(0, 1);

    File resurs = new File("Eng\\"+bh+".B&M");

    File res = new File("Uzb\\"+bh+".txt");


    if (!resurs.exists()) {

    natija1.setText("Iltimos, faqat lotincha harflardan foydalaning");

    System.exit(0);

    }

    if (!res.exists()) {



    natija2.setText("Iltimos, faqat lotincha harflardan foydalaning");

    System.exit(0);

    }

    try {


    BufferedReader reader1 = new BufferedReader(new FileReader(resurs));

    int i = 0;

    StringBuffer buffer1 = new StringBuffer();

    StringBuffer buffer2 = new StringBuffer();

    while(reader1.ready()) {

    String line = reader1.readLine();

    if (line.startsWith(suz)) {

    buffer1.append(line).append("\n");

    i++;

    }

    if (i==30) break;



    }

    natija1.setText(buffer1.toString());

    BufferedReader reader2 = new BufferedReader(new FileReader(res));

    int j = 0;

    while(reader2.ready()) {

    String line = reader2.readLine();

    if (line.startsWith(suz)) {

    buffer2.append(line).append("\n");

    j++;

    }

    if (j==30) break;



    }

    natija2.setText(buffer2.toString());

    } catch (FileNotFoundException e2) {

    e2.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.

    } catch (IOException e2) {

    e2.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.

    }

    }

    });



    JLabel label1 = new JLabel("English - Uzbek ");

    JLabel label2 = new JLabel(" Uzbek - English");


    natija1.setLineWrap(true); //faqat pastga tushadi

    JScrollPane scrollPane1 = new JScrollPane(natija1);

    scrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    scrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    add(scrollPane1);
    natija2.setLineWrap(true);

    JScrollPane scrollPane2 = new JScrollPane(natija2);

    scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    add(scrollPane2);
    topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 20));

    topPanel.add(label);

    topPanel.add(textField1);

    topPanel.add(Ok);

    add(topPanel, BorderLayout.NORTH);
    westPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 20));

    westPanel.add(scrollPane1);

    add(westPanel, BorderLayout.WEST);
    eastPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 20));

    eastPanel.add(scrollPane2);

    add(eastPanel, BorderLayout.EAST);
    southPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 20));

    southPanel.add(label1);

    southPanel.add(label2);

    add(southPanel, BorderLayout.SOUTH);

    }

    }

    Dasturning main qismi


    import javax.swing.*;

    import java.awt.event.ActionEvent;

    import java.awt.event.ActionListener;

    /**


    * Created with IntelliJ IDEA.

    * User: HUSAN

    * Date: 20.01.14

    * Time: 0:29

    * To change this template use File | Settings | File Templates.

    */

    public class Main {



    public static void main(String[] args) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException {
    UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");

    Dic dic = new Dic("Lug'at");

    JMenuBar menuBar = new JMenuBar();

    JMenu fayl = new JMenu("Fayl");

    JMenuItem chiqish = new JMenuItem("Chiqish");

    chiqish.addActionListener(new ActionListener() {

    @Override

    public void actionPerformed(ActionEvent e) {

    System.exit(0);

    }

    });



    JCheckBoxMenuItem item = new JCheckBoxMenuItem("Power Save Mode");

    fayl.add(item);

    fayl.addSeparator();

    fayl.add(chiqish);

    JMenu tahrir = new JMenu("Tahrirlash");

    JMenu servis = new JMenu("Servis");

    JMenu oyna = new JMenu("Oynalar");

    JMenu yordam = new JMenu("Yordam");

    menuBar.add(fayl);

    menuBar.add(tahrir);

    menuBar.add(servis);

    menuBar.add(oyna);

    menuBar.add(yordam);

    dic.setJMenuBar(menuBar);

    }

    }



    XULOSA

    Kurs ishini bajarish davomida quyidagi xulosalarga ega bo'ldim: bularga qism dasturlarni yaratish, ob'ekt xususiyatlari bilan ishlash, sinflarni shakllantirish kabi tushunchalarni o'zlashtirish .

    Ushbu kurs ishida yuqorida ta'kidlab o'tilgan ma'lumotlarni o'zlashtirish bilan bir qatorda JAWA va shu kabi dasturlash tillarida sinflar va ob'ektlar, sinflar orasidagi munosabatlar, ob'eklarga qiymatlarni o'zlashtirish va ulardan foydalanish kabi tushunchalar o'zlashtirildi.

    Lug’at yaratishda Jawa muhitidan unumli foydalanildi. Natijalar esa Console rejimida chiqarildi.



    Foydalanilgan adabiyotlar:

    1. Майкл Томас, Пратик Пател, Алан Хадсон, Доналд Болл(мл.) Секреты программирования для Internet на Java.- Ventana Press, Ventana Communications Group, U.S.A.,1996, Издательство "Питер Пресс", 1997

    2. Аарон И.Волш Основы программирования на Java для World Wide Web.- IDG Books Worldwide,Inc.,1996, Издательство "Диалектика",1996

    3. Кен Арнольд, Джеймс Гослинг Язык программирования Java.- Addison-Wesley Longman,U.S.A.,1996, Издательство "Питер-Пресс", 1997

    4. Нейл Бартлетт, Алекс Лесли, Стив Симкин Программирование на Java. Путеводитель.- The Coriolis Group,Inc.,1996, Издательство НИПФ "ДиаСофт Лтд.",1996

    5. Крис Джамса Библиотека программиста Java.- Jamsa Press, 1996, ООО "Попурри", 1996


    Download 114.06 Kb.
    1   2   3   4




    Download 114.06 Kb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    JAVA: SWING Java/SWING nima

    Download 114.06 Kb.