Changeset 994 for trunk/src/org/expeditee
- Timestamp:
- 02/04/16 10:44:34 (8 years ago)
- Location:
- trunk/src/org/expeditee/items/widgets
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/widgets/RubbishBin.java
r981 r994 1 1 package org.expeditee.items.widgets; 2 2 3 import java.awt.BorderLayout;4 import java.awt.Color;5 import java.awt.Dimension;6 import java.awt.Insets;7 3 import java.awt.event.ActionEvent; 8 4 import java.awt.event.ActionListener; 9 5 import java.io.File; 10 import javax.swing.BorderFactory;11 import javax.swing.JButton;12 import javax.swing.JPanel;13 import javax.swing.border.EmptyBorder;14 6 7 import org.expeditee.gui.DisplayIO; 15 8 import org.expeditee.gui.FrameMouseActions; 16 9 import org.expeditee.gui.FreeItems; 17 10 import org.expeditee.items.Item; 18 11 import org.expeditee.items.Text; 19 import com.kitfox.svg.app.beans.*;20 12 21 13 //When the Rubbish Bin Widget is clicked by any of the mouse buttons, whatever is currently being picked up by the mouse is destroyed 22 public class RubbishBin extends InteractiveWidget{14 public class RubbishBin extends ButtonWidget{ 23 15 24 16 public RubbishBin(Text source, String[] args){ 25 26 //Controls how the widget is displayed 27 super(source, new JPanel(new BorderLayout()), 80, 80, 80, 80); 28 JButton clicked = new JButton(""); 29 clicked.setBorder(new EmptyBorder(0, 0, 0, 0)); 30 clicked.setBackground(Color.white); 31 32 //Imports the SVG and displays it as the JButton image 33 SVGIcon icon = null; 34 Dimension size = new Dimension(80, 80); 35 File f = new File("src/org/expeditee/assets/images/bin.svg"); 36 icon = new SVGIcon(); 37 38 icon.setSvgURI(f.toURI()); 39 icon.setUseAntiAlias(true); 40 icon.setScaleToFit(true); 41 icon.setPreferredSize(size); 42 clicked.setIcon(icon); 43 _swingComponent.add(clicked); 44 this.setWidgetEdgeThickness(0.0f); 45 this.setWidgetEdgeColor(Color.white); 46 17 18 super(80, "org/expeditee/assets/images/bin.svg", source, args); 19 47 20 clicked.addActionListener(new ActionListener() { 48 public void actionPerformed(ActionEvent e) { 21 public void actionPerformed(ActionEvent e) { 49 22 50 System.out.println("Ok Button clicked.");51 52 23 } 53 24 }); … … 58 29 Item freeItems = FreeItems.getItemAttachedToCursor(); 59 30 if( freeItems != null){ 31 freeItems.setParent(DisplayIO.getCurrentFrame()); 32 33 try{ 60 34 61 35 FrameMouseActions.delete(freeItems); 62 36 } 37 catch(Exception e){ 38 39 e.printStackTrace(); 40 } 63 41 } 64 42 return true; … … 69 47 // TODO Auto-generated method stub 70 48 return null; 71 } 49 } 50 //this should be a generic method for any widget that is clicked while an item is being held 51 public boolean itemHeldWhileClicked(InteractiveWidget iw){ 52 53 ItemsLeftClickDropped(); 54 return true; 55 56 } 57 public boolean getdropInteractableStatus(){ 58 return true; 59 } 60 72 61 } -
trunk/src/org/expeditee/items/widgets/Undo.java
r981 r994 1 1 package org.expeditee.items.widgets; 2 2 3 import java.awt.BorderLayout;4 import java.awt.Color;5 import java.awt.Dimension;6 3 import java.awt.event.ActionEvent; 7 4 import java.awt.event.ActionListener; 8 5 import java.io.File; 9 import javax.swing.BorderFactory; 10 import javax.swing.JButton; 11 import javax.swing.JPanel; 12 import javax.swing.border.EmptyBorder; 6 import java.net.URL; 13 7 14 8 import org.expeditee.gui.DisplayIO; 15 import org.expeditee.gui.FrameGraphics;16 9 import org.expeditee.items.Text; 17 10 18 import com.kitfox.svg.app.beans.SVGIcon;19 20 11 //Creates a button that when pressed, restores the previous action 21 public class Undo extends InteractiveWidget{12 public class Undo extends ButtonWidget{ 22 13 23 14 public Undo(Text source, String[] args){ 24 15 25 //Controls how the widget is displayed 26 super(source, new JPanel(new BorderLayout()), 80, 80, 80, 80); 27 JButton clicked = new JButton(""); 28 clicked.setBorder(new EmptyBorder(0, 0, 0, 0)); 29 clicked.setBackground(Color.white); 30 31 //Imports the SVG and displays it as the JButton image 32 SVGIcon icon = null; 33 Dimension size = new Dimension(120, 120); 34 File f = new File("src/org/expeditee/assets/images/undo.svg"); 35 icon = new SVGIcon(); 36 37 icon.setSvgURI(f.toURI()); 38 icon.setUseAntiAlias(true); 39 icon.setScaleToFit(true); 40 icon.setPreferredSize(size); 41 clicked.setIcon(icon); 42 _swingComponent.add(clicked); 43 this.setWidgetEdgeThickness(0.0f); 44 this.setWidgetEdgeColor(Color.white); 16 super(120, "org/expeditee/assets/images/undo.svg", source, args); 45 17 46 18 clicked.addActionListener(new ActionListener() { 47 19 public void actionPerformed(ActionEvent e) { 48 49 System.out.println("Undo Button Clicked."); 20 50 21 DisplayIO.getCurrentFrame().undo(); 51 22 } … … 57 28 // TODO Auto-generated method stub 58 29 return null; 59 } 30 } 60 31 }
Note:
See TracChangeset
for help on using the changeset viewer.