1 16 package net.sf.jftp.gui.base; 17 18 import net.sf.jftp.*; 19 import net.sf.jftp.config.Settings; 20 import net.sf.jftp.gui.framework.*; 21 22 import java.awt.*; 23 24 import javax.swing.*; 25 26 27 public class StatusCanvas extends JPanel 28 { 29 JLabel host = new JLabel(""); 30 JLabel separator = new JLabel(" "); 31 JLabel text = new JLabel(Settings.greeting); 32 String drawText = ""; 33 int pos = 0; 34 Image image; 35 Graphics offg; 36 boolean slide = false; 37 int interval = 3; 38 boolean fwd = false; 39 40 public StatusCanvas() 41 { 42 setMinimumSize(new Dimension(200, 25)); 43 setPreferredSize(new Dimension(320, 25)); 44 setLayout(null); 45 46 setVisible(true); 51 } 52 53 public void setInterval(int x) 54 { 55 interval = x; 56 } 57 58 public void forward() 59 { 60 fwd = true; 61 } 62 63 public void setText(String msg) 64 { 65 if(false) 66 { 67 text.setText(msg); 68 } 69 else 70 { 71 text.setText(""); 72 drawText = msg; 73 slide = false; 74 75 if(AppMenuBar.fadeMenu.getState()) 76 { 77 SwingUtilities.invokeLater(new Runnable () { 78 public void run() { 79 for(pos = 30; pos > 0; pos -= 1) 80 { 81 paintImmediately(0, 0, getSize().width, getSize().height); 82 net.sf.jftp.system.LocalIO.pause(interval); 83 } 84 } 85 }); 86 } 87 else 88 { 89 repaint(); 90 } 91 } 92 93 validate(); 94 } 95 96 public void scrollText(String msg) 97 { 98 if(false) 99 { 100 text.setText(msg); 101 } 102 else 103 { 104 text.setText(""); 105 drawText = msg; 106 slide = true; 107 108 if(AppMenuBar.fadeMenu.getState()) 109 { 110 for(pos = 700; pos > (msg.length() * -6); pos -= 1) 111 { 112 if(fwd) 113 { 114 break; 115 } 116 117 repaint(); 119 net.sf.jftp.system.LocalIO.pause(interval); 120 121 } 123 } 124 else 125 { 126 repaint(); 127 } 128 129 fwd = false; 130 } 131 132 validate(); 133 } 134 135 public void setHost(String h) 136 { 137 host.setText(h); 138 validate(); 139 } 140 141 public String getHost() 142 { 143 return host.getText(); 144 } 145 146 public void paintComponent(Graphics g) 147 { 148 if(image == null) 149 { 150 image = createImage(getWidth(), getHeight()); 151 } 152 153 if(offg == null) 154 { 155 offg = image.getGraphics(); 156 } 157 158 offg.setColor(GUIDefaults.light); 159 offg.setFont(GUIDefaults.status); 160 offg.fillRect(0, 0, getSize().width, getSize().height); 161 offg.setColor(new Color(125, 125, 175)); 162 163 if(!slide) 164 { 165 offg.drawString(drawText, 10, 15 + pos); 166 } 167 else 168 { 169 offg.drawString(drawText, 10 + pos, 15); 170 } 171 172 offg.setColor(GUIDefaults.front); 173 offg.drawRect(0, 0, getSize().width - 1, getSize().height - 1); 174 offg.drawRect(0, 0, getSize().width - 2, getSize().height - 2); 175 g.drawImage(image, 0, 0, this); 176 } 177 178 public void update(Graphics g) 179 { 180 paintComponent(g); 181 } 182 } 183 | Popular Tags |