source: trunk/src/org/expeditee/items/widgets/ButtonWidget.java@ 994

Last change on this file since 994 was 994, checked in by davidb, 8 years ago

Added new Java classes for widgets

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1package org.expeditee.items.widgets;
2import java.awt.BorderLayout;
3import java.awt.Color;
4import java.awt.Dimension;
5import java.io.File;
6import java.net.URL;
7
8import javax.swing.JButton;
9import javax.swing.JPanel;
10import javax.swing.border.EmptyBorder;
11import org.expeditee.items.Text;
12import com.kitfox.svg.app.beans.SVGIcon;
13
14//Will be the default class for Rubbish Bin, Reset and Undo Button Widgets
15public class ButtonWidget extends InteractiveWidget{
16
17 JButton clicked = new JButton("");
18
19 public ButtonWidget(int dimension, String filePath, Text source, String[] args)
20 {
21 //Controls how the widget is displayed
22 super(source, new JPanel(new BorderLayout()), 80, 80, 80, 80);
23
24 clicked.setBorder(new EmptyBorder(0, 0, 0, 0));
25 clicked.setBackground(Color.white);
26
27 SVGIcon icon = null;
28 Dimension size = new Dimension(dimension, dimension);
29 icon = new SVGIcon();
30 try{
31 URL imageURL = ClassLoader.getSystemResource(filePath);
32 icon.setSvgURI(imageURL.toURI());
33 //This STILL works, unsure why. Don't remove it has an affect on the button appearance.
34 icon.setUseAntiAlias(true);
35 icon.setScaleToFit(true);
36 icon.setPreferredSize(size);
37 clicked.setIcon(icon);
38 _swingComponent.add(clicked);
39 this.setWidgetEdgeThickness(0.0f);
40 this.setWidgetEdgeColor(Color.white);
41 }
42 catch(Exception e){
43
44 //Set a default image if image is missing
45 System.out.println("Unable to load image from directory");
46 }
47 }
48
49 @Override
50 protected String[] getArgs() {
51 // TODO Auto-generated method stub
52 return null;
53 }
54 public boolean itemHeldWhileClicked(InteractiveWidget bw) {
55 // TODO Auto-generated method stub
56 return false;
57 }
58 public boolean getdropInteractableStatus(){
59 return false;
60 }
61
62}
Note: See TracBrowser for help on using the repository browser.