Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. import java.awt.*;
  2. import javax.swing.*;
  3. import java.util.*;
  4. import java.util.List;
  5.  
  6. public class Glavna {
  7. public static void main(String[] args) {
  8. //dragi kumarice mijenjaj ove putanje za slike jer ovo je meni u linux (za widows ti je C://.../
  9. JFrame okvir = new JFrame("mojred");
  10. ImageIcon img = new ImageIcon("/home/ja/Downloads/okvir.png");
  11. okvir.setIconImage(img.getImage());
  12. JPanel panela = new JPanel(null);
  13. panela.setBackground(Color.white);
  14.  
  15. JLabel labela = new JLabel("BROJ :");
  16. labela.setForeground(Color.yellow);
  17. labela.setBounds(150, 132, 120, 30);
  18. labela.setFont(new Font("Laksaman", Font.PLAIN, 30));//ne znam imaju li ovi fontovi u windows ako nema nadji slicni za windows
  19. panela.add(labela);
  20.  
  21. int redniBroj = 5;// Tvoj Redni broj
  22.  
  23. JLabel redniBr = new JLabel(redniBroj + "");
  24. redniBr.setForeground(Color.white);
  25. redniBr.setFont(new Font("Verdana", Font.BOLD, 30));
  26. redniBr.setBounds(253, 122, 50, 50);
  27. panela.add(redniBr);
  28.  
  29. labela = new JLabel();
  30. labela.setIcon(new ImageIcon("/home/ja/Downloads/tata.jpg"));
  31. labela.setBounds(30, 40, 410, 200);
  32. panela.add(labela);
  33.  
  34. JLabel brojLjudi = new JLabel("Broj ljudi u redu: ");// Broj ljudi iza tebe
  35. brojLjudi.setForeground(Color.darkGray);
  36. brojLjudi.setFont(new Font("Verdana", Font.BOLD, 15));
  37. brojLjudi.setBounds(110, 250, 400, 40);
  38.  
  39. labela = new JLabel("Naredni brojevi:");
  40. labela.setForeground(Color.black);
  41. labela.setFont(new Font("Laksaman", Font.HANGING_BASELINE, 27));
  42. labela.setBounds(500, 30, 300, 40);
  43. panela.add(labela);
  44.  
  45. JButton dugme = new JButton();
  46. dugme.setIcon(new ImageIcon("/home/ja/Downloads/aaa.png"));
  47. dugme.setOpaque(false);
  48. dugme.setContentAreaFilled(false);
  49. dugme.setBorderPainted(false);
  50. dugme.setBounds(250, 218, 100, 100);
  51. panela.add(dugme);
  52.  
  53. labela = new JLabel();
  54. labela.setIcon(new ImageIcon("/home/ja/Downloads/wq.png"));
  55. labela.setBounds(340, 210, 300, 300);
  56. panela.add(labela);
  57.  
  58. List<Integer> brojevi = new ArrayList<>();// lista narednih brojeva
  59.  
  60. //ovdje napravi da ti puni listu eleemntima iz baze
  61. brojevi.add(6);
  62. brojevi.add(7);
  63. brojevi.add(8);
  64. brojevi.add(9);
  65. brojevi.add(10);
  66. brojevi.add(11);
  67. brojevi.add(12);
  68. brojevi.add(13);
  69.  
  70. brojLjudi.setText(brojLjudi.getText() + " " + brojevi.size());
  71.  
  72. JList<Integer> lista = new JList<>();
  73. lista.setFont(new Font("Verdana", Font.BOLD, 27));
  74. lista.setForeground(Color.darkGray);
  75. DefaultListCellRenderer renderer = (DefaultListCellRenderer) lista.getCellRenderer();
  76. renderer.setHorizontalAlignment(JLabel.CENTER);
  77. DefaultListModel<Integer> model = new DefaultListModel<>();
  78.  
  79. for (int i : brojevi)
  80. model.addElement(i);
  81.  
  82. lista.setModel(model);
  83. JScrollPane sc = new JScrollPane();
  84. sc.setViewportView(lista);
  85. sc.setBounds(458, 70, 278, 333);
  86. sc.setBorder(BorderFactory.createLineBorder(Color.decode("#ff0000"), 2));
  87. lista.setSelectionModel(new NoSelectionModel());
  88. panela.add(sc);
  89. panela.add(brojLjudi);
  90. okvir.setContentPane(panela);
  91. okvir.setBounds(305, 150, 770, 460);
  92. okvir.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  93. okvir.setResizable(false);
  94. okvir.setVisible(true);
  95.  
  96. dugme.addActionListener(x -> {
  97. if (brojevi.size() > 0) {
  98. redniBr.setText(brojevi.get(0) + "");
  99. brojevi.remove(0);
  100. model.remove(0);
  101. brojLjudi.setText("Broj ljudi u redu: " + brojevi.size());
  102. } else
  103. redniBr.setText("");
  104. });
  105. }
  106. }
  107.  
  108. class NoSelectionModel extends DefaultListSelectionModel {
  109.  
  110. private static final long serialVersionUID = 1L;
  111.  
  112. @Override
  113. public void setAnchorSelectionIndex(final int anchorIndex) {
  114. }
  115.  
  116. @Override
  117. public void setLeadAnchorNotificationEnabled(final boolean flag) {
  118. }
  119.  
  120. @Override
  121. public void setLeadSelectionIndex(final int leadIndex) {
  122. }
  123.  
  124. @Override
  125. public void setSelectionInterval(final int index0, final int index1) {
  126. }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement