Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import javax.swing.*;
- import java.util.*;
- import java.util.List;
- public class Glavna {
- public static void main(String[] args) {
- //dragi kumarice mijenjaj ove putanje za slike jer ovo je meni u linux (za widows ti je C://.../
- JFrame okvir = new JFrame("mojred");
- ImageIcon img = new ImageIcon("/home/ja/Downloads/okvir.png");
- okvir.setIconImage(img.getImage());
- JPanel panela = new JPanel(null);
- panela.setBackground(Color.white);
- JLabel labela = new JLabel("BROJ :");
- labela.setForeground(Color.yellow);
- labela.setBounds(150, 132, 120, 30);
- labela.setFont(new Font("Laksaman", Font.PLAIN, 30));//ne znam imaju li ovi fontovi u windows ako nema nadji slicni za windows
- panela.add(labela);
- int redniBroj = 5;// Tvoj Redni broj
- JLabel redniBr = new JLabel(redniBroj + "");
- redniBr.setForeground(Color.white);
- redniBr.setFont(new Font("Verdana", Font.BOLD, 30));
- redniBr.setBounds(253, 122, 50, 50);
- panela.add(redniBr);
- labela = new JLabel();
- labela.setIcon(new ImageIcon("/home/ja/Downloads/tata.jpg"));
- labela.setBounds(30, 40, 410, 200);
- panela.add(labela);
- JLabel brojLjudi = new JLabel("Broj ljudi u redu: ");// Broj ljudi iza tebe
- brojLjudi.setForeground(Color.darkGray);
- brojLjudi.setFont(new Font("Verdana", Font.BOLD, 15));
- brojLjudi.setBounds(110, 250, 400, 40);
- labela = new JLabel("Naredni brojevi:");
- labela.setForeground(Color.black);
- labela.setFont(new Font("Laksaman", Font.HANGING_BASELINE, 27));
- labela.setBounds(500, 30, 300, 40);
- panela.add(labela);
- JButton dugme = new JButton();
- dugme.setIcon(new ImageIcon("/home/ja/Downloads/aaa.png"));
- dugme.setOpaque(false);
- dugme.setContentAreaFilled(false);
- dugme.setBorderPainted(false);
- dugme.setBounds(250, 218, 100, 100);
- panela.add(dugme);
- labela = new JLabel();
- labela.setIcon(new ImageIcon("/home/ja/Downloads/wq.png"));
- labela.setBounds(340, 210, 300, 300);
- panela.add(labela);
- List<Integer> brojevi = new ArrayList<>();// lista narednih brojeva
- //ovdje napravi da ti puni listu eleemntima iz baze
- brojevi.add(6);
- brojevi.add(7);
- brojevi.add(8);
- brojevi.add(9);
- brojevi.add(10);
- brojevi.add(11);
- brojevi.add(12);
- brojevi.add(13);
- brojLjudi.setText(brojLjudi.getText() + " " + brojevi.size());
- JList<Integer> lista = new JList<>();
- lista.setFont(new Font("Verdana", Font.BOLD, 27));
- lista.setForeground(Color.darkGray);
- DefaultListCellRenderer renderer = (DefaultListCellRenderer) lista.getCellRenderer();
- renderer.setHorizontalAlignment(JLabel.CENTER);
- DefaultListModel<Integer> model = new DefaultListModel<>();
- for (int i : brojevi)
- model.addElement(i);
- lista.setModel(model);
- JScrollPane sc = new JScrollPane();
- sc.setViewportView(lista);
- sc.setBounds(458, 70, 278, 333);
- sc.setBorder(BorderFactory.createLineBorder(Color.decode("#ff0000"), 2));
- lista.setSelectionModel(new NoSelectionModel());
- panela.add(sc);
- panela.add(brojLjudi);
- okvir.setContentPane(panela);
- okvir.setBounds(305, 150, 770, 460);
- okvir.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- okvir.setResizable(false);
- okvir.setVisible(true);
- dugme.addActionListener(x -> {
- if (brojevi.size() > 0) {
- redniBr.setText(brojevi.get(0) + "");
- brojevi.remove(0);
- model.remove(0);
- brojLjudi.setText("Broj ljudi u redu: " + brojevi.size());
- } else
- redniBr.setText("");
- });
- }
- }
- class NoSelectionModel extends DefaultListSelectionModel {
- private static final long serialVersionUID = 1L;
- @Override
- public void setAnchorSelectionIndex(final int anchorIndex) {
- }
- @Override
- public void setLeadAnchorNotificationEnabled(final boolean flag) {
- }
- @Override
- public void setLeadSelectionIndex(final int leadIndex) {
- }
- @Override
- public void setSelectionInterval(final int index0, final int index1) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement