package paket;
//Main Panel,klasa koja je ujedno u pocetak mog progama
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.UIManager;
import action.ActionMenager;
public class MainPanel extends JFrame {
/**
*
*/
private static final long serialVersionUID = -6828463873271440640L;
private JPanel glavniPanel = null;
private JMenuBar myMenuBar = null;
private JMenu kasaMenu = null;
private JMenu radniciMenu = null;
private JMenu infoMenu = null;
private JMenu artikliMenu = null;
private JLabel Slika = null;
private JLabel imeAutora = null;
private ImageIcon imageIcon = new ImageIcon("Slike/KasaSlika.jpg");
private UnosRadnikaPanel unosRadnika;
private UnosArtikalaPanel unosArtikala;
private UputstvoPanel uputstvoPanel;
private Login login;
private AutorPanel autor;
public static NoviRacunPanel noviRacun;
private ActionMenager actionMenager;
public static UcitajIzFajla ui;
private Toolkit kit;
public static TabelaRadnici tb;
public static TabelaArtikli tbA;
// konstruktor Main Panel
public MainPanel(String title) {
super(title);
unosRadnika = new UnosRadnikaPanel("Unos novog Radnika");
unosArtikala = new UnosArtikalaPanel("Unos novog artikla");
noviRacun = new NoviRacunPanel("Novi racun");
login = new Login("Sifra Radnika");
autor = new AutorPanel("Autor");
uputstvoPanel = new UputstvoPanel(this);
actionMenager = new ActionMenager(this);
ui = new UcitajIzFajla();
init();
}
// Podesavanje prozora
public void init() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(800, 600);
kit = Toolkit.getDefaultToolkit();
Dimension dim = kit.getScreenSize();
setLocation((dim.width - getWidth()) / 2,
(dim.height - getHeight()) / 2);
setJMenuBar(getMyMenuBar());
setContentPane(getGlavniPanel());
setResizable(false);
}
// podesavanje panela i ubacivanje slike
public JPanel getGlavniPanel() {
if (glavniPanel == null) {
glavniPanel = new JPanel();
glavniPanel.setLayout(new BorderLayout());
glavniPanel.setBackground(Color.white);
glavniPanel.add(getSlika(), BorderLayout.CENTER);
glavniPanel.add(getImeAutora(), BorderLayout.SOUTH);
}
return glavniPanel;
}
// Meni Bar, pozivanje funkcija
public JMenuBar getMyMenuBar() {
if (myMenuBar == null) {
myMenuBar = new JMenuBar();
myMenuBar.add(getKasaMenu());
myMenuBar.add(getArtikliMenu());
myMenuBar.add(getRadniciMenu());
myMenuBar.add(getInfoMenu());
}
return myMenuBar;
}
// Podesavanje Kasa Meni
public JMenu getKasaMenu() {
if (kasaMenu == null) {
kasaMenu = new JMenu("Kasa");
kasaMenu.add(actionMenager.getNoviRacun());
}
return kasaMenu;
}
public JMenu getRadniciMenu() {
if (radniciMenu == null) {
radniciMenu = new JMenu("Radnici");
radniciMenu.add(actionMenager.getUnosRadnika());
radniciMenu.addSeparator();
radniciMenu.add(actionMenager.getPregledRadnika());
}
return radniciMenu;
}
public JMenu getInfoMenu() {
if (infoMenu == null) {
infoMenu = new JMenu("Info");
infoMenu.add(actionMenager.getUputstvo());
infoMenu.addSeparator();
infoMenu.add(actionMenager.getAutor());
infoMenu.addSeparator();
infoMenu.add(actionMenager.getExit());
}
return infoMenu;
}
public JMenu getArtikliMenu() {
if (artikliMenu == null) {
artikliMenu = new JMenu("Artikli");
artikliMenu.add(actionMenager.getUnosArtikala());
artikliMenu.addSeparator();
artikliMenu.add(actionMenager.getPregledArtikla());
}
return artikliMenu;
}
public UcitajIzFajla getUi() {
return ui;
}
public UnosRadnikaPanel getUnosRadnika() {
return unosRadnika;
}
public void setUnosRadnika(UnosRadnikaPanel unosRadnika) {
this.unosRadnika = unosRadnika;
}
public UnosArtikalaPanel getUnosArtikala() {
return unosArtikala;
}
public void setUnosArtikala(UnosArtikalaPanel unosArtikala) {
this.unosArtikala = unosArtikala;
}
public NoviRacunPanel getNoviRacun() {
return noviRacun;
}
public AutorPanel getAutor() {
return autor;
}
public void setAutor(AutorPanel autor) {
this.autor = autor;
}
public Login getLogin() {
return login;
}
public void setLogin(Login login) {
this.login = login;
}
public JLabel getSlika() {
if (Slika == null) {
Slika = new JLabel(imageIcon);
}
return Slika;
}
public void setSlika(JLabel slika) {
Slika = slika;
}
public UputstvoPanel getUputstvoPanel() {
return uputstvoPanel;
}
public void setUputstvoPanel(UputstvoPanel uputstvoPanel) {
this.uputstvoPanel = uputstvoPanel;
}
public JLabel getImeAutora() {
if(imeAutora == null){
imeAutora = new JLabel("by Ivan Nikolic");
imeAutora.setForeground(Color.decode("#3BA3D0"));
}
return imeAutora;
}
}