import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.ButtonGroup;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;
import javax.swing.UIManager;
public class edit extends JFrame {
private JPanel contentPane;
public static JTextField txtText = new JTextField();
static JRadioButton rdbtnNone = new JRadioButton("None");
static JRadioButton rdbtnRed = new JRadioButton("Red");
static JRadioButton rdbtnNone2 = new JRadioButton("None");
static JRadioButton rdbtnScroll = new JRadioButton("Scroll");
static JRadioButton rdbtnWave = new JRadioButton("Wave");
static JRadioButton rdbtnWave2 = new JRadioButton("Wave 2");
static JRadioButton rdbtnShake = new JRadioButton("Shake");
static JRadioButton rdbtnSlide = new JRadioButton("Slide");
static JRadioButton rdbtnWhite = new JRadioButton("White");
static JRadioButton rdbtnGreen = new JRadioButton("Green");
static JRadioButton rdbtnPurple = new JRadioButton("Purple");
static JRadioButton rdbtnCyan = new JRadioButton("Cyan");
static JRadioButton rdbtnFlash1 = new JRadioButton("Flash 1");
static JRadioButton rdbtnFlash2 = new JRadioButton("Flash 2");
static JRadioButton rdbtnFlash3 = new JRadioButton("Flash 3");
static JRadioButton rdbtnGlow1 = new JRadioButton("Glow 1");
static JRadioButton rdbtnGlow2 = new JRadioButton("Glow 2");
static JRadioButton rdbtnGlow3 = new JRadioButton("Glow 3");
static JButton btnCancel = new JButton("Cancel");
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
edit frame = new edit();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
setup();
}
/**
* Create the frame.
*/
public edit() {
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent arg0) {
main.frmRunescapeAutotyper.setVisible(true);
}
});
setTitle("Edit Message");
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 451, 244);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
dispose();
main.frmRunescapeAutotyper.setVisible(true);
}
});
txtText.setColumns(10);
JLabel lblMessage = new JLabel("Message:");
JPanel panel = new JPanel();
panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Colour:", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
JPanel panel_1 = new JPanel();
panel_1.setBorder(new TitledBorder(null, "Movement:", TitledBorder.LEADING, TitledBorder.TOP, null, null));
GroupLayout gl_panel_1 = new GroupLayout(panel_1);
gl_panel_1.setHorizontalGroup(
gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addComponent(rdbtnNone2)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(rdbtnWave2))
.addGroup(gl_panel_1.createSequentialGroup()
.addComponent(rdbtnScroll)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(rdbtnShake))
.addGroup(gl_panel_1.createSequentialGroup()
.addComponent(rdbtnWave)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(rdbtnSlide)))
.addGap(22))
);
rdbtnNone2.setSelected(true);
gl_panel_1.setVerticalGroup(
gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
.addComponent(rdbtnNone2)
.addComponent(rdbtnWave2))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
.addComponent(rdbtnScroll)
.addComponent(rdbtnShake))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
.addComponent(rdbtnWave)
.addComponent(rdbtnSlide))
.addContainerGap(78, Short.MAX_VALUE))
);
panel_1.setLayout(gl_panel_1);
JButton btnAdd = new JButton("Change");
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(4)
.addComponent(lblMessage)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(txtText))
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(panel, GroupLayout.PREFERRED_SIZE, 170, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)
.addComponent(btnAdd, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnCancel, GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE))
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(panel_1, GroupLayout.PREFERRED_SIZE, 158, GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblMessage)
.addComponent(txtText, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(55)
.addComponent(btnAdd)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addGroup(gl_contentPane.createSequentialGroup()
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(panel, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE)
.addComponent(panel_1, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE))))
.addGap(3))
);
GroupLayout gl_panel = new GroupLayout(panel);
gl_panel.setHorizontalGroup(
gl_panel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel.createSequentialGroup()
.addContainerGap()
.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel.createSequentialGroup()
.addComponent(rdbtnCyan)
.addGap(18)
.addComponent(rdbtnGlow3))
.addGroup(gl_panel.createSequentialGroup()
.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
.addComponent(rdbtnNone)
.addComponent(rdbtnRed)
.addComponent(rdbtnWhite)
.addComponent(rdbtnGreen)
.addComponent(rdbtnPurple))
.addGap(14)
.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
.addComponent(rdbtnGlow2)
.addComponent(rdbtnGlow1)
.addComponent(rdbtnFlash3)
.addComponent(rdbtnFlash2)
.addComponent(rdbtnFlash1))))
.addContainerGap(16, Short.MAX_VALUE))
);
rdbtnNone.setSelected(true);
gl_panel.setVerticalGroup(
gl_panel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel.createSequentialGroup()
.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
.addComponent(rdbtnNone)
.addComponent(rdbtnFlash1))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
.addComponent(rdbtnRed)
.addComponent(rdbtnFlash2))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
.addComponent(rdbtnWhite)
.addComponent(rdbtnFlash3))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
.addComponent(rdbtnGreen)
.addComponent(rdbtnGlow1))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
.addComponent(rdbtnPurple)
.addComponent(rdbtnGlow2))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
.addComponent(rdbtnCyan)
.addComponent(rdbtnGlow3))
.addContainerGap(9, Short.MAX_VALUE))
);
panel.setLayout(gl_panel);
contentPane.setLayout(gl_contentPane);
ButtonGroup group = new ButtonGroup();
group.add(rdbtnNone);
group.add(rdbtnRed);
group.add(rdbtnWhite);
group.add(rdbtnGreen);
group.add(rdbtnPurple);
group.add(rdbtnCyan);
group.add(rdbtnFlash1);
group.add(rdbtnFlash2);
group.add(rdbtnFlash3);
group.add(rdbtnGlow1);
group.add(rdbtnGlow2);
group.add(rdbtnGlow3);
ButtonGroup group2 = new ButtonGroup();
group2.add(rdbtnNone2);
group2.add(rdbtnScroll);
group2.add(rdbtnWave);
group2.add(rdbtnWave2);
group2.add(rdbtnShake);
group2.add(rdbtnScroll);
group2.add(rdbtnSlide);
btnAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
edit();
}
});
}
public static void edit(){
int originalindex = main.list1.getSelectedIndex();
main.list1.delItem(originalindex);
String colour = null;
String movement = null;
Boolean error = false;
if(rdbtnNone.isSelected() == true){
colour = "";
}else if(rdbtnRed.isSelected() == true){
colour = "Red:";
}else if(rdbtnWhite.isSelected() == true){
colour = "White:";
}else if(rdbtnGreen.isSelected() == true){
colour = "Green:";
}else if(rdbtnPurple.isSelected() == true){
colour = "Purple:";
}else if(rdbtnCyan.isSelected() == true){
colour = "Cyan:";
}else if(rdbtnFlash1.isSelected() == true){
colour = "Flash1:";
}else if(rdbtnFlash2.isSelected() == true){
colour = "Flash2:";
}else if(rdbtnFlash3.isSelected() == true){
colour = "Flash3:";
}else if(rdbtnGlow1.isSelected() == true){
colour = "Glow1:";
}else if(rdbtnGlow2.isSelected() == true){
colour = "Glow2:";
}else if(rdbtnGlow2.isSelected() == true){
colour = "Glow3:";
}else {
JOptionPane.showMessageDialog(null, "No colour selected!", "Error", JOptionPane.INFORMATION_MESSAGE, null);
error = true;
}
if(rdbtnNone2.isSelected() == true){
movement = "";
}else if(rdbtnWave2.isSelected() == true){
movement = "Wave2:";
}else if(rdbtnWave.isSelected() == true){
movement = "Wave:";
}else if(rdbtnScroll.isSelected() == true){
movement = "Scroll:";
}else if(rdbtnShake.isSelected() == true){
movement = "Shake:";
}else if(rdbtnSlide.isSelected() == true){
movement = "Slide:";
}else{
JOptionPane.showMessageDialog(null, "No movement selected!", "Error", JOptionPane.INFORMATION_MESSAGE, null);
error = true;
}
if(error == false){
main.list1.addItem(colour + movement + txtText.getText(), originalindex);
main.list1.select(originalindex);
btnCancel.doClick();
}
}
public static void setup(){
String message;
String colour;
String movement;
String original;
String temp = new String();
int count;
boolean colourbool = false;
boolean movementbool = false;
original = main.list1.getItem(main.list1.getSelectedIndex());
count = original.indexOf(":");
temp = original.substring(0, count);
txtText.setText(temp);
if(temp.equals("Red")){
rdbtnRed.setSelected(true);
}else if(temp == "White"){
rdbtnWhite.setSelected(true);
}else if(temp == "Green"){
rdbtnGreen.setSelected(true);
}else if(temp == "Purple"){
rdbtnPurple.setSelected(true);
}else if(temp == "Cyan"){
rdbtnCyan.setSelected(true);
}else if(temp == "Flash1"){
rdbtnFlash1.setSelected(true);
}else if(temp == "Flash2"){
rdbtnFlash2.setSelected(true);
}else if(temp == "Flash3"){
rdbtnFlash3.setSelected(true);
}else if(temp == "Glow1"){
rdbtnGlow1.setSelected(true);
}else if(temp == "Glow2"){
rdbtnGlow2.setSelected(true);
}else if(temp == "Glow3"){
rdbtnGlow3.setSelected(true);
}else if(temp == "Wave"){
rdbtnWave.setSelected(true);
}else if(temp == "Wave2"){
rdbtnWave2.setSelected(true);
}else if(temp == "Scroll"){
rdbtnScroll.setSelected(true);
}else if(temp == "Shake"){
rdbtnShake.setSelected(true);
}else if(temp == "Slide"){
rdbtnSlide.setSelected(true);
}else{
JOptionPane.showMessageDialog(null, "Didnt do anytin (like normal)");
}
if(temp == "Wave"){
rdbtnWave.setSelected(true);
}else if(temp == "Wave2"){
rdbtnWave2.setSelected(true);
}else if(temp == "Scroll"){
rdbtnScroll.setSelected(true);
}else if(temp == "Shake"){
rdbtnShake.setSelected(true);
}else if(temp == "Slide"){
rdbtnSlide.setSelected(true);
}
}
}