Quantcast
Channel: Programação - GUJ
Viewing all articles
Browse latest Browse all 33093

Estou fazendo um programa de poltronas de cinema, mas não consigo fazer com que quando vai clicando nos botões(poltronas) vá somando um a quantidade de ingressos

$
0
0

@Joao_Vitor_Araujo escreveu:

package trabalho;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class poltronas extends JFrame implements ActionListener {
JLabel label1, label2, label3, label4, label5, label6, label7, label8, label9, label10, label11, label12, label13,
label14, label15;
JTextField t1, t2;
JButton b1, b2, b3, b5, b4, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23,
b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39;
JPanel p1, p2, p3, p4, p5, p6, p7, p8, p9;

public static void main(String args[]) {
	JFrame janela = new poltronas();
	janela.setUndecorated(true);
	janela.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
	janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	janela.setVisible(true);
}

poltronas() {
	setTitle("Cinema");
	setBounds(300, 50, 700, 700);
	label1 = new JLabel("");
	label2 = new JLabel("ESCOLHA", JLabel.LEFT);
	label2.setFont(new Font("", Font.HANGING_BASELINE, 20));
	label3 = new JLabel("SUAS", JLabel.CENTER);
	label3.setFont(new Font("", Font.HANGING_BASELINE, 20));
	label3.setForeground(Color.black);
	label4 = new JLabel("POLTRONAS", JLabel.RIGHT);
	label4.setFont(new Font("", Font.ITALIC, 18));
	label5 = new JLabel("");
	label6 = new JLabel("");
	label7 = new JLabel("Quantidade", JLabel.CENTER);
	label7.setFont(new Font("", Font.HANGING_BASELINE, 18));
	label8 = new JLabel("de  ingressos:");
	label8.setFont(new Font("", Font.HANGING_BASELINE, 18));
	label9 = new JLabel("");
	label10 = new JLabel("TOTAL:", JLabel.CENTER);
	label10.setFont(new Font("", Font.HANGING_BASELINE, 18));
	label15 = new JLabel("0");

	label11 = new JLabel("");
	label11.setBackground(Color.DARK_GRAY);
	b1 = new JButton("MEIA");
	label12 = new JLabel("");
	label12.setBackground(Color.DARK_GRAY);
	label13 = new JLabel("");
	label13.setBackground(Color.DARK_GRAY);
	b2 = new JButton("INTEIRA");
	label14 = new JLabel("");
	label14.setBackground(Color.DARK_GRAY);

	t1 = new JTextField("           ");
	t1.setEditable(false);
	t2 = new JTextField("           ");
	t2.setEditable(false);

	b4 = new JButton("1");
	b4.setBackground(Color.GREEN);
	b4.addActionListener(this);
	b5 = new JButton("2");
	b5.setBackground(Color.LIGHT_GRAY);
	b5.addActionListener(this);
	b6 = new JButton("3");
	b6.setBackground(Color.GREEN);
	b6.addActionListener(this);
	b7 = new JButton("4");
	b7.setBackground(Color.LIGHT_GRAY);
	b7.addActionListener(this);
	b8 = new JButton("5");
	b8.setBackground(Color.GREEN);
	b8.addActionListener(this);
	b9 = new JButton("6");
	b9.setBackground(Color.LIGHT_GRAY);
	b9.addActionListener(this);
	b10 = new JButton("7");
	b10.setBackground(Color.LIGHT_GRAY);
	b10.addActionListener(this);
	b11 = new JButton("8");
	b11.setBackground(Color.GREEN);
	b11.addActionListener(this);
	b12 = new JButton("9");
	b12.setBackground(Color.LIGHT_GRAY);
	b12.addActionListener(this);
	b13 = new JButton("10");
	b13.setBackground(Color.GREEN);
	b13.addActionListener(this);
	b14 = new JButton("11");
	b14.setBackground(Color.LIGHT_GRAY);
	b14.addActionListener(this);
	b15 = new JButton("12");
	b15.setBackground(Color.GREEN);
	b15.addActionListener(this);
	b16 = new JButton("13");
	b16.setBackground(Color.GREEN);
	b16.addActionListener(this);
	b17 = new JButton("14");
	b17.setBackground(Color.LIGHT_GRAY);
	b17.addActionListener(this);
	b18 = new JButton("15");
	b18.setBackground(Color.GREEN);
	b18.addActionListener(this);
	b19 = new JButton("16");
	b19.setBackground(Color.LIGHT_GRAY);
	b19.addActionListener(this);
	b20 = new JButton("17");
	b20.setBackground(Color.GREEN);
	b20.addActionListener(this);
	b21 = new JButton("18");
	b21.setBackground(Color.LIGHT_GRAY);
	b21.addActionListener(this);
	b22 = new JButton("19");
	b22.setBackground(Color.LIGHT_GRAY);
	b22.addActionListener(this);
	b23 = new JButton("20");
	b23.setBackground(Color.GREEN);
	b23.addActionListener(this);
	b24 = new JButton("21");
	b24.setBackground(Color.LIGHT_GRAY);
	b24.addActionListener(this);
	b25 = new JButton("22");
	b25.setBackground(Color.GREEN);
	b25.addActionListener(this);
	b26 = new JButton("23");
	b26.setBackground(Color.LIGHT_GRAY);
	b26.addActionListener(this);
	b27 = new JButton("24");
	b27.setBackground(Color.GREEN);
	b27.addActionListener(this);
	b28 = new JButton("25");
	b28.setBackground(Color.GREEN);
	b28.addActionListener(this);
	b29 = new JButton("26");
	b29.setBackground(Color.LIGHT_GRAY);
	b29.addActionListener(this);
	b30 = new JButton("27");
	b30.setBackground(Color.GREEN);
	b30.addActionListener(this);
	b31 = new JButton("28");
	b31.setBackground(Color.LIGHT_GRAY);
	b31.addActionListener(this);
	b32 = new JButton("29");
	b32.setBackground(Color.GREEN);
	b32.addActionListener(this);
	b33 = new JButton("30");
	b33.setBackground(Color.LIGHT_GRAY);
	b33.addActionListener(this);
	b34 = new JButton("31");
	b34.setBackground(Color.yellow);
	b34.addActionListener(this);
	b35 = new JButton("32");
	b35.setBackground(Color.yellow);
	b35.addActionListener(this);
	b36 = new JButton("33");
	b36.setBackground(Color.yellow);
	b36.addActionListener(this);
	b37 = new JButton("34");
	b37.setBackground(Color.yellow);
	b37.addActionListener(this);
	b38 = new JButton("35");
	b38.setBackground(Color.yellow);
	b38.addActionListener(this);
	b39 = new JButton("36");
	b39.setBackground(Color.yellow);
	b39.addActionListener(this);
	p1 = new JPanel();
	p2 = new JPanel();
	p3 = new JPanel();
	p4 = new JPanel();
	p5 = new JPanel();
	p6 = new JPanel();
	p7 = new JPanel();
	p8 = new JPanel();
	p9 = new JPanel();
	p1.setLayout(new FlowLayout());
	p1.add(label1);
	p3.setLayout(new FlowLayout());
	p3.add(label2);
	p4.setLayout(new FlowLayout());
	p4.add(label3);
	p5.setLayout(new FlowLayout());
	p5.add(label4);
	p6.setLayout(new FlowLayout());
	p6.add(label5);
	p7.setLayout(new FlowLayout());
	p7.add(label6);

	p2.setLayout(new FlowLayout());
	p2.add(label7);
	p2.add(label8);
	p2.add(label15);

	p8.setLayout(new FlowLayout());
	p8.add(label9);
	p8.add(label10);
	p8.add(t2);

	p9.setLayout(new FlowLayout());
	p9.add(label11);
	p9.add(b1);
	p9.add(label12);
	p9.add(label13);
	p9.add(b2);
	p9.add(label14);

	getContentPane().setLayout(new GridLayout(8, 5));
	getContentPane().add(p1);
	getContentPane().add(p3);
	getContentPane().add(p4);
	getContentPane().add(p5);
	getContentPane().add(p6);
	getContentPane().add(p7);
	getContentPane().add(b4);
	getContentPane().add(b5);
	getContentPane().add(b6);
	getContentPane().add(b7);
	getContentPane().add(b8);
	getContentPane().add(b9);
	getContentPane().add(b10);
	getContentPane().add(b11);
	getContentPane().add(b12);
	getContentPane().add(b13);
	getContentPane().add(b14);
	getContentPane().add(b15);
	getContentPane().add(b16);
	getContentPane().add(b17);
	getContentPane().add(b18);
	getContentPane().add(b19);
	getContentPane().add(b20);
	getContentPane().add(b21);
	getContentPane().add(b22);
	getContentPane().add(b23);
	getContentPane().add(b24);
	getContentPane().add(b25);
	getContentPane().add(b26);
	getContentPane().add(b27);
	getContentPane().add(b28);
	getContentPane().add(b29);
	getContentPane().add(b30);
	getContentPane().add(b31);
	getContentPane().add(b32);
	getContentPane().add(b33);
	getContentPane().add(b34);
	getContentPane().add(b35);
	getContentPane().add(b36);
	getContentPane().add(b37);
	getContentPane().add(b38);
	getContentPane().add(b39);
	getContentPane().add(p2);
	getContentPane().add(p8);
	getContentPane().add(p9);

}

public void actionPerformed(ActionEvent e) {
	if (e.getSource() == b4) {
		b4.setBackground(Color.red);
		b4.setText("OCUPADO");
		b4.setEnabled(false);
		
		
		
		label15.setText("1");
	}
	if (e.getSource() == b5) {
		b5.setBackground(Color.red);
		b5.setEnabled(false);
		b5.setText("OCUPADO");
	}
	if (e.getSource() == b6) {
		b6.setBackground(Color.red);
		b6.setEnabled(false);
		b6.setText("OCUPADO");
	}
	if (e.getSource() == b7) {
		b7.setBackground(Color.red);
		b7.setEnabled(false);
		b7.setText("OCUPADO");
	}
	if (e.getSource() == b8) {
		b8.setBackground(Color.red);
		b8.setEnabled(false);
		b8.setText("OCUPADO");
	}
	if (e.getSource() == b9) {
		b9.setBackground(Color.red);
		b9.setEnabled(false);
		b9.setText("OCUPADO");
	}
	if (e.getSource() == b10) {
		b10.setBackground(Color.red);
		b10.setEnabled(false);
		b10.setText("OCUPADO");
	}
	if (e.getSource() == b11) {
		b11.setBackground(Color.red);
		b11.setEnabled(false);
		b11.setText("OCUPADO");
	}
	if (e.getSource() == b12) {
		b12.setBackground(Color.red);
		b12.setEnabled(false);
		b12.setText("OCUPADO");
	}
	if (e.getSource() == b13){
		b13.setBackground(Color.red);
		b13.setEnabled(false);
		b13.setText("OCUPADO");
	}
	if (e.getSource() == b14) {
		b14.setBackground(Color.red);
		b14.setEnabled(false);
		b14.setText("OCUPADO");
	}
	if (e.getSource() == b15) {
		b15.setBackground(Color.red);
		b15.setEnabled(false);
		b15.setText("OCUPADO");
	}
	if (e.getSource() == b16) {
		b16.setBackground(Color.red);
		b16.setEnabled(false);
		b16.setText("OCUPADO");
	}
	if (e.getSource() == b17) {
		b17.setBackground(Color.red);
		b17.setEnabled(false);
		b17.setText("OCUPADO");
	}
	if (e.getSource() == b18) {
		b18.setBackground(Color.red);
		b18.setEnabled(false);
		b18.setText("OCUPADO");
	}
	if (e.getSource() == b19) {
		b19.setBackground(Color.red);
		b19.setEnabled(false);
		b19.setText("OCUPADO");
	}
	if (e.getSource() == b20) {
		b20.setBackground(Color.red);
		b20.setEnabled(false);
		b20.setText("OCUPADO");
	}
	if (e.getSource() == b21) {
		b21.setBackground(Color.red);
		b21.setEnabled(false);
		b21.setText("OCUPADO");
	}
	if (e.getSource() == b22) {
		b22.setBackground(Color.red);
		b22.setEnabled(false);
		b22.setText("OCUPADO");
	}
	if (e.getSource() == b23) {
		b23.setBackground(Color.red);
		b23.setEnabled(false);
		b23.setText("OCUPADO");
	}
	if (e.getSource() == b24) {
		b24.setBackground(Color.red);
		b24.setEnabled(false);
		b24.setText("OCUPADO");
	}
	if (e.getSource() == b25) {
		b25.setBackground(Color.red);
		b25.setEnabled(false);
		b25.setText("OCUPADO");
	}
	if (e.getSource() == b26) {
		b26.setBackground(Color.red);
		b26.setEnabled(false);
		b26.setText("OCUPADO");
	}
	if (e.getSource() == b27) {
		b27.setBackground(Color.red);
		b27.setEnabled(false);
		b27.setText("OCUPADO");
	}
	if (e.getSource() == b28) {
		b28.setBackground(Color.red);
		b28.setEnabled(false);
		b28.setText("OCUPADO");
	}
	if (e.getSource() == b29) {
		b29.setBackground(Color.red);
		b29.setEnabled(false);
		b29.setText("OCUPADO");
	}
	if (e.getSource() == b30) {
		b30.setBackground(Color.red);
		b30.setEnabled(false);
		b30.setText("OCUPADO");
	}
	if (e.getSource() == b31) {
		b31.setBackground(Color.red);
		b31.setEnabled(false);
		b31.setText("OCUPADO");
	}
	if (e.getSource() == b32) {
		b32.setBackground(Color.red);
		b32.setEnabled(false);
		b32.setText("OCUPADO");
	}
	if (e.getSource() == b33) {
		b33.setBackground(Color.red);
		b33.setEnabled(false);
		b33.setText("OCUPADO");
	}
	if (e.getSource() == b34) {
		b34.setBackground(Color.red);
		b34.setEnabled(false);
		b34.setText("OCUPADO");
	}
	if (e.getSource() == b35) {
		b35.setBackground(Color.red);
		b35.setEnabled(false);
		b35.setText("OCUPADO");
	}
	if (e.getSource() == b36) {
		b36.setBackground(Color.red);
		b36.setEnabled(false);
		b36.setText("OCUPADO");
	}
	if (e.getSource() == b37) {
		b37.setBackground(Color.red);
		b37.setEnabled(false);
		b37.setText("OCUPADO");
	}
	if (e.getSource() == b38) {
		b38.setBackground(Color.red);
		b38.setEnabled(false);
		b38.setText("OCUPADO");
	}
	if (e.getSource() == b39) {
		b39.setBackground(Color.red);
		b39.setEnabled(false);
		b39.setText("OCUPADO");
	}

}

}

Mensagens: 1

Participantes: 1

Ler tópico completo


Viewing all articles
Browse latest Browse all 33093


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>