mirror of
https://github.com/macocianradu/javaGUItoolkit.git
synced 2026-03-18 13:40:04 +00:00
added working click listener
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import guiTree.Button;
|
||||
import guiTree.Window;
|
||||
import parser.XAMLParser;
|
||||
|
||||
@@ -7,14 +8,16 @@ import java.awt.event.WindowEvent;
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
try{
|
||||
Window window = XAMLParser.parse("company.xml");
|
||||
Window window = XAMLParser.parse("ui.xml");
|
||||
assert window != null;
|
||||
Button button = (Button)window.findByName("button1");
|
||||
window.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
window.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,62 @@
|
||||
package guiTree;
|
||||
|
||||
import guiTree.Visual;
|
||||
import guiTree.events.MouseListener;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class Button extends Visual {
|
||||
private String label;
|
||||
|
||||
public Button()
|
||||
{
|
||||
public Button() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public Button(String label) {
|
||||
super();
|
||||
this.label = label;
|
||||
this.addMouseListener(new MouseListener() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent mouseEvent) {
|
||||
if(getBackgroundColor() == Color.BLACK) {
|
||||
setBackgroundColor(Color.RED);
|
||||
}
|
||||
else {
|
||||
setBackgroundColor(Color.BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent mouseEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent mouseEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent mouseEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent mouseEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent mouseEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent mouseEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -17,6 +64,16 @@ public class Button extends Visual {
|
||||
{
|
||||
Graphics g = imageBuffer.getGraphics();
|
||||
g.setColor(this.getBackgroundColor());
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 50, 50);
|
||||
g.setColor(this.getForegroundColor());
|
||||
g.drawString(this.label, this.getWidth()/2, this.getHeight()/2);
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return this.label;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,32 @@
|
||||
package guiTree;
|
||||
|
||||
import guiTree.events.KeyEventGetter;
|
||||
import guiTree.events.MouseWheelGetter;
|
||||
|
||||
import javax.swing.event.MouseInputListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class CustomFrame extends Frame {
|
||||
private BufferedImage imageBuffer;
|
||||
private Window parentWindow;
|
||||
|
||||
public CustomFrame()
|
||||
public CustomFrame(Window parent)
|
||||
{
|
||||
super();
|
||||
this("", parent);
|
||||
}
|
||||
|
||||
public CustomFrame(String name)
|
||||
public CustomFrame(String name, Window parent)
|
||||
{
|
||||
super(name);
|
||||
this.parentWindow = parent;
|
||||
this.addMouseMotionListener(new MouseEventGetter(parent));
|
||||
this.addMouseListener(new MouseEventGetter(parent));
|
||||
this.addKeyListener(new KeyEventGetter(parent));
|
||||
this.addMouseWheelListener(new MouseWheelGetter(parent));
|
||||
}
|
||||
|
||||
public void setImageBuffer(BufferedImage imageBuffer) {
|
||||
|
||||
52
src/guiTree/MouseEventGetter.java
Normal file
52
src/guiTree/MouseEventGetter.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package guiTree;
|
||||
|
||||
import javax.swing.event.MouseInputListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class MouseEventGetter implements MouseInputListener {
|
||||
private Window callingWindow;
|
||||
|
||||
public MouseEventGetter(Window callingWindow) {
|
||||
this.callingWindow = callingWindow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent mouseEvent) {
|
||||
callingWindow.mouseDragged(mouseEvent, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent mouseEvent) {
|
||||
callingWindow.mouseMoved(mouseEvent, 0, 0);
|
||||
System.out.println("MOVED");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent mouseEvent) {
|
||||
callingWindow.mouseClicked(mouseEvent, 0, 0);
|
||||
System.out.println("CLICKED");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent mouseEvent) {
|
||||
callingWindow.mousePressed(mouseEvent, 0, 0);
|
||||
System.out.println("PRESSED");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent mouseEvent) {
|
||||
callingWindow.mouseReleased(mouseEvent, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent mouseEvent) {
|
||||
callingWindow.mouseEntered(mouseEvent, 0, 0);
|
||||
System.out.println("ENTERED");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent mouseEvent) {
|
||||
callingWindow.mouseExited(mouseEvent, 0, 0);
|
||||
System.out.println("EXITED");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
package guiTree;
|
||||
|
||||
import guiTree.events.KeyListener;
|
||||
import guiTree.events.MouseListener;
|
||||
import guiTree.events.MouseWheelListener;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -13,12 +19,14 @@ public class Visual {
|
||||
private List<Visual> children;
|
||||
private Visual parent;
|
||||
private BufferedImage imageBuffer;
|
||||
|
||||
private String name;
|
||||
private List<MouseListener> mouseListeners;
|
||||
private List<MouseWheelListener> mouseWheelListeners;
|
||||
private List<KeyListener> keyListeners;
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Attributes
|
||||
---------------------------------------------------------------------*/
|
||||
private String name;
|
||||
private Integer width;
|
||||
private Integer height;
|
||||
private Integer locationX;
|
||||
@@ -33,6 +41,9 @@ public class Visual {
|
||||
---------------------------------------------------------------------*/
|
||||
public Visual() {
|
||||
this.children = new ArrayList<>();
|
||||
this.mouseWheelListeners = new ArrayList<>();
|
||||
this.mouseListeners = new ArrayList<>();
|
||||
this.keyListeners = new ArrayList<>();
|
||||
this.parent = null;
|
||||
this.backgroundColor = Color.WHITE;
|
||||
this.foregroundColor = Color.BLACK;
|
||||
@@ -105,13 +116,21 @@ public class Visual {
|
||||
}
|
||||
|
||||
private void calculateInitialSize() {
|
||||
this.width = 20;
|
||||
this.height = 20;
|
||||
if(this.width == null) {
|
||||
this.width = 20;
|
||||
}
|
||||
if(this.height == null){
|
||||
this.height = 20;
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateInitialLocation(){
|
||||
this.locationX = 20;
|
||||
this.locationY = 50;
|
||||
if(this.locationX == null) {
|
||||
this.locationX = 20;
|
||||
}
|
||||
if(this.locationY == null){
|
||||
this.locationY = 50;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +138,22 @@ public class Visual {
|
||||
Tree Methods
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
public Visual findByName(String name){
|
||||
if(this.name.equals(name)){
|
||||
return this;
|
||||
}
|
||||
else{
|
||||
for(Visual child: children){
|
||||
Visual visual;
|
||||
visual = child.findByName(name);
|
||||
if(visual != null){
|
||||
return visual;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addVisual(Visual child) {
|
||||
this.children.add(child);
|
||||
child.setParent(this);
|
||||
@@ -130,6 +165,16 @@ public class Visual {
|
||||
child.revalidate();
|
||||
}
|
||||
|
||||
public void removeVisual(Visual child) {
|
||||
this.children.remove(child);
|
||||
child.setParent(null);
|
||||
child.setSize(0, 0);
|
||||
child.setLocation(0, 0);
|
||||
child.imageBuffer = null;
|
||||
child.active = false;
|
||||
revalidate();
|
||||
}
|
||||
|
||||
private void setParent(Visual parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
@@ -172,14 +217,199 @@ public class Visual {
|
||||
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Listener Methods
|
||||
---------------------------------------------------------------------*/
|
||||
void addMouseListener(MouseListener mouseListener) {
|
||||
this.mouseListeners.add(mouseListener);
|
||||
}
|
||||
|
||||
void removeMouseListener(MouseListener mouseListener) {
|
||||
this.mouseListeners.remove(mouseListener);
|
||||
}
|
||||
|
||||
void addMouseWheelListener(MouseWheelListener mouseWheelListener) {
|
||||
this.mouseWheelListeners.add(mouseWheelListener);
|
||||
}
|
||||
|
||||
void removeMouseWheelListener(MouseWheelListener mouseWheelListener) {
|
||||
this.mouseWheelListeners.remove(mouseWheelListener);
|
||||
}
|
||||
|
||||
void addKeyListener(KeyListener keyListener) {
|
||||
this.keyListeners.add(keyListener);
|
||||
}
|
||||
|
||||
void removeKeyListener(KeyListener keyListener) {
|
||||
this.keyListeners.remove(keyListener);
|
||||
}
|
||||
|
||||
void mouseClicked(MouseEvent mouseEvent, int offsetX, int offsetY) {
|
||||
boolean front = true;
|
||||
int mouseX = mouseEvent.getX() - offsetX;
|
||||
int mouseY = mouseEvent.getY() - offsetY;
|
||||
for(Visual v: children) {
|
||||
if(mouseX > v.getLocationX() &&
|
||||
mouseY > v.getLocationY() &&
|
||||
mouseX < v.getWidth() + v.getLocationX() &&
|
||||
mouseY < v.getHeight() + v.getLocationY()) {
|
||||
front = false;
|
||||
v.mouseClicked(mouseEvent, v.locationX + offsetX, v.locationY + offsetY);
|
||||
}
|
||||
}
|
||||
if(front) {
|
||||
for(MouseListener mouseListener: mouseListeners) {
|
||||
mouseListener.mouseClicked(mouseEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mouseReleased(MouseEvent mouseEvent, int offsetX, int offsetY) {
|
||||
boolean front = true;
|
||||
int mouseX = mouseEvent.getX() + offsetX;
|
||||
int mouseY = mouseEvent.getY() + offsetY;
|
||||
for(Visual v: children) {
|
||||
if(mouseX > v.getLocationX() &&
|
||||
mouseY < v.getLocationY() &&
|
||||
mouseX < v.getWidth() &&
|
||||
mouseY > v.getHeight()) {
|
||||
front = false;
|
||||
v.mouseReleased(mouseEvent, offsetX + v.locationX, offsetY + v.locationY);
|
||||
}
|
||||
}
|
||||
if(front) {
|
||||
for(MouseListener mouseListener: mouseListeners) {
|
||||
mouseListener.mouseReleased(mouseEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mousePressed(MouseEvent mouseEvent, int offsetX, int offsetY) {
|
||||
boolean front = true;
|
||||
int mouseX = mouseEvent.getX() + offsetX;
|
||||
int mouseY = mouseEvent.getY() + offsetY;
|
||||
for(Visual v: children) {
|
||||
if(mouseX > v.getLocationX() &&
|
||||
mouseY < v.getLocationY() &&
|
||||
mouseX < v.getWidth() &&
|
||||
mouseY > v.getHeight()) {
|
||||
front = false;
|
||||
v.mousePressed(mouseEvent, offsetX + v.locationX, offsetY + v.locationY);
|
||||
}
|
||||
}
|
||||
if(front) {
|
||||
for(MouseListener mouseListener: mouseListeners) {
|
||||
mouseListener.mousePressed(mouseEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mouseEntered(MouseEvent mouseEvent, int offsetX, int offsetY) {
|
||||
boolean front = true;
|
||||
int mouseX = mouseEvent.getX() + offsetX;
|
||||
int mouseY = mouseEvent.getY() + offsetY;
|
||||
for(Visual v: children) {
|
||||
if(mouseX > v.getLocationX() &&
|
||||
mouseY < v.getLocationY() &&
|
||||
mouseX < v.getWidth() &&
|
||||
mouseY > v.getHeight()) {
|
||||
front = false;
|
||||
v.mouseEntered(mouseEvent, offsetX + v.locationX, offsetY + v.locationY);
|
||||
}
|
||||
}
|
||||
if(front) {
|
||||
for(MouseListener mouseListener: mouseListeners) {
|
||||
mouseListener.mouseEntered(mouseEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mouseExited(MouseEvent mouseEvent, int offsetX, int offsetY) {
|
||||
boolean front = true;
|
||||
int mouseX = mouseEvent.getX() + offsetX;
|
||||
int mouseY = mouseEvent.getY() + offsetY;
|
||||
for(Visual v: children) {
|
||||
if(mouseX > v.getLocationX() &&
|
||||
mouseY < v.getLocationY() &&
|
||||
mouseX < v.getWidth() &&
|
||||
mouseY > v.getHeight()) {
|
||||
front = false;
|
||||
v.mouseExited(mouseEvent, offsetX + v.locationX, offsetY + v.locationY);
|
||||
}
|
||||
}
|
||||
if(front) {
|
||||
for(MouseListener mouseListener: mouseListeners) {
|
||||
mouseListener.mouseExited(mouseEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mouseDragged(MouseEvent mouseEvent, int offsetX, int offsetY) {
|
||||
boolean front = true;
|
||||
int mouseX = mouseEvent.getX() + offsetX;
|
||||
int mouseY = mouseEvent.getY() + offsetY;
|
||||
for(Visual v: children) {
|
||||
if(mouseX > v.getLocationX() &&
|
||||
mouseY < v.getLocationY() &&
|
||||
mouseX < v.getWidth() &&
|
||||
mouseY > v.getHeight()) {
|
||||
front = false;
|
||||
v.mouseDragged(mouseEvent, offsetX + v.locationX, offsetY + v.locationY);
|
||||
}
|
||||
}
|
||||
if(front) {
|
||||
for(MouseListener mouseListener: mouseListeners) {
|
||||
mouseListener.mouseDragged(mouseEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mouseMoved(MouseEvent mouseEvent, int offsetX, int offsetY) {
|
||||
boolean front = true;
|
||||
int mouseX = mouseEvent.getX() + offsetX;
|
||||
int mouseY = mouseEvent.getY() + offsetY;
|
||||
for(Visual v: children) {
|
||||
if(mouseX > v.getLocationX() &&
|
||||
mouseY < v.getLocationY() &&
|
||||
mouseX < v.getWidth() &&
|
||||
mouseY > v.getHeight()) {
|
||||
front = false;
|
||||
v.mouseMoved(mouseEvent, offsetX + v.locationX, offsetY + locationY);
|
||||
}
|
||||
}
|
||||
if(front) {
|
||||
for(MouseListener mouseListener: mouseListeners) {
|
||||
mouseListener.mouseMoved(mouseEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mouseWheelMoved(MouseWheelEvent mouseWheelEvent, int offsetX, int offsetY) {
|
||||
boolean front = true;
|
||||
int mouseX = mouseWheelEvent.getX() + offsetX;
|
||||
int mouseY = mouseWheelEvent.getY() + offsetY;
|
||||
for(Visual v: children) {
|
||||
if(mouseX > v.getLocationX() &&
|
||||
mouseY < v.getLocationY() &&
|
||||
mouseX < v.getWidth() &&
|
||||
mouseY > v.getHeight()) {
|
||||
front = false;
|
||||
v.mouseWheelMoved(mouseWheelEvent, offsetX + v.locationX, offsetY + v.locationY);
|
||||
}
|
||||
}
|
||||
if(front) {
|
||||
for(MouseWheelListener mouseWheelListener: mouseWheelListeners) {
|
||||
mouseWheelListener.mouseWheelMoved(mouseWheelEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
Helper Methods
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
private void initializeImageBuffer(Integer width, Integer height){
|
||||
this.imageBuffer = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
|
||||
this.imageBuffer.getGraphics().setColor(backgroundColor);
|
||||
this.imageBuffer.getGraphics().fillRect(0, 0, width, height);
|
||||
this.imageBuffer.getGraphics().setColor(foregroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package guiTree;
|
||||
|
||||
import guiTree.Visual;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.awt.event.WindowStateListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
|
||||
public class Window extends Visual {
|
||||
public CustomFrame frame;
|
||||
private List<Visual> listenerList;
|
||||
|
||||
public Window()
|
||||
{
|
||||
super();
|
||||
this.frame = new CustomFrame();
|
||||
this.frame = new CustomFrame(this);
|
||||
this.addWindowStateListener(e -> {
|
||||
this.setSize(getWidth(), getHeight());
|
||||
revalidate();
|
||||
@@ -64,4 +64,14 @@ public class Window extends Visual {
|
||||
public void setPositionRelativeTo(){
|
||||
frame.setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
public void setUndecorated(Boolean undecorated){frame.setUndecorated(undecorated);}
|
||||
|
||||
public void addListener(Visual listener) {
|
||||
this.listenerList.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(Visual listener) {
|
||||
this.listenerList.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
29
src/guiTree/events/KeyEventGetter.java
Normal file
29
src/guiTree/events/KeyEventGetter.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package guiTree.events;
|
||||
|
||||
import guiTree.Window;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
|
||||
public class KeyEventGetter implements KeyListener {
|
||||
public Window callingWindow;
|
||||
|
||||
public KeyEventGetter(Window callingWindow) {
|
||||
this.callingWindow = callingWindow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent keyEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent keyEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent keyEvent) {
|
||||
|
||||
}
|
||||
}
|
||||
9
src/guiTree/events/KeyListener.java
Normal file
9
src/guiTree/events/KeyListener.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package guiTree.events;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public interface KeyListener {
|
||||
void keyTyped(KeyEvent keyEvent);
|
||||
void keyPressed(KeyEvent keyEvent);
|
||||
void keyReleased(KeyEvent keyEvent);
|
||||
}
|
||||
13
src/guiTree/events/MouseListener.java
Normal file
13
src/guiTree/events/MouseListener.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package guiTree.events;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public interface MouseListener {
|
||||
void mouseClicked(MouseEvent mouseEvent);
|
||||
void mouseReleased(MouseEvent mouseEvent);
|
||||
void mousePressed(MouseEvent mouseEvent);
|
||||
void mouseEntered(MouseEvent mouseEvent);
|
||||
void mouseExited(MouseEvent mouseEvent);
|
||||
void mouseDragged(MouseEvent mouseEvent);
|
||||
void mouseMoved(MouseEvent mouseEvent);
|
||||
}
|
||||
19
src/guiTree/events/MouseWheelGetter.java
Normal file
19
src/guiTree/events/MouseWheelGetter.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package guiTree.events;
|
||||
|
||||
import guiTree.Window;
|
||||
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
|
||||
public class MouseWheelGetter implements MouseWheelListener {
|
||||
private Window callingWindow;
|
||||
|
||||
public MouseWheelGetter(Window callingWindow) {
|
||||
this.callingWindow = callingWindow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent mouseWheelEvent) {
|
||||
|
||||
}
|
||||
}
|
||||
7
src/guiTree/events/MouseWheelListener.java
Normal file
7
src/guiTree/events/MouseWheelListener.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package guiTree.events;
|
||||
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
|
||||
public interface MouseWheelListener {
|
||||
void mouseWheelMoved(MouseWheelEvent mouseWheelEvent);
|
||||
}
|
||||
@@ -23,11 +23,18 @@ public class XAMLParser {
|
||||
String methodName = "set";
|
||||
methodName = methodName.concat(attribute.getNodeName());
|
||||
List<Object> parameterList = convertStringToPrimitives(object, attribute.getNodeValue(), methodName);
|
||||
Method method = getMethod(object, methodName, parameterList);
|
||||
if(parameterList == null) {
|
||||
break;
|
||||
}
|
||||
Class<?>[] parameterTypes = new Class[parameterList.size()];
|
||||
for(int index = 0; index < parameterList.size(); index++){
|
||||
parameterTypes[index] = parameterList.get(index).getClass();
|
||||
}
|
||||
try {
|
||||
Method method = object.getClass().getMethod(methodName, parameterTypes);
|
||||
assert method != null;
|
||||
method.invoke(object, parameterList.toArray());
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user