Skip to content

Commit

Permalink
Popups now only occur when the user's chat is minimized
Browse files Browse the repository at this point in the history
  • Loading branch information
RogCampbell committed Jun 8, 2016
1 parent 6121481 commit e02c538
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/ChatClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,24 @@ public void run() {
String line = i.readUTF();
output.append(sdf.format(cal.getTime())+line + "\n");
output.setCaretPosition(output.getDocument().getLength());
if(getState()== Frame.ICONIFIED){
JFrame popup = new JFrame();
JTextArea msg = new JTextArea();
msg.setText(sdf.format(cal.getTime())+line + "\n");
msg.setWrapStyleWord(true);
msg.setEditable(false);
popup.setLayout(new BorderLayout());
popup.add(msg);
popup.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
popup.setLocationRelativeTo(null);
popup.setSize(200, 100);
popup.toFront();
popup.repaint();

Notification note = new Notification(popup,WindowPosition.BOTTOMRIGHT,25,25,1000);
NotificationQueue queue = new NotificationQueue();
queue.add(note);
}
}
} catch (IOException ex) {
ex.printStackTrace();
Expand All @@ -165,22 +183,6 @@ public boolean handleEvent(Event e) {
if ((e.target == input) && (e.id == Event.ACTION_EVENT)) {
try {
o.writeUTF(name.getText() + ": " + input.getText());
JFrame popup = new JFrame();
JTextArea msg = new JTextArea();
msg.setText(name.getText() + ": " + input.getText());
msg.setWrapStyleWord(true);
popup.setLayout(new BorderLayout());
popup.add(msg);
popup.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
popup.setLocationRelativeTo(null);
//popup.setVisible(true);
popup.setSize(200, 100);
popup.toFront();
popup.repaint();

Notification note = new Notification(popup,WindowPosition.BOTTOMRIGHT,25,25,1000);
NotificationQueue queue = new NotificationQueue();
queue.add(note);

input.setText("");
o.flush();
Expand Down

0 comments on commit e02c538

Please sign in to comment.