/** Inicializace základních komponent okna */ private void init() { krokLabel = new JLabel("Synchronizace s web aplikací"); Font pismo = new Font("Arial", Font.BOLD, 14); krokLabel.setFont(pismo); NacitaciOkno.add(krokLabel); krokLabel.setBounds(90, 10, 250, 20); startButton = new JButton("Načíst"); startButton.setActionCommand("start"); startButton.setBounds(250, 110, 120, 25); startButton.addActionListener(new Start()); progressBar = new JProgressBar(0, 100); progressBar.setBounds(20, 60, 350, 25); progressBar.setValue(0); progressBar.setStringPainted(true); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false); NacitaciOkno.add(startButton); NacitaciOkno.add(progressBar); NacitaciOkno.setVisible(true); vybratButton = new JButton("Otevřít"); NacitaciOkno.add(vybratButton); vybratButton.setBounds(20, 110, 120, 25); vybratButton.addActionListener(new Zpet()); }
public Initialize() { setTitle(""); setSize(400, 300); setLocationRelativeTo(null); JPanel p = new JPanel(); p.setLayout(new GridLayout(3, 2)); typel = new JLabel("Animal Type:"); typef = new JComboBox(); typef.addItem("Cow"); typef.addItem("Deer"); typef.addItem("Horse"); tot_popl = new JLabel("Initial population:"); tot_pop = new JTextField(12); annuler = new JButton("Cancel"); validate = new JButton("Create"); annuler.addActionListener(this); validate.addActionListener(this); p.add(typel); p.add(typef); p.add(tot_popl); p.add(tot_pop); p.add(annuler); p.add(validate); setContentPane(p); this.pack(); // bien regrouper les éléments }
@Override public void valueChanged(ListSelectionEvent lsEve) { int rowNum = table.getSelectedRow(); int colNum = table.getSelectedColumn(); // System.out.println("Reached in else"); if (colNum > 0) { selectAllCB.setVisible(false); deleteBut.setVisible(false); new MessagePan(rowNum, workingSet); backBut.setVisible(true); Home.home.homeFrame.setVisible(true); } }
@Override public void mouseClicked(MouseEvent e) { ArrayList list = getSelectedMessages(); if (list.size() == 0) { deleteBut.setVisible(false); restoreBut.setVisible(false); } else { deleteBut.setVisible(true); if (Home.titlePan.getTitle().equals("Trash")) { restoreBut.setVisible(true); System.out.println("Here inside"); } } }
/** * This is the constructor for objects of the class ChangeReservationDialog * * @param markedSeats A collection of the seats marked in the room overview * @param show The show chosen in the result table * @param customerID The phonenumber of the customer * @param frame The frame the dialog was called from */ public ChangeReservationDialog( ArrayList<Seat> markedSeats, Show show, int customerID, MainFrame frame) { super("Reservation"); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); Border standart = BorderFactory.createEmptyBorder(5, 5, 5, 5); JPanel north = new JPanel(); north.setBorder(standart); contentPane.add(north, BorderLayout.NORTH); JLabel topText = new JLabel( "Du forsøger at ændre en reservation til en med følgende " + markedSeats.size() + " sæder til: " + show.toString()); north.add(topText); JPanel center = new JPanel(); center.setLayout(new FlowLayout()); center.setBorder(standart); contentPane.add(center, BorderLayout.CENTER); String seatString = "<html>"; for (Seat s : markedSeats) { seatString += s.toString() + "<br>"; } seatString += "</html>"; JLabel seatText = new JLabel(seatString); seatText.setBackground(Color.WHITE); center.add(seatText); JPanel south = new JPanel(); south.setLayout(new BorderLayout()); south.setBorder(standart); contentPane.add(south, BorderLayout.SOUTH); JPanel phoneSection = new JPanel(); JLabel costumerText = new JLabel("Kundens telefonnummer: " + customerID); phoneSection.add(costumerText); JPanel buttons = new JPanel(); JButton cancel = new JButton("Annuller"); cancel.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); JButton reserve = new JButton("Ændre"); reserve.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String number = "" + customerID; if (number.length() == 8) { Database.deleteReservations(show, customerID); for (Seat s : markedSeats) { Database.makeReservation(show, new Customer(Integer.parseInt(number)), s); } ChangeReservationDialog.this.dispose(); frame.reset(); } } }); buttons.add(cancel); buttons.add(reserve); south.add(buttons, BorderLayout.SOUTH); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); pack(); setVisible(true); }
public void setContent(String cat) { cat = cat.trim(); selectAllCB.setVisible(false); selectAllCB.setSelected(false); deleteBut.setVisible(false); restoreBut.setVisible(false); refreshBut.setVisible(true); Object columns[] = null; int count = 0; switch (cat) { case "Inbox": columns = new Object[] {"", "From", "Date", "Subject", "Content"}; count = Database.getCount("Inbox"); workingSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id desc"); ; break; case "SentMail": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Sentmail"); workingSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id desc"); break; case "Draft": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Draft"); workingSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id desc"); break; case "Outbox": columns = new Object[] {"", "To", "Date", "Subject", "Content"}; count = Database.getCount("Outbox"); workingSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id desc"); break; case "Trash": // restoreBut.setVisible(true); columns = new Object[] {"", "To/From", "Date", "Subject", "Content"}; count = Database.getCount("Trash"); workingSet = db.getData( "SELECT * FROM messages,trash WHERE messages.tag='trash' and messages.msg_id=trash.msg_id ORDER BY deleted_at desc"); break; default: System.out.println("in default case"); } if (count > 0) { selectAllCB.setVisible(true); rows = new Object[count][]; msgID = new int[count]; try { workingSet.beforeFirst(); for (int i = 0; i < count && workingSet.next(); i++) { msgID[i] = workingSet.getInt(1); rows[i] = new Object[] { false, workingSet.getString(2), workingSet.getDate(3), workingSet.getString(4), workingSet.getString(5) }; } } catch (SQLException sqlExc) { JOptionPane.showMessageDialog(null, sqlExc, "EXCEPTION", JOptionPane.ERROR_MESSAGE); sqlExc.printStackTrace(); } tableModel = new MyDefaultTableModel(rows, columns); table = new JTable(tableModel); table.getSelectionModel().addListSelectionListener(this); table.addMouseListener(this); table.getTableHeader().setOpaque(true); table.getTableHeader().setReorderingAllowed(false); // table.getTableHeader().setBackground(Color.blue); table.getTableHeader().setForeground(Color.blue); // table.setRowSelectionAllowed(false); // table.setColumnSelectionAllowed(false); table.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14)); table.setRowHeight(20); table.setFillsViewportHeight(true); TableColumn column = null; for (int i = 0; i < 5; i++) { column = table.getColumnModel().getColumn(i); if (i == 0) { column.setPreferredWidth(6); } else if (i == 3) { column.setPreferredWidth(250); } else if (i == 4) { column.setPreferredWidth(450); } else { column.setPreferredWidth(40); } } table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); remove(contentPan); contentPan = new JScrollPane(table); contentPan.setBackground(Color.orange); contentPan.setOpaque(true); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); Home.home.homeFrame.setVisible(true); } else { JPanel centPan = new JPanel(new GridBagLayout()); centPan.setBackground(new Color(52, 86, 70)); JLabel label = new JLabel("No Messages In This Category"); label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 22)); label.setForeground(Color.orange); centPan.add(label); remove(contentPan); contentPan = new JScrollPane(centPan); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); contentPan.repaint(); } }
public void createGUI() { setLayout(new BorderLayout()); toolBar = new JToolBar("options", JToolBar.HORIZONTAL); toolBar.setFloatable(false); toolBar.setOpaque(true); toolBar.setBackground(new Color(154, 12, 12)); toolBar.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); selectAllCB = new JCheckBox("Select All"); selectAllCB.setVisible(false); selectAllCB.setForeground(Color.white); selectAllCB.addActionListener(this); refreshBut = new JButton(new ImageIcon(this.getClass().getResource("/images/reloadIcon.png"))); refreshBut.setVisible(false); refreshBut.setToolTipText("Refresh"); refreshBut.setForeground(new Color(20, 88, 49)); refreshBut.addActionListener(this); backBut = new JButton(new ImageIcon(this.getClass().getResource("/images/backIcon.png"))); backBut.setVisible(false); backBut.setToolTipText("Back"); backBut.setForeground(new Color(20, 88, 49)); backBut.addActionListener(this); deleteBut = new JButton(new ImageIcon(this.getClass().getResource("/images/trashIcon.png"))); deleteBut.setToolTipText("Delete"); deleteBut.setForeground(Color.red); deleteBut.setVisible(false); deleteBut.addActionListener(this); deleteBut.setBackground(Color.red); restoreBut = new JButton(new ImageIcon(this.getClass().getResource("/images/restoreIcon.png"))); restoreBut.setToolTipText("Restore"); restoreBut.setForeground(Color.blue); restoreBut.setVisible(false); restoreBut.addActionListener(this); toolBar.addSeparator(new Dimension(10, 5)); toolBar.add(selectAllCB); toolBar.add(backBut); toolBar.add(refreshBut); toolBar.add(deleteBut); toolBar.add(restoreBut); add(toolBar, "North"); JPanel centPan = new JPanel(new GridBagLayout()); centPan.setBackground(new Color(52, 86, 70)); JLabel label = new JLabel("Select A Category From Left Pane"); label.setFont(new Font("arial", Font.BOLD, 35)); label.setForeground(Color.yellow); centPan.add(label); contentPan = new JScrollPane(centPan); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); contentPan.repaint(); db = new Database(); // inboxSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id // desc"); // sentmailSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id // desc"); // draftSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id // desc"); // outboxSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id // desc"); // trashSet = db.getData("SELECT * FROM messages,trash WHERE messages.tag='trash' and // messages.msg_id=trash.msg_id ORDER BY deleted_at desc"); }
@Override public void actionPerformed(ActionEvent axnEve) { Object obj = axnEve.getSource(); if (obj == selectAllCB) { Boolean state; if (selectAllCB.isSelected()) { state = true; deleteBut.setVisible(true); if (Home.titlePan.getTitle().equals("Trash")) { restoreBut.setVisible(true); } } else { state = false; deleteBut.setVisible(false); if (Home.titlePan.getTitle().equals("Trash")) { restoreBut.setVisible(false); } } for (int i = 0; i < table.getRowCount(); i++) { table.setValueAt(state, i, 0); } } else if (obj == refreshBut || obj == backBut) { setContent(Home.titlePan.getTitle()); backBut.setVisible(false); } else if (obj == deleteBut) { ArrayList selectedMessages = getSelectedMessages(); if (selectedMessages.isEmpty()) { FootPan.setMessage(FootPan.NO_SELECTION_MESSAGE); } else { int option = JOptionPane.showConfirmDialog( Home.home.homeFrame, "Are You Sure?", "DELETE", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == 0) { Database.deleteMessages(selectedMessages, Home.titlePan.getTitle()); setContent(Home.titlePan.getTitle()); } } } else if (obj == restoreBut) { ArrayList selectedMessages = getSelectedMessages(); if (selectedMessages.isEmpty()) { FootPan.setMessage(FootPan.NO_SELECTION_MESSAGE); } else { int option = JOptionPane.showConfirmDialog( Home.home.homeFrame, "Are You Sure?", "RESTORE", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == 0) { Database.restoreMessages(selectedMessages); setContent(Home.titlePan.getTitle()); } } } }
public FavouritesView(Favourite favouritesModel) { super(); // Set the favourites model, and register ourselves as an observer, so we can be notified // of any changes to the model. _favouritesModel = favouritesModel; _favouritesModel.addObserver(this); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.setBorder(BorderFactory.createTitledBorder("Favourites")); JPanel listPanel = new JPanel(); listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.Y_AXIS)); listPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); _favouritesList = new JList(); _favouritesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); _favouritesList.setLayoutOrientation(JList.VERTICAL); // Fetch initial favourited stations. updateList(); _favouritesScroller = new JScrollPane(_favouritesList); _favouritesScroller.setHorizontalScrollBarPolicy( ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); _favouritesScroller.setVerticalScrollBarPolicy( ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); listPanel.add(_favouritesScroller); _remove = new JButton("Remove"); _remove.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { // Remove the selected station from the user's favourites. Station station = (Station) _favouritesList.getSelectedValue(); if (station != null) { _favouritesModel.removeStation(station); } } }); _select = new JButton("Select"); _select.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { // Display the selected favourite. if (_favouritesList.getSelectedValue() != null) _favouritesModel.setCurrentStation((Station) _favouritesList.getSelectedValue()); } }); JPanel buttonPanel = new JPanel(); buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); buttonPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 25)); buttonPanel.add(_select); buttonPanel.add(_remove); this.add(listPanel); this.add(buttonPanel); }