Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package queuegui;
- import java.util.LinkedList;
- import java.util.Queue;
- import javax.swing.JLabel;
- /**
- *
- * @author natekiger
- */
- public class QueueGUI extends javax.swing.JFrame{
- private Queue<Integer> queue;
- /**
- * Creates new form QueueGUI
- */
- public QueueGUI() {
- queue = new LinkedList();
- initComponents();
- }
- private void enqueueButtonActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- String input = this.textbox1.getText();
- int toAdd = Integer.parseInt(input);
- //QueueModel queue = new QueueModel();
- this.queue.add(toAdd); //adds int to tail
- this.label1.setText(input);
- this.label1.setVisible(true);
- this.label2.setVisible(true);
- }
- private void dequeueButtonActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- this.queue.remove(0); //removes the head
- int head = queue.peek();
- String num = Integer.toString(head);
- this.label2.setText(num);
- //this.label2.setVisible(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement