public class GUI extends JFrame implements Observer {
/**************************************************************
* Declarations PANELS.
*/
private CardLayout cardLayout = new CardLayout();
private final JPanel contentPane = new JPanel();
private final JPanel panel_content = new JPanel();
private final JPanel panel_menu = new JPanel();
private final JPanel panel_dump = new JPanel();
/**************************************************************
* Declarations BUTTONS.
*/
Image dump_icon = new ImageIcon(this.getClass().getResource("/btn_dump.png")).getImage();
Image changeDb_icon = new ImageIcon(this.getClass().getResource("/btn_changeDb.png")).getImage();
Image dbList_icon = new ImageIcon(this.getClass().getResource("/btn_dblist.png")).getImage();
Image whitespace_icon = new ImageIcon(this.getClass().getResource("/btn_whitespace.png")).getImage();
Image settings_icon = new ImageIcon(this.getClass().getResource("/btn_settings.png")).getImage();
private final JButton btn_dump = new JButton("");
private final JButton btn_changeDb = new JButton("");
private final JButton btn_dbList = new JButton("");
private final JButton btn_whitespace = new JButton("");
private final JButton btn_settings = new JButton("");
/**************************************************************
* Declarations JLabels.
*/
JLabel lbl_headling = new JLabel("HH");
/**************************************************************
* Declarations ARRAYS.
*/
private ArrayList<JButton> allButtons = new ArrayList<JButton>();
/**************************************************************
* Create the frame.
*/
public GUI(Controller control) {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500, 400);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
setUndecorated(true);
contentPane.add(panel_menu, BorderLayout.SOUTH);
setResizable(false);
setName("Frame");
panel_menu.add(btn_dump);
btn_dump.setIcon(new ImageIcon(dump_icon));
btn_dump.setName("EventButton");
panel_menu.add(btn_changeDb);
btn_changeDb.setIcon(new ImageIcon(changeDb_icon));
btn_changeDb.setName("EventButton");
panel_menu.add(btn_dbList);
btn_dbList.setIcon(new ImageIcon(dbList_icon));
btn_dbList.setName("EventButton");
panel_menu.add(btn_whitespace);
btn_whitespace.setIcon(new ImageIcon(whitespace_icon));
btn_whitespace.setName("EventButton");
panel_menu.add(btn_settings);
btn_settings.setIcon(new ImageIcon(settings_icon));
btn_settings.setName("EventButton");
panel_content.setLayout(new CardLayout(0, 0));
panel_content.add(panel_dump, "panel_dump");
GridBagLayout gbl_panel_dump = new GridBagLayout();
gbl_panel_dump.columnWidths = new int[]{153, 92, 0, 0};
gbl_panel_dump.rowHeights = new int[]{41, 0};
gbl_panel_dump.columnWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
gbl_panel_dump.rowWeights = new double[]{0.0, Double.MIN_VALUE};
panel_dump.setLayout(gbl_panel_dump);
GridBagConstraints gbc_lbl_headling = new GridBagConstraints();
gbc_lbl_headling.fill = GridBagConstraints.BOTH;
gbc_lbl_headling.gridx = 2;
gbc_lbl_headling.gridy = 0;
panel_dump.add(lbl_headling, gbc_lbl_headling);
/**************************************************************
* Array->ButtonsAdd
*/
allButtons.add(btn_dump);
allButtons.add(btn_changeDb);
allButtons.add(btn_dbList);
allButtons.add(btn_whitespace);
allButtons.add(btn_settings);
}
/**************************************************************
* GETTER
*/
public JPanel getContentPane() { return contentPane; }
public ArrayList getButtons() { return allButtons; }
@Override
public void update(Observable arg0, Object arg1) {
if(arg1 instanceof Model){
setOpacity((((Model)arg1).getframeVisible()));
System.out.println(arg0 + " " + arg1);
}
}
}