I am trying to create a type of Graphics Editor that allows users to create graphic depictions of American Football plays. To do this, the User should be able to do the following:
1) Click and Move images with Left Mouse Click
2) Change images (circles, squares, and lines)
3) Reset size of all objects
Ideally, I would like to be able to add adjustable colors and line thickness, but that is far down the road.
Right now, all I can do is create JButtons that cycle through images when clicked. I think I would like to change this to JComboBox so users can go straight to the correct image. Here is my class called: FBButton
import javax.swing.*;
import java.awt.event.*;
@SuppressWarnings("serial")
public class FBButton extends JButton implements ActionListener {
ImageIcon SN, SL, SR, SC, CN, CL, CR, CC, IN;
byte value = 0;
public FBButton() {
SN = new ImageIcon(this.getClass().getResource("square_null.png"));
SL = new ImageIcon(this.getClass().getResource("square_left.png"));
SR = new ImageIcon(this.getClass().getResource("square_right.png"));
SC = new ImageIcon(this.getClass().getResource("square_line.png"));
CN = new ImageIcon(this.getClass().getResource("circle_null.png"));
CL = new ImageIcon(this.getClass().getResource("circle_left.png"));
CR = new ImageIcon(this.getClass().getResource("circle_right.png"));
CC = new ImageIcon(this.getClass().getResource("circle_line.png"));
IN = new ImageIcon(this.getClass().getResource("invisible.png"));
addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
value++;
value %= 9;
if (value == 1) {
setIcon(SN);
} else if (value == 2) {
setIcon(SL);
} else if (value == 3) {
setIcon(SR);
} else if (value == 4) {
setIcon(SC);
} else if (value == 5) {
setIcon(CN);
} else if (value == 6) {
setIcon(CL);
} else if (value == 7) {
setIcon(CR);
} else if (value == 8) {
setIcon(CC);
} else {
setIcon(IN);
}
}
}
These buttons work and the images can be found. Here is my code for the class FBPlayerFrame
import java.awt.Dimension;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
public class FBPlayerFrame extends JFrame {
JPanel p = new JPanel();
FBButton buttons[] = new FBButton[22];
Dimension dim = new Dimension(52, 52);
public static void main(String[] args) {
new FBPlayerFrame();
}
public FBPlayerFrame() {
super("Football Start");
setSize(400, 400);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
for (int i = 0; i < 4; i++) {
buttons[i] = new FBButton();
buttons[i].setPreferredSize(dim);
p.add(buttons[i]);
}
add(p);
setVisible(true);
}
}
In the spirit of keeping specific, what I am looking for first is the ability to Left Click and Drag JButtons,or JComboBoxes, throughout the frame. It would also help later if the Coordinates of the Buttons could be saved at some point, but that is not necessary now.
I have searched StackOverflow and youtube for similar questions, but have had a challenging time finding something that answers my question specifically.
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I have been finding the size of a stack in java and the run time is different every timeIs there any way the run time of the method be constant? What does run time depend upon? Would it help if the stack had a constant size?
I'm trying to open a text file and split it into a list of integer values in ClojureI get this error code every single time, and I've got no idea why
Having trouble figuring out how to check if a word from one String Array is in another String ArrayThis is what I have so far:
I have this error while trying to compile the flamingo graphic tools for java, using intelliJ