private void construct() { // @preformat // Root Panel JPanel root = new JPanel(); root.setLayout(new BoxLayout(root, BoxLayout.PAGE_AXIS)); // Fighters panel JPanel f = new JPanel(); f.setLayout(new FlowLayout()); // User Panel JPanel userpane = new JPanel(); userpane.setLayout(new FlowLayout()); // Party Info uparty = new JPanel(); uparty.setPreferredSize(new Dimension(40, 50)); for (int i = 0; i < 6; i++) { if (battle.user.party.pkmn[i] != null && battle.user.party.pkmn[i].awake) uparty.add(new JLabel(new ImageIcon(Tools.findImage("active")))); else { uparty.add(new JLabel(new ImageIcon(Tools.findImage("inactive")))); } } userpane.add(uparty); // Picture userpic = new JLabel(new ImageIcon(Tools.findImage(battle.user.leader))); userpane.add(userpic); // Info JPanel userinfo = new JPanel(); userinfo.setLayout(new BoxLayout(userinfo, BoxLayout.PAGE_AXIS)); // Name username = new JLabel(battle.user.party.leader().name + " Lvl." + battle.user.leader.level); userinfo.add(username); // HP Bar userhp = new JProgressBar(0, battle.user.leader.health.max); userhp.setValue(battle.user.leader.health.cur); userhp.setForeground(Color.PINK); userhp.setBackground(Color.GRAY); userhp.setStringPainted(true); userhp.setBorderPainted(false); userinfo.add(userhp); // XP Bar userxp = new JProgressBar(0, battle.user.leader.xpNeeded()); userxp.setValue(battle.user.leader.xp); userxp.setForeground(Color.CYAN); userxp.setBackground(Color.GRAY); userxp.setStringPainted(true); userxp.setBorderPainted(false); userinfo.add(userxp); // Status userstatus = new JLabel(battle.user.leader.status.toString()); userinfo.add(userstatus); userpane.add(userinfo); f.add(userpane); // Enemy Panel JPanel enemypane = new JPanel(); enemypane.setLayout(new FlowLayout()); // Info JPanel enemyinfo = new JPanel(); enemyinfo.setLayout(new BoxLayout(enemyinfo, BoxLayout.PAGE_AXIS)); // Name enemyname = new JLabel(battle.enemy.leader.name + " Lvl." + battle.enemy.leader.level); enemyinfo.add(enemyname); // HP Bar enemyhp = new JProgressBar(0, battle.enemy.leader.health.max); enemyhp.setValue(battle.enemy.leader.health.cur); enemyhp.setForeground(Color.PINK); enemyhp.setBackground(Color.GRAY); enemyhp.setStringPainted(true); enemyhp.setBorderPainted(false); enemyinfo.add(enemyhp); // Status enemystatus = new JLabel(battle.enemy.leader.status.toString()); enemyinfo.add(enemystatus); enemypane.add(enemyinfo); // Picture enemypic = new JLabel(new ImageIcon(Tools.findImage(battle.enemy.leader))); enemypane.add(enemypic); // Party Info oparty = new JPanel(); oparty.setPreferredSize(new Dimension(40, 50)); for (int i = 0; i < 6; i++) { if (battle.enemy.party.pkmn[i] != null && battle.enemy.party.pkmn[i].awake) oparty.add(new JLabel(new ImageIcon(Tools.findImage("active")))); else { oparty.add(new JLabel(new ImageIcon(Tools.findImage("inactive")))); } } enemypane.add(oparty); f.add(enemypane); root.add(f); // Buttons panel JPanel b = new JPanel(); b.add(new FightButton()); b.add(new ItemButton()); b.add(new SwapButton()); b.add(new RunButton()); root.add(b); add(root); // @format }
private void initializeComponents() { this.setTitle("Synchro - Kopierassistent"); this.setBounds(0, 0, 550, 600); this.setResizable(true); this.setLayout(null); this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.addWindowListener(this); mainPanel = new JPanel(); mainPanel.setBounds(0, 0, this.getWidth() - 20, 25); // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); mainPanel.setLayout(null); btnBackup = new JButton("Backup"); btnBackup.setBounds(this.getWidth() / 2, 0, this.getWidth() / 2 - 20, mainPanel.getHeight()); btnBackup.addActionListener(this); mainPanel.add(btnBackup); this.add(mainPanel); fcPanel = new JPanel(); fcPanel.setBounds(10, 40, this.getWidth(), 260); // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); fcPanel.setLayout(null); quellLabel = new JLabel("Bitte Quellverzeichnis auswählen"); quellLabel.setBounds(10, 5, 320, 20); fcPanel.add(quellLabel); quellListModel = new DefaultListModel<>(); quellJList = new JList<ListItem>(quellListModel); quellJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); quellJList.setLayoutOrientation(JList.VERTICAL); quellJList.addListSelectionListener(this); listBoxScroller = new JScrollPane(quellJList); listBoxScroller.setBounds(0, 30, 315, 100); fcPanel.add(listBoxScroller); btnQAuswahl = new JButton("Quellverz. hinzufügen"); btnQAuswahl.setBounds(320, 30, 200, 25); btnQAuswahl.addActionListener(this); fcPanel.add(btnQAuswahl); btnQEntfernen = new JButton("Quellverz. entfernen"); btnQEntfernen.setBounds(320, 60, 200, 25); btnQEntfernen.addActionListener(this); fcPanel.add(btnQEntfernen); zielLabel = new JLabel("Bitte Zielverzeichnis auswählen"); zielLabel.setBounds(10, 135, 320, 20); fcPanel.add(zielLabel); zielListModel = new DefaultListModel<>(); zielJList = new JList<ListItem>(zielListModel); zielJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); zielJList.setLayoutOrientation(JList.VERTICAL); zielJList.addListSelectionListener(this); listBoxScroller2 = new JScrollPane(zielJList); listBoxScroller2.setBounds(0, 160, 315, 100); fcPanel.add(listBoxScroller2); btnZAuswahl = new JButton("Zielverz. hinzufügen"); btnZAuswahl.setBounds(320, 160, 200, 25); btnZAuswahl.addActionListener(this); fcPanel.add(btnZAuswahl); btnZEntfernen = new JButton("Zielverz. entfernen"); btnZEntfernen.setBounds(320, 190, 200, 25); btnZEntfernen.addActionListener(this); fcPanel.add(btnZEntfernen); this.add(fcPanel); ButtonGroup bGrp = new ButtonGroup(); optionPanel = new JPanel(); optionPanel.setBounds(10, 300 + 10, this.getWidth() - 40, 90); optionPanel.setPreferredSize(new Dimension(this.getWidth() - 40, 90)); // optionPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); optionPanel.setLayout(new GridLayout(3, 1)); nUebSchr = new JRadioButton("Keine Dateien überschreiben"); nUebSchr.addItemListener(this); bGrp.add(nUebSchr); optionPanel.add(nUebSchr); ueSchr = new JRadioButton("Neuere Dateien überschreiben"); ueSchr.addItemListener(this); bGrp.add(ueSchr); optionPanel.add(ueSchr); aUeSchr = new JRadioButton("Alle Dateien überschreiben"); aUeSchr.addItemListener(this); bGrp.add(aUeSchr); optionPanel.add(aUeSchr); this.add(optionPanel); syncPanel = new JPanel(); syncPanel.setBounds( 10, optionPanel.getY() + optionPanel.getHeight() + 10, this.getWidth() - 30, 25); // syncPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); syncPanel.setLayout(new BorderLayout()); btnSync = new JButton("Sync it!"); btnSync.setBounds(0, 0, 150, (syncPanel.getHeight() / 3)); btnSync.addActionListener(this); btnSync.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3))); btnSync.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3))); syncPanel.add(btnSync, BorderLayout.LINE_START); btnAbbruch = new JButton("Abbrechen"); btnAbbruch.setBounds(0, 0, 150, (syncPanel.getHeight() / 3)); btnAbbruch.addActionListener(this); btnAbbruch.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3))); btnAbbruch.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3))); btnAbbruch.setVisible(false); syncPanel.add(btnAbbruch, BorderLayout.LINE_END); progressBar = new JProgressBar(JProgressBar.HORIZONTAL); progressBar.setBorderPainted(true); progressBar.setPreferredSize(new Dimension(300, (syncPanel.getHeight() / 3))); progressBar.setForeground(Color.RED); progressBar.setStringPainted(true); progressBar.setVisible(true); syncPanel.add(progressBar, BorderLayout.CENTER); this.add(syncPanel); logPanel = new JPanel(); logPanel.setBounds( 10, syncPanel.getY() + syncPanel.getHeight() + 10, this.getWidth() - 30, 105); logPanel.setLayout(new BorderLayout()); textArea = new JTextArea(); textArea.setMargin(new Insets(3, 3, 3, 3)); textArea.setBackground(Color.black); textArea.setForeground(Color.LIGHT_GRAY); textArea.setAutoscrolls(true); textArea.setFocusable(false); textAreaScroller = new JScrollPane(textArea); DefaultCaret caret = (DefaultCaret) textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); textAreaScroller.setBounds(0, 0, syncPanel.getWidth(), 50); logPanel.add(textAreaScroller, BorderLayout.CENTER); this.add(logPanel, BorderLayout.SOUTH); }