package frame; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import javax.swing.ImageIcon; import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JScrollPane; /** * This class is to display custom window that displays messages * that the program sends out. Basically acts as a graphical * System.out.print/println console. Will eventually expand to allow * for user interaction and to input custom commands * * @author * @version */ @SuppressWarnings("serial") public class terminalWindow extends JFrame { //Class variables SlideBrowser sb; JEditorPane sp; /** * Default constructor for terminal window frame * * @return */ public terminalWindow(SlideBrowser p) { //Create Frame super("Terminal"); this.setSize(400, 200); this.setResizable(false); //Set the frame icon to an image loaded from a file. this.setIconImage(new ImageIcon(getClass().getResource("/resources/16x16/application_osx_terminal.png")).getImage()); //Get frame sb = p; //Make terminal scroll pane sp = new JEditorPane("text/plain", ""); sp.setFont(new Font("Serif", Font.PLAIN, 12)); sp.setForeground(Color.WHITE); sp.setBackground(Color.BLACK); sp.setPreferredSize(new Dimension(400, 1500)); JScrollPane sbpscroll = new JScrollPane(sp); //Add scroll pane add(sbpscroll); addWindowListener(new WindowListener(){ @Override public void windowActivated(WindowEvent arg0) {} @Override public void windowClosed(WindowEvent arg0) {} @Override public void windowClosing(WindowEvent arg0) { sb.terminal.setSelected(false); } @Override public void windowDeactivated(WindowEvent arg0) {} @Override public void windowDeiconified(WindowEvent arg0) {} @Override public void windowIconified(WindowEvent arg0) {} @Override public void windowOpened(WindowEvent arg0) {} }); } /** * Adds given string to the message log * * @param String to add to the message log */ public void addMessage(String s){ if(sp.getText().equals("")) sp.setText(s + "\n"); else sp.setText(sp.getText() + s + "\n"); } }