-
-
Save anonymous/e2b6ca212a014d20b75a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.GridLayout; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import javax.swing.JButton; | |
import javax.swing.JFrame; | |
import javax.swing.JLabel; | |
import javax.swing.JTextArea; | |
public class Main extends JFrame implements ActionListener{ | |
private static final long serialVersionUID = 1L; | |
private JButton artists = new JButton("Artist Login"); | |
private JButton comment = new JButton("Comment"); | |
private JButton setUp = new JButton("Set Up"); | |
private JButton log = new JButton("Log In"); | |
private JButton submit = new JButton("Send"); | |
private JButton back = new JButton("Back"); | |
private JButton eye = new JButton("Enter"); | |
private JButton delete = new JButton("Delete"); | |
private JButton[] messi = new JButton[10]; | |
private String[] mesi = new String[10]; | |
private Messer[] messy = new Messer[1000]; | |
private int[] messl = new int[10]; | |
private int init = 1000000; | |
private String names, piece, message, artist, rate; | |
private JLabel uno = new JLabel(" "); | |
private JLabel dos = new JLabel(" "); | |
private JLabel tre = new JLabel(" "); | |
private JLabel cua = new JLabel(" "); | |
private JLabel cin = new JLabel(" "); | |
private JTextArea userOn = new JTextArea(1, 10); | |
private JTextArea passOp = new JTextArea(1, 10); | |
private JTextArea art = new JTextArea(1, 10); | |
private JTextArea rating = new JTextArea(1, 10); | |
private JTextArea mess = new JTextArea(5, 20); | |
private Messagers artsh = new Messagers(); | |
private JTextArea area = new JTextArea(1, 75); | |
public static void main(String[] argv) { | |
new Main().setVisible(true); | |
} | |
public Main() { | |
super("Tutorial - Bryan"); | |
setSize(1920, 1080); // W x H | |
setResizable(true); | |
setDefaultCloseOperation(EXIT_ON_CLOSE); | |
setLayout(new GridLayout(3, 1)); | |
//JTextField hola = new JTextField(); | |
//add(area); | |
artists.addActionListener(this); | |
comment.addActionListener(this); | |
setUp.addActionListener(this); | |
log.addActionListener(this); | |
back.addActionListener(this); | |
submit.addActionListener(this); | |
add(artists); | |
add(comment); | |
if(init == 1000000) | |
add(setUp); | |
} | |
@Override | |
public void actionPerformed(ActionEvent e) { | |
String name = e.getActionCommand(); | |
if(name.equals("Artist Login")) { | |
remove(artists); | |
remove(comment); | |
remove(setUp); | |
artL(); | |
} | |
if(name.equals("Comment")) { | |
remove(artists); | |
remove(comment); | |
remove(setUp); | |
repaint(); | |
validate(); | |
com(); | |
} | |
if(name.equals("Set Up")) { | |
init = 1; | |
remove(artists); | |
remove(comment); | |
remove(setUp); | |
repaint(); | |
validate(); | |
sets(); | |
} | |
if(name.equals("Log In") ) { | |
names = userOn.getText(); | |
init = Integer.parseInt(userOn.getText()); | |
if(artsh.clogin(names, init)) | |
logins(names); | |
} | |
if(name.equals("Back to Inbox")) { | |
logins(names); | |
} | |
if(name.equals("Back")) { | |
getContentPane().removeAll(); | |
setLayout(new GridLayout(2, 1)); | |
add(artists); | |
add(comment); | |
repaint(); | |
validate(); | |
} | |
if(name.equals("Send")) { | |
names = userOn.getText(); | |
artist = art.getText(); | |
piece = passOp.getText(); | |
rate = rating.getText(); | |
message = mess.getText(); | |
artsh.send(names, artist, piece, rate, message); | |
getContentPane().removeAll(); | |
setLayout(new GridLayout(2, 1)); | |
add(artists); | |
add(comment); | |
repaint(); | |
validate(); | |
} | |
if(name.equals("Enter")) { | |
init = Integer.parseInt(userOn.getText()); | |
artsh.submitt("connor", init); | |
init = Integer.parseInt(passOp.getText()); | |
artsh.submitt("kyle", init); | |
init = Integer.parseInt(art.getText()); | |
artsh.submitt("chase", init); | |
getContentPane().removeAll(); | |
setLayout(new GridLayout(2, 1)); | |
add(artists); | |
add(comment); | |
repaint(); | |
validate(); | |
} | |
if(!name.equals("empty")) { | |
getContentPane().removeAll(); | |
init = name.indexOf(" "); | |
init = Integer.parseInt(name.substring(0,init)); | |
redy(init); | |
} | |
} | |
public void redy(int a) { | |
int lines; | |
String my = messy[a].ret(message); | |
lines = my.length(); | |
lines = lines % 75; | |
lines ++; | |
setLayout(new GridLayout(5, 1)); | |
area.setRows(lines); | |
area.setText(my); | |
uno.setText("From: "+ messy[a].ret(names)); | |
dos.setText(messy[a].bb()); | |
add(uno); | |
add(dos); | |
add(area); | |
add(delete); | |
log.setActionCommand("Back to Inbox"); | |
add(log); | |
} | |
public void artL() | |
{ | |
setLayout(new GridLayout(3,2,10,200)); | |
uno.setText("Username"); | |
dos.setText("Password"); | |
add(uno); | |
add(userOn); | |
add(dos); | |
add(passOp); | |
add(back); | |
add(log); | |
repaint(); | |
validate(); | |
} | |
public void com() | |
{ | |
setLayout(new GridLayout(6,2,10,200)); | |
uno.setText("Your Name"); | |
dos.setText("Artist's Name"); | |
tre.setText("Piece Name"); | |
cua.setText("Rating out of 10"); | |
cin.setText("Message"); | |
add(uno); | |
add(userOn); | |
add(dos); | |
add(art); | |
add(tre); | |
add(passOp); | |
add(cua); | |
add(rating); | |
add(cin); | |
add(mess); | |
add(back); | |
add(submit); | |
repaint(); | |
validate(); | |
} | |
public void sets() | |
{ | |
setLayout(new GridLayout(4,2,10,200)); | |
uno.setText("Connor"); | |
dos.setText("Kyle"); | |
tre.setText("Chase"); | |
add(uno); | |
add(userOn); | |
add(dos); | |
add(passOp); | |
add(tre); | |
add(art); | |
add(eye); | |
repaint(); | |
validate(); | |
} | |
public void logins(String n) { | |
getContentPane().removeAll(); | |
messy = artsh.gM(); | |
int coo = 0; | |
for(int x = 0; x<10; x++) | |
messl[x] = -1; | |
for(int x = 0; x<1000; x++) | |
{ | |
if(messy[x].ret("artist").equals(n) || messy[x].ret("artist") == null) { | |
messl[coo] = x; | |
coo++; | |
} | |
} | |
coo = 0; | |
for(int x = 0; x < 10; x++) { | |
if(messl[x] != -1) { | |
coo++; | |
if(messy[messl[x]].isRead()) | |
mesi[x] = (messl[x] +" NEW| To: "+ messy[messl[x]].ret("artist") + " From: " + messy[messl[x]].ret("name")); | |
else | |
mesi[x] = (messl[x] +" | To: "+ messy[messl[x]].ret("artist") + " From: " + messy[messl[x]].ret("name")); | |
} | |
} | |
for(int x = 0 + coo; x < 10; x++) | |
mesi[x] = "empty"; | |
setLayout(new GridLayout(11, 1)); | |
for(int x = 0; x < 10; x++) { | |
messi[x].setActionCommand(mesi[x]); | |
if(!mesi[x].equals("empty")) | |
messi[x].addActionListener(this); | |
add(messi[x]); | |
} | |
add(back); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Messer { | |
private String name, art, pie, rat, mes; | |
private int rd; | |
public Messer() { | |
mes = "empty4939"; | |
rd = 0; | |
} | |
public void eMesser(String n, String a, String p, String r, String m){ | |
name = n; | |
art = a; | |
pie = p; | |
rat = r; | |
mes = m; | |
rd = 1; | |
if(a == null) | |
art = "All"; | |
} | |
public String ret(String a) { | |
if(a.equals("name")) | |
return name ; | |
if(a.equals("artist")) | |
return art ; | |
if(a.equals("piece")) | |
return pie ; | |
if(a.equals("rating")) | |
return rat ; | |
if(a.equals("message")) | |
return mes ; | |
return "blank"; | |
} | |
public void read() { | |
rd = 0; | |
} | |
public boolean isRead() { | |
if(rd == 1) | |
return true; | |
else | |
return false; | |
} | |
public String bb() { | |
String hey = ""; | |
int x =0; | |
if(pie != null){ | |
hey = ("For " + pie + " "); | |
x = 1; | |
} | |
if(rat != null){ | |
hey = (hey + rat + "/10 "); | |
x = 1; | |
} | |
if(x ==1) | |
return hey; | |
else | |
return ("No Extra Stuff"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Messer { | |
private String name, art, pie, rat, mes; | |
private int rd; | |
public Messer() { | |
mes = "empty4939"; | |
rd = 0; | |
} | |
public void eMesser(String n, String a, String p, String r, String m){ | |
name = n; | |
art = a; | |
pie = p; | |
rat = r; | |
mes = m; | |
rd = 1; | |
if(a == null) | |
art = "All"; | |
} | |
public String ret(String a) { | |
if(a.equals("name")) | |
return name ; | |
if(a.equals("artist")) | |
return art ; | |
if(a.equals("piece")) | |
return pie ; | |
if(a.equals("rating")) | |
return rat ; | |
if(a.equals("message")) | |
return mes ; | |
return "blank"; | |
} | |
public void read() { | |
rd = 0; | |
} | |
public boolean isRead() { | |
if(rd == 1) | |
return true; | |
else | |
return false; | |
} | |
public String bb() { | |
String hey = ""; | |
int x =0; | |
if(pie != null){ | |
hey = ("For " + pie + " "); | |
x = 1; | |
} | |
if(rat != null){ | |
hey = (hey + rat + "/10 "); | |
x = 1; | |
} | |
if(x ==1) | |
return hey; | |
else | |
return ("No Extra Stuff"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment