package View_Pacote;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.security.auth.callback.TextOutputCallback;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Interface extends JFrame {
protected static final String I = null;
protected static final String E = null;
protected static final String O = null;
protected static final String U = null;
protected static final String A = null;
private JPanel contentPane;
private JTextField txtFrase;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Interface frame = new Interface();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Interface() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
txtFrase = new JTextField();
txtFrase.setBounds(168, 72, 86, 20);
contentPane.add(txtFrase);
txtFrase.setColumns(10);
JLabel lblText = new JLabel("Escreva uma Frase");
lblText.setBounds(63, 75, 91, 14);
contentPane.add(lblText);
JButton btnVogais = new JButton("Mostrar Vogais");
btnVogais.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String Frase = txtFrase.getText();
int Vogais;
char Texto;
Vogais = 0;
for (int i = 0; i < Frase.length(); i++ ) {
Frase.charAt(i);
if (Frase.charAt(i) == "a,e,i,o,u") {
Vogais = Vogais+1;
JOptionPane.showMessageDialog(null, "a quantidade de Vogais é "+ Vogais);
}
}
}
private String charAt(int i) {
return null;
// TODO Auto-generated method stub
}
});
btnVogais.setBounds(80, 165, 114, 23);
contentPane.add(btnVogais);
JButton btnTamanho = new JButton("Mostrar Tamanho");
btnTamanho.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String Frase = txtFrase.getText();
int Tamanho = Frase.length();
JOptionPane.showMessageDialog(null, "a frase tem " + Tamanho + " letras");
}
});
btnTamanho.setBounds(208, 165, 134, 23);
contentPane.add(btnTamanho);
}
}