Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package grafika;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.WindowAdapter;
- import java.awt.event.WindowEvent;
- /**
- * Created by korisnik on 4.12.2018..
- */
- public class Prozor extends Frame{
- MojDijalog md=new MojDijalog(this);
- public Prozor(String naslov){
- super(naslov);
- setSize(400,400);
- setLayout(new BorderLayout());
- Label l1=new Label("L1");
- Label l2=new Label("L2");
- Label l3=new Label("L3");
- Label l4=new Label("L4");
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- md.prikazi();
- }
- });
- add("North", l1);
- add("East", l2);
- add("Center", l3);
- add("South", l4);
- Panel p=new Panel();
- p.setLayout(new GridLayout(2,2));
- p.add(new Button ("B1"));
- p.add(new Button ("B2"));
- p.add(new Button ("B3"));
- p.add(new Button ("B4"));
- add("Center", p);
- dodajMenu();
- setVisible(true);
- }
- private void dodajMenu(){
- MenuBar mb=new MenuBar();
- Menu m1=new Menu("File");
- m1.add("New");
- m1.add("Save");
- m1.add("Save as");
- m1.addSeparator();
- m1.add("Exit");
- m1.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- System.out.println(e.getActionCommand());
- }
- });
- mb.add(m1);
- Menu m2=new Menu("Edit");
- m2.add("Undo");
- Menu m3=new Menu("vise");
- m3.add("Podopcija 1");
- m2.add(m3);
- mb.add(m2);
- setMenuBar(mb);
- }
- }
- ---------------------------------------
- package grafika;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- /**
- * Created by korisnik on 4.12.2018..
- */
- public class MojDijalog extends Dialog{
- public MojDijalog(Frame roditelj) {
- super(roditelj, "Da li ste sigurni?", true);
- setSize(200,200);
- setLayout(new FlowLayout());
- Button b1=new Button("Da");
- b1.setActionCommand("11");
- b1.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- System.out.println(e.getActionCommand());
- System.exit(1);
- }
- });
- add(b1);
- }
- public void prikazi(){
- setVisible(true);
- }
- }
- --------------------------------------------
- package glavni;
- import Samostalni.ProzorKalkulatora;
- import grafika.Prozor;
- /**
- * Created by korisnik on 4.12.2018..
- */
- public class Program {
- public static void main(String[] args) {
- // Prozor p=new Prozor("Vezba 7");
- ProzorKalkulatora p= new ProzorKalkulatora("Kalkulator");
- }
- }
- ------------------------------------------------
- package Samostalni;
- import sun.swing.MenuItemLayoutHelper;
- import javax.swing.plaf.basic.BasicOptionPaneUI;
- import java.awt.*;
- /**
- * Created by korisnik on 4.12.2018..
- */
- public class ProzorKalkulatora extends Frame{
- private String prvi="l1";
- private String drugi="l2";
- private String treci="l3";
- public ProzorKalkulatora (String naslov){
- super(naslov);
- setSize(600,600);
- setLayout(new BorderLayout());
- Label l1=new Label(prvi);
- Label l2=new Label(drugi);
- Label l3=new Label(treci);
- add("North", l1);
- add("North", l2);
- add("North", l3);
- Panel p=new Panel();
- p.setLayout(new GridLayout(3,3));
- p.add(new Button ("1"));
- p.add(new Button ("2"));
- p.add(new Button ("3"));
- p.add(new Button ("4"));
- p.add(new Button ("5"));
- p.add(new Button ("6"));
- p.add(new Button ("7"));
- p.add(new Button ("8"));
- p.add(new Button ("9"));
- p.add(new Button ("."));
- p.add(new Button ("0"));
- Panel d=new Panel();
- d.setLayout(new GridLayout(1,3));
- add("West", d);
- d.add( new Button ("="));
- add("Center", p);
- setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement