svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / gui / panels / LinkPanel.java @ 34002
History | View | Annotate | Download (15.7 KB)
1 | 6117 | jaume | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 29596 | jpiera | package org.gvsig.app.gui.panels; |
42 | 6117 | jaume | |
43 | import java.awt.BorderLayout; |
||
44 | 13558 | evercher | import java.awt.Dimension; |
45 | 18623 | jdominguez | import java.awt.Graphics2D; |
46 | import java.awt.GridBagConstraints; |
||
47 | import java.awt.GridBagLayout; |
||
48 | import java.awt.GridLayout; |
||
49 | import java.awt.RenderingHints; |
||
50 | import java.awt.event.ComponentEvent; |
||
51 | import java.awt.event.ComponentListener; |
||
52 | import java.awt.geom.AffineTransform; |
||
53 | import java.awt.geom.Rectangle2D; |
||
54 | import java.awt.image.BufferedImage; |
||
55 | 6117 | jaume | import java.io.File; |
56 | import java.io.IOException; |
||
57 | import java.net.MalformedURLException; |
||
58 | 13558 | evercher | import java.net.URI; |
59 | 6117 | jaume | import java.net.URL; |
60 | |||
61 | import javax.swing.ImageIcon; |
||
62 | import javax.swing.JButton; |
||
63 | import javax.swing.JDialog; |
||
64 | import javax.swing.JLabel; |
||
65 | import javax.swing.JPanel; |
||
66 | import javax.swing.JScrollPane; |
||
67 | 13558 | evercher | import javax.swing.JTextPane; |
68 | 6117 | jaume | import javax.swing.event.HyperlinkEvent; |
69 | |||
70 | 13558 | evercher | import org.apache.batik.bridge.BridgeContext; |
71 | import org.apache.batik.bridge.DocumentLoader; |
||
72 | import org.apache.batik.bridge.GVTBuilder; |
||
73 | import org.apache.batik.bridge.UserAgentAdapter; |
||
74 | import org.apache.batik.bridge.ViewBox; |
||
75 | import org.apache.batik.gvt.GraphicsNode; |
||
76 | import org.apache.batik.gvt.renderer.StaticRenderer; |
||
77 | 29596 | jpiera | import org.gvsig.andami.PluginServices; |
78 | import org.gvsig.andami.messages.NotificationManager; |
||
79 | import org.gvsig.andami.ui.mdiManager.IWindow; |
||
80 | import org.gvsig.andami.ui.mdiManager.WindowInfo; |
||
81 | import org.gvsig.app.project.documents.gui.PDFViewerWindow; |
||
82 | import org.gvsig.app.project.documents.view.toolListeners.LinkListener; |
||
83 | import org.gvsig.utils.BrowserControl; |
||
84 | 28033 | cordinyana | |
85 | import org.slf4j.Logger; |
||
86 | import org.slf4j.LoggerFactory; |
||
87 | |||
88 | 13558 | evercher | import org.w3c.dom.Document; |
89 | import org.w3c.dom.Element; |
||
90 | import org.w3c.dom.svg.SVGDocument; |
||
91 | 18623 | jdominguez | |
92 | 13558 | evercher | import com.sun.jimi.core.Jimi; |
93 | 6117 | jaume | |
94 | |||
95 | /**
|
||
96 | 13558 | evercher | * This class extends JPanel. This class implements a Panel to show the content of the URI
|
97 | * that the constructor of the class receives. The URI is interpreted according to the type
|
||
98 | * of the HyperLink. The allowed types are Text, WWW, image (jpg,gif,tiff,bmp,ico), PDF
|
||
99 | * documents and SVG images. Implements listener to resize the component that contains the
|
||
100 | * text when resize the window.
|
||
101 | 6117 | jaume | *
|
102 | * @author Vicente Caballero Navarro
|
||
103 | 8275 | caballero | *
|
104 | 6117 | jaume | */
|
105 | 13558 | evercher | public class LinkPanel extends JPanel implements IWindow, ComponentListener { |
106 | 28033 | cordinyana | private static final Logger logger = LoggerFactory |
107 | .getLogger(LinkPanel.class); |
||
108 | |||
109 | 6117 | jaume | private JPanel jPane = null; |
110 | private JScrollPane jScrollPane = null; |
||
111 | 13558 | evercher | // private JEditorPane jEditorPane1 = null;
|
112 | 6117 | jaume | private JPanel jPanel = null; // @jve:decl-index=0:visual-constraint="220,10" |
113 | 13558 | evercher | private URI uri=null; |
114 | 10165 | caballero | private int type=LinkListener.TYPELINKIMAGE; |
115 | 13558 | evercher | private JPanel jPanel1Izq = null; |
116 | private JPanel jPanel1Der = null; |
||
117 | private JLabel jLabelUri = null; |
||
118 | private JButton jButtonCerrar = null; |
||
119 | private JScrollPane scroll=null; |
||
120 | private int alto; |
||
121 | private int ancho; |
||
122 | private WindowInfo m_ViewInfo;
|
||
123 | private JTextPane textPane; |
||
124 | private Element elt; |
||
125 | private GVTBuilder gvtBuilder = new GVTBuilder(); |
||
126 | private GraphicsNode gvtRoot = null; |
||
127 | 18623 | jdominguez | private BridgeContext ctx = null; |
128 | 13558 | evercher | private StaticRenderer renderer = new StaticRenderer(); |
129 | protected static RenderingHints defaultRenderingHints; |
||
130 | static {
|
||
131 | defaultRenderingHints = new RenderingHints(null); |
||
132 | defaultRenderingHints.put(RenderingHints.KEY_ANTIALIASING,
|
||
133 | RenderingHints.VALUE_ANTIALIAS_ON);
|
||
134 | |||
135 | defaultRenderingHints.put(RenderingHints.KEY_INTERPOLATION,
|
||
136 | RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||
137 | } |
||
138 | 6117 | jaume | /**
|
139 | 13558 | evercher | * This is the default constructor. Needs the URI with the information of the HyperLink
|
140 | * and the type of the HyperLink
|
||
141 | 6117 | jaume | */
|
142 | 13558 | evercher | public LinkPanel(URI Uri, int t){ |
143 | 6117 | jaume | super();
|
144 | type=t; |
||
145 | 13558 | evercher | uri=Uri; |
146 | addComponentListener(this);
|
||
147 | 6117 | jaume | initialize(); |
148 | } |
||
149 | |||
150 | /**
|
||
151 | * This method initializes this
|
||
152 | */
|
||
153 | private void initialize() { |
||
154 | this.setLayout(new BorderLayout()); |
||
155 | this.setSize(600, 450); |
||
156 | 13558 | evercher | alto=this.getHeight()-100; |
157 | ancho=this.getWidth()-100; |
||
158 | 6117 | jaume | this.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
|
159 | this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
|
||
160 | } |
||
161 | |||
162 | 8275 | caballero | |
163 | 6117 | jaume | /**
|
164 | * This method initializes jScrollPane
|
||
165 | *
|
||
166 | * @return javax.swing.JScrollPane
|
||
167 | */
|
||
168 | private JScrollPane getJScrollPane() { |
||
169 | if (jScrollPane == null) { |
||
170 | jScrollPane = new JScrollPane(); |
||
171 | jScrollPane.setPreferredSize(new java.awt.Dimension(300, 400)); |
||
172 | jScrollPane.setViewportView(getJPane()); |
||
173 | } |
||
174 | return jScrollPane;
|
||
175 | } |
||
176 | |||
177 | /**
|
||
178 | 13558 | evercher | * This method initializes jEditorPane1. Check the type of the HyperLink and analize the
|
179 | * URI. According to the type, adds to the panel the necessary components to show the
|
||
180 | * content of the URI. If the type is "0" (text/WWW) adds a ScrollPane with the text.
|
||
181 | * If the type "1" (smages) adds a ImageIcon with a label. If the type is "2" uses the
|
||
182 | * library "JPedal" to open PDF documents and if the type is "3" implements some methods
|
||
183 | * to open SVG images
|
||
184 | 6117 | jaume | *
|
185 | * @return javax.swing.JEditorPane
|
||
186 | */
|
||
187 | private JPanel getJPane() { |
||
188 | 8275 | caballero | |
189 | 6117 | jaume | if (jPane == null) { |
190 | jPane=new JPanel(); |
||
191 | 13558 | evercher | System.out.println(type);
|
192 | 8275 | caballero | |
193 | 13558 | evercher | //Enlazar a documento de texto o WWW
|
194 | 6117 | jaume | if (type==1){ |
195 | 13558 | evercher | textPane = new JTextPane(); |
196 | |||
197 | scroll = new JScrollPane(textPane); |
||
198 | scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
|
||
199 | scroll.setPreferredSize(new Dimension(ancho-100,alto-100)); |
||
200 | scroll.setMinimumSize(new Dimension(ancho-100,alto-100)); |
||
201 | textPane.setEditable(false);
|
||
202 | |||
203 | 26449 | jmvivo | if(uri==null) { |
204 | System.out.println("NULO"); |
||
205 | } |
||
206 | 13558 | evercher | if (uri != null) { |
207 | URL url=null; |
||
208 | try {
|
||
209 | url=uri.normalize().toURL(); |
||
210 | } catch (MalformedURLException e1) { |
||
211 | NotificationManager.addError(e1); |
||
212 | } |
||
213 | try {
|
||
214 | |||
215 | textPane.setPage(url); |
||
216 | textPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {
|
||
217 | public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) { |
||
218 | 6117 | jaume | if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { |
219 | System.out.println("hyperlinkUpdate()"); |
||
220 | 13558 | evercher | BrowserControl.displayURL(e.getURL().toString()); |
221 | 6117 | jaume | |
222 | 13558 | evercher | } |
223 | 6117 | jaume | } |
224 | 13558 | evercher | }); |
225 | } catch (IOException e) { |
||
226 | System.err.println("Attempted to read a bad URL: " + |
||
227 | uri); |
||
228 | } |
||
229 | jPane.add(scroll); |
||
230 | } else {
|
||
231 | System.err.println("Couldn't find file."); |
||
232 | 6117 | jaume | } |
233 | } |
||
234 | 13558 | evercher | //Enlazar a archivo de Im?gen
|
235 | else if (type==0){ |
||
236 | |||
237 | ImageIcon image = null; |
||
238 | String iString=uri.toString();
|
||
239 | iString=iString.toLowerCase(); |
||
240 | if (uri == null){ |
||
241 | System.out.println("Uri creada incorrectamente"); |
||
242 | return null;} |
||
243 | |||
244 | if (iString.endsWith("jpg") || iString.endsWith("jpeg") || |
||
245 | iString.endsWith("gif")) {
|
||
246 | try {
|
||
247 | image = new ImageIcon(Jimi.getImage(uri.toURL())); |
||
248 | } catch (MalformedURLException e) { |
||
249 | e.printStackTrace(); |
||
250 | } |
||
251 | } else
|
||
252 | if (iString.endsWith("png") || iString.endsWith("tiff") || |
||
253 | 27379 | vcaballero | iString.endsWith("ico") || iString.endsWith("xpm")) { |
254 | 13558 | evercher | try {
|
255 | image = new ImageIcon(Jimi.getImage(uri.toURL())); |
||
256 | } catch (MalformedURLException e) { |
||
257 | e.printStackTrace(); |
||
258 | } |
||
259 | |||
260 | }else {
|
||
261 | try {
|
||
262 | image=new ImageIcon(uri.toURL()); |
||
263 | } catch (MalformedURLException e) { |
||
264 | e.printStackTrace(); |
||
265 | } |
||
266 | } |
||
267 | 26449 | jmvivo | if (image==null) { |
268 | return null; |
||
269 | } |
||
270 | 13558 | evercher | |
271 | JLabel label = new JLabel(image); |
||
272 | jPane.add(label); |
||
273 | |||
274 | jPane.setVisible(true);
|
||
275 | 6117 | jaume | } |
276 | 13558 | evercher | |
277 | //Tipo 2: Enlazar a documentos PDF
|
||
278 | else if (type==2){ |
||
279 | |||
280 | String aux=null; |
||
281 | try {
|
||
282 | aux = uri.normalize().toURL().toString(); |
||
283 | } catch (MalformedURLException e) { |
||
284 | e.printStackTrace(); |
||
285 | } |
||
286 | aux=aux.replaceFirst("file:/",""); |
||
287 | System.out.println(aux);
|
||
288 | PDFViewerWindow pdf =new PDFViewerWindow(aux);
|
||
289 | jPane.add(pdf); |
||
290 | jPane.setVisible(true);
|
||
291 | 6117 | jaume | } |
292 | |||
293 | 13558 | evercher | //Tipo 3: Enlazar a im?genes SDV
|
294 | else if (type==3){ |
||
295 | String iString=uri.toString();
|
||
296 | iString=iString.toLowerCase(); |
||
297 | if (uri == null){ |
||
298 | System.out.println("Uri creada incorrectamente"); |
||
299 | return null;} |
||
300 | File file=new File(uri); |
||
301 | iString=uri.toString().replaceFirst("file:/",""); |
||
302 | if (iString.endsWith("svg")){ |
||
303 | paintSVGToPanel(file); |
||
304 | } |
||
305 | 6117 | jaume | } |
306 | } |
||
307 | 13558 | evercher | return jPane;
|
308 | } |
||
309 | 6117 | jaume | |
310 | 13558 | evercher | /**
|
311 | * Allows paint SVG images in the panel.
|
||
312 | *
|
||
313 | * @param file, this file has been extracted from the URI
|
||
314 | */
|
||
315 | private void paintSVGToPanel(File file) { |
||
316 | BufferedImage image = new BufferedImage(this.getWidth(), this.getHeight(), |
||
317 | BufferedImage.TYPE_INT_ARGB);
|
||
318 | Graphics2D g = image.createGraphics();
|
||
319 | Rectangle2D rect = new Rectangle2D.Double(); |
||
320 | rect.setFrame(0,0,this.getWidth(),this.getHeight()); |
||
321 | obtainStaticRenderer(file); |
||
322 | drawSVG(g,rect, null);
|
||
323 | jPane.setVisible(true);
|
||
324 | 26449 | jmvivo | ImageIcon icon=new ImageIcon(image); |
325 | 13558 | evercher | JLabel label = new JLabel(icon); |
326 | jPane.add(label); |
||
327 | 6117 | jaume | } |
328 | |||
329 | /**
|
||
330 | 13558 | evercher | * Render the image to add to the panel.
|
331 | * @param file, this file has been extracted from the URI
|
||
332 | */
|
||
333 | private void obtainStaticRenderer(File file) { |
||
334 | try {
|
||
335 | UserAgentAdapter userAgent = new UserAgentAdapter();
|
||
336 | DocumentLoader loader = new DocumentLoader(userAgent);
|
||
337 | 18623 | jdominguez | ctx = new BridgeContext(userAgent, loader);
|
338 | 13558 | evercher | Document svgDoc = loader.loadDocument(file.toURI().toString());
|
339 | gvtRoot = gvtBuilder.build(ctx, svgDoc); |
||
340 | renderer.setTree(gvtRoot); |
||
341 | elt = ((SVGDocument) svgDoc).getRootElement(); |
||
342 | } catch (Exception ex) { |
||
343 | ex.printStackTrace(); |
||
344 | } |
||
345 | } |
||
346 | |||
347 | /**
|
||
348 | * Draw SVG in the Graphics that receives like parameter.
|
||
349 | *
|
||
350 | * @param g Graphics
|
||
351 | * @param rect Rectangle that fills the Graphic.
|
||
352 | * @param rv Rectangle. This forms the visible part in the Layout
|
||
353 | */
|
||
354 | private void drawSVG(Graphics2D g, Rectangle2D rect, Rectangle2D rv) { |
||
355 | if ((rv == null) || rv.contains(rect)) { |
||
356 | AffineTransform ataux = new AffineTransform(); |
||
357 | |||
358 | ataux.translate(rect.getX(), rect.getY()); |
||
359 | try {
|
||
360 | ataux.concatenate(ViewBox.getViewTransform(null, elt,
|
||
361 | 18623 | jdominguez | (float) rect.getWidth(), (float) rect.getHeight(), ctx)); |
362 | 13558 | evercher | gvtRoot.setTransform(ataux); |
363 | |||
364 | } catch (Exception e) { |
||
365 | // TODO: handle exception
|
||
366 | } |
||
367 | } else {
|
||
368 | AffineTransform ataux = new AffineTransform(); |
||
369 | |||
370 | ataux.translate(rect.getX(), rect.getY()); |
||
371 | ataux.concatenate(ViewBox.getViewTransform(null, elt,
|
||
372 | 18623 | jdominguez | (float) rect.getWidth(), (float) rect.getHeight(), ctx)); |
373 | 13558 | evercher | |
374 | gvtRoot.setTransform(ataux); |
||
375 | } |
||
376 | |||
377 | RenderingHints renderingHints = defaultRenderingHints;
|
||
378 | g.setRenderingHints(renderingHints); |
||
379 | |||
380 | if (gvtRoot != null) { |
||
381 | gvtRoot.paint(g); |
||
382 | } |
||
383 | } |
||
384 | |||
385 | /**
|
||
386 | 6117 | jaume | * This method initializes jPanel
|
387 | *
|
||
388 | * @return javax.swing.JPanel
|
||
389 | */
|
||
390 | private JPanel getJPanel() { |
||
391 | if (jPanel == null) { |
||
392 | 13558 | evercher | //JLabel name = new JLabel();
|
393 | GridLayout gridLayout = new GridLayout(); |
||
394 | gridLayout.setRows(1);
|
||
395 | 6117 | jaume | jPanel = new JPanel(); |
396 | 13558 | evercher | jPanel.setLayout(gridLayout); |
397 | 6117 | jaume | jPanel.setPreferredSize(new java.awt.Dimension(10, 50)); |
398 | jPanel.setSize(411, 50); |
||
399 | 13558 | evercher | jPanel.add(getJPanel1Izq(), null);
|
400 | jPanel.add(getJPanel1Der(), null);
|
||
401 | 6117 | jaume | String auxext=""; |
402 | } |
||
403 | |||
404 | return jPanel;
|
||
405 | } |
||
406 | |||
407 | 13558 | evercher | /* (non-Javadoc)
|
408 | * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
||
409 | */
|
||
410 | public WindowInfo getWindowInfo() {
|
||
411 | m_ViewInfo = new WindowInfo(WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE | WindowInfo.ICONIFIABLE);
|
||
412 | m_ViewInfo.setTitle(PluginServices.getText(this,"Hiperenlace")); |
||
413 | |||
414 | return m_ViewInfo;
|
||
415 | } |
||
416 | |||
417 | /* (non-Javadoc)
|
||
418 | * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
||
419 | */
|
||
420 | public void viewActivated() { |
||
421 | // TODO Auto-generated method stub
|
||
422 | } |
||
423 | |||
424 | 6117 | jaume | /**
|
425 | 13558 | evercher | * This method initializes jPanel1Izq
|
426 | 6117 | jaume | *
|
427 | 13558 | evercher | * @return javax.swing.JPanel
|
428 | */
|
||
429 | private JPanel getJPanel1Izq() { |
||
430 | if (jPanel1Izq == null) { |
||
431 | GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
||
432 | gridBagConstraints.gridx = 0;
|
||
433 | gridBagConstraints.gridy = 0;
|
||
434 | jLabelUri = new JLabel(); |
||
435 | jLabelUri.setText(uri.toString()); |
||
436 | jLabelUri.setPreferredSize(new java.awt.Dimension(172,17)); |
||
437 | jPanel1Izq = new JPanel(); |
||
438 | jPanel1Izq.setLayout(new GridBagLayout()); |
||
439 | jPanel1Izq.setPreferredSize(new java.awt.Dimension(10,10)); |
||
440 | jPanel1Izq.setAlignmentX(0.5F);
|
||
441 | jPanel1Izq.add(jLabelUri, gridBagConstraints); |
||
442 | } |
||
443 | return jPanel1Izq;
|
||
444 | } |
||
445 | |||
446 | /**
|
||
447 | * This method initializes jPanel1Der
|
||
448 | *
|
||
449 | * @return javax.swing.JPanel
|
||
450 | */
|
||
451 | private JPanel getJPanel1Der() { |
||
452 | if (jPanel1Der == null) { |
||
453 | GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
||
454 | gridBagConstraints1.gridx = 0;
|
||
455 | gridBagConstraints1.gridy = 0;
|
||
456 | jPanel1Der = new JPanel(); |
||
457 | jPanel1Der.setLayout(new GridBagLayout()); |
||
458 | jPanel1Der.add(getJButtonCerrar(), gridBagConstraints1); |
||
459 | } |
||
460 | return jPanel1Der;
|
||
461 | } |
||
462 | |||
463 | /**
|
||
464 | * Initializes jButtonCerrar, and implements the Listener to close the window
|
||
465 | *
|
||
466 | 6117 | jaume | * @return javax.swing.JButton
|
467 | */
|
||
468 | 13558 | evercher | private JButton getJButtonCerrar() { |
469 | if (jButtonCerrar == null) { |
||
470 | jButtonCerrar = new JButton(); |
||
471 | jButtonCerrar.setPreferredSize(new java.awt.Dimension(94,25)); |
||
472 | jButtonCerrar.setText(PluginServices.getText(this,"Cerrar")); |
||
473 | jButtonCerrar.addActionListener(new java.awt.event.ActionListener() {
|
||
474 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
475 | System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed() |
||
476 | 6117 | jaume | |
477 | 13558 | evercher | if (PluginServices.getMainFrame() != null) { |
478 | PluginServices.getMDIManager().closeWindow(LinkPanel.this); |
||
479 | } else {
|
||
480 | ((JDialog) (getParent().getParent().getParent()
|
||
481 | .getParent())).dispose(); |
||
482 | 6117 | jaume | } |
483 | 13558 | evercher | } |
484 | }); |
||
485 | |||
486 | 6117 | jaume | } |
487 | 13558 | evercher | return jButtonCerrar;
|
488 | } |
||
489 | /**
|
||
490 | * Resizes the scroll that contains the text when the window changes its own size
|
||
491 | */
|
||
492 | private void redimensionarScroll(){ |
||
493 | Dimension currentSize = getSize();
|
||
494 | scroll.setPreferredSize(new Dimension(currentSize.width-100,currentSize.height-100)); |
||
495 | scroll.setMinimumSize(new Dimension(currentSize.width-100,currentSize.height-100)); |
||
496 | scroll.updateUI(); |
||
497 | System.out.println(scroll.getSize().toString());
|
||
498 | } |
||
499 | 6117 | jaume | |
500 | 13558 | evercher | /**
|
501 | * Invoked when the frame?s size changes
|
||
502 | */
|
||
503 | public void componentResized(ComponentEvent e) { |
||
504 | 26449 | jmvivo | if(type==1) { |
505 | redimensionarScroll(); |
||
506 | } |
||
507 | 6117 | jaume | } |
508 | |||
509 | 13558 | evercher | /*
|
510 | * (non-Javadoc)
|
||
511 | * @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
|
||
512 | 6117 | jaume | */
|
513 | 13558 | evercher | public void componentMoved(ComponentEvent e) { |
514 | // TODO Auto-generated method stub
|
||
515 | 6117 | jaume | |
516 | } |
||
517 | |||
518 | 13558 | evercher | /*
|
519 | * (non-Javadoc)
|
||
520 | * @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
|
||
521 | 6117 | jaume | */
|
522 | 13558 | evercher | public void componentShown(ComponentEvent e) { |
523 | 6117 | jaume | // TODO Auto-generated method stub
|
524 | 13558 | evercher | |
525 | 6117 | jaume | } |
526 | 13558 | evercher | |
527 | /*
|
||
528 | * (non-Javadoc)
|
||
529 | * @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
|
||
530 | */
|
||
531 | public void componentHidden(ComponentEvent e) { |
||
532 | // TODO Auto-generated method stub
|
||
533 | |||
534 | } |
||
535 | 26449 | jmvivo | |
536 | public Object getWindowProfile() { |
||
537 | return WindowInfo.TOOL_PROFILE;
|
||
538 | } |
||
539 | 13558 | evercher | } |