Advertisement
Guest User

Untitled

a guest
Jan 17th, 2015
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.41 KB | None | 0 0
  1. package txteditor;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.FlowLayout;
  5. import java.awt.Font;
  6. import java.awt.GridLayout;
  7.  
  8. import javax.swing.JButton;
  9. import javax.swing.JComboBox;
  10. import javax.swing.JEditorPane;
  11. import javax.swing.JFrame;
  12. import javax.swing.JLabel;
  13. import javax.swing.JMenu;
  14. import javax.swing.JMenuBar;
  15. import javax.swing.JMenuItem;
  16. import javax.swing.JPanel;
  17. import javax.swing.JScrollPane;
  18. import javax.swing.ScrollPaneConstants;
  19.  
  20.  
  21. public class Layout{
  22.        
  23.        
  24.         //OKNO
  25.         private JFrame okno = new JFrame("Edytor Tekstu");
  26.         //PANELE
  27.         private JPanel uppanel = new JPanel();
  28.         private JPanel menupanel = new JPanel();
  29.         private JPanel btnpanel = new JPanel();
  30.         private JPanel txtpanel = new JPanel();
  31.         private JPanel wordpanel = new JPanel();
  32.         //PRZYCISKI
  33.         JButton bold = new JButton("B");
  34.         private JButton italy = new JButton("I");
  35.         private JButton underline = new JButton("U");
  36.         private JButton image = new JButton("Wstaw Obraz");
  37.         //MENU
  38.         private JMenuBar menu = new JMenuBar();
  39.         private JMenu plik = new JMenu("Plik");
  40.         private JMenu edycja = new JMenu("Edycja");
  41.         private JMenu pomoc = new JMenu("Pomoc");
  42.        
  43.         //MENU PLIK
  44.         JMenuItem nowy = new JMenuItem("Nowy");
  45.         JMenuItem otworz = new JMenuItem("Otworz");
  46.         JMenuItem zapisz = new JMenuItem("Zapisz");
  47.         JMenuItem zapiszjako = new JMenuItem("Zapisz jako");
  48.         JMenuItem ustawieniawydruku = new JMenuItem("Ustawienia Wydruku");
  49.         JMenuItem drukuj = new JMenuItem("Drukuj");
  50.         //MENU EDYCJA
  51.         JMenuItem cofnij = new JMenuItem("Cofnij");    
  52.         JMenuItem przywroc = new JMenuItem("Przywroc");
  53.         JMenuItem kopiuj = new JMenuItem("Kopiuj");    
  54.         JMenuItem wklej = new JMenuItem("Wklej");      
  55.         JMenuItem wytnij = new JMenuItem("Wytnij");
  56.         JMenuItem zaznaczwszystko = new JMenuItem("Zaznacz wszystko");
  57.         JMenuItem znajdz = new JMenuItem("Znajd\u017A");
  58.         JMenuItem zamien = new JMenuItem("Zamie\u0144");
  59.         //MENU POMOC
  60.         JMenuItem oprogramie = new JMenuItem("O programie");
  61.         //COMBO BOX
  62.         JComboBox czcionka= new JComboBox();
  63.         JComboBox rozmiar = new JComboBox();          
  64.         JComboBox kolor = new JComboBox();
  65.        
  66.        
  67.         //PRZEWIJANIE TEKSTU
  68.         JScrollPane scroll = new JScrollPane();
  69.         //POLE TEKSTOWE
  70.         JEditorPane textbar = new JEditorPane();
  71.         //ILOŚĆ SŁÓW
  72.         JLabel word= new JLabel("Ilość Słów");
  73.  
  74.        
  75.        
  76.         public Layout(){
  77.                
  78.                
  79.         //OKNO
  80.         okno.setBounds(100, 100, 1000, 600);
  81.         okno.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  82.         okno.getContentPane().setLayout(new BorderLayout(0, 0));
  83.         okno.setVisible(true);
  84.         okno.getContentPane().add(uppanel, BorderLayout.NORTH);
  85.         okno.getContentPane().add(txtpanel, BorderLayout.CENTER);
  86.         okno.getContentPane().add(wordpanel, BorderLayout.SOUTH);
  87.        
  88.         //UPPANEL
  89.         uppanel.setLayout(new GridLayout(0, 1, 0, 0));
  90.         uppanel.add(menupanel);
  91.         uppanel.add(btnpanel);
  92.         //MENUPANEL
  93.         menupanel.setLayout(new GridLayout(0, 1, 0, 0));
  94.         menupanel.add(menu);
  95.         //MENU
  96.         menu.add(plik);
  97.         menu.add(edycja);
  98.         menu.add(pomoc);
  99.         //MENU PLIK
  100.         plik.add(nowy);
  101.         plik.add(otworz);
  102.         plik.add(zapisz);
  103.         plik.add(zapiszjako);
  104.         plik.add(ustawieniawydruku);
  105.         plik.add(drukuj);
  106.         //MENU EDYCJA
  107.         edycja.add(cofnij);
  108.         edycja.add(przywroc);
  109.         edycja.add(kopiuj);
  110.         edycja.add(wklej);
  111.         edycja.add(wytnij);
  112.         edycja.add(zaznaczwszystko);
  113.         edycja.add(znajdz);
  114.         edycja.add(zamien);
  115.         //MENU POMOC
  116.         pomoc.add(oprogramie);
  117.         //BTN PANEL
  118.         btnpanel.setLayout(new FlowLayout(FlowLayout.LEADING));
  119.         btnpanel.add(bold);
  120.  
  121.        
  122.        
  123.        
  124.        
  125.        
  126.        
  127.        
  128.        
  129.        
  130.        
  131.        
  132.        
  133.         bold.setFont(new Font("Tahoma", Font.BOLD, 12));
  134.         btnpanel.add(italy);
  135.         italy.setFont(new Font("Tahoma", Font.ITALIC, 12));
  136.         btnpanel.add(underline);
  137.         underline.setFont(new Font("Tahoma", Font.PLAIN, 12));
  138.         rozmiar=new JComboBox(new String[]{"10","12","14"});
  139.         btnpanel.add(rozmiar);
  140.         czcionka=new JComboBox(new String[]{"Arial","Tahoma","Verdana"});
  141.         btnpanel.add(czcionka);
  142.         kolor=new JComboBox(new String[]{"Czarny","Czerwony","Zielony"});
  143.         btnpanel.add(kolor);
  144.         btnpanel.add(image);
  145.         //TXT PANEL
  146.         txtpanel.setLayout(new GridLayout(0, 1, 0, 0));
  147.         txtpanel.add(scroll);
  148.         scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  149.         scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  150.         scroll.setViewportView(textbar);
  151.         //WORD PANEL
  152.         wordpanel.setLayout(new GridLayout(0, 1, 0, 0));
  153.         wordpanel.add(word);
  154.        
  155.        
  156.        
  157.        
  158.        
  159.        
  160.        
  161.                
  162.                
  163.                
  164.                
  165.                
  166.         }
  167.        
  168.        
  169.        
  170.        
  171.        
  172.        
  173.        
  174.        
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement