Import Java.Awt.Eventqueue;
Total Page:16
File Type:pdf, Size:1020Kb
import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import javax.swing.JTextArea; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import javax.swing.JTextField; import javax.swing.JScrollPane; import java.awt.Font; import javax.swing.JLabel; import javax.swing.JComboBox; import javax.swing.DefaultComboBoxModel; import javax.swing.JSeparator; public class Colecoes extends JFrame {
/** * */ private static final long serialVersionUID = -7275882428847114650L; private JPanel contentPane; private JTextArea listagemEntrada = new JTextArea(); private ArrayList
/** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Colecoes frame = new Colecoes(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public Colecoes() { tfDisjoint.setFont(new Font("Tahoma", Font.PLAIN, 10)); tfDisjoint.setBounds(167, 605, 67, 20); tfDisjoint.setColumns(10); tfFrequency.setFont(new Font("Tahoma", Font.PLAIN, 10)); tfFrequency.setBounds(197, 574, 37, 20); tfFrequency.setColumns(10); tfLastIndexOfSubList.setFont(new Font("Tahoma", Font.PLAIN, 10)); tfLastIndexOfSubList.setBounds(167, 543, 67, 20); tfLastIndexOfSubList.setColumns(10); tfIndexOfSubList.setFont(new Font("Tahoma", Font.PLAIN, 10)); tfIndexOfSubList.setBounds(167, 512, 67, 20); tfIndexOfSubList.setColumns(10); tfFill.setBounds(197, 450, 37, 20); tfFill.setColumns(10); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(300, 10, 507, 738); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null);
JButton btnEntraValor = new JButton("+"); btnEntraValor.setFont(new Font("Tahoma", Font.PLAIN, 7)); btnEntraValor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) {
listagemEntrada.append(tfEntrada.getText()+"\n"); lista1.add(tfEntrada.getText()); tfEntrada.setText(""); tfEntrada.requestFocusInWindow();
} }); btnEntraValor.setBounds(111, 83, 46, 23); contentPane.add(btnEntraValor); scrollPane.setBounds(276, 247, 181, 141);
contentPane.add(scrollPane); scrollPane.setViewportView(listagemSaida); btnListaEntrada.setFont(new Font("Tahoma", Font.PLAIN, 10)); btnListaEntrada.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { listagemSaida.setText(""); for (String str : lista1) { listagemSaida.append(str+"\n"); } } }); btnListaEntrada.setBounds(21, 234, 136, 23); contentPane.add(btnListaEntrada); btnListaSaida.setFont(new Font("Tahoma", Font.PLAIN, 10)); btnListaSaida.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { listagemEntrada.setText(""); listagemSaida.setText(""); Iterator
} }); btnListaSaida.setBounds(21, 136, 136, 21); contentPane.add(btnListaSaida); tfEntrada = new JTextField(); tfEntrada.setBounds(21, 82, 80, 23); contentPane.add(tfEntrada); tfEntrada.setColumns(10); btnSair.setFont(new Font("Tahoma", Font.PLAIN, 10)); btnSair.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); btnSair.setBounds(416, 666, 65, 23); contentPane.add(btnSair); btnSort.setToolTipText("Ordena\u00E7\u00E3o crescente"); btnSort.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { listagemSaida.setText(""); ArrayList
JLabel lblDigiteUmCaractere = new JLabel("Valor"); lblDigiteUmCaractere.setBounds(21, 54, 37, 17); contentPane.add(lblDigiteUmCaractere);
JLabel lblNewLabel = new JLabel("Valor(es) entrado(s)"); lblNewLabel.setBounds(276, 11, 118, 14); contentPane.add(lblNewLabel);
JLabel lblResultado = new JLabel("Resultado"); lblResultado.setBounds(276, 222, 80, 14); contentPane.add(lblResultado);
JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setBounds(278, 36, 179, 151); contentPane.add(scrollPane_1); scrollPane_1.setViewportView(listagemEntrada); listagemEntrada.setColumns(15); JButton btnShuffle = new JButton("Shuffle"); btnShuffle.setToolTipText("Ordena\u00E7\u00E3o aleat\u00F3ria"); btnShuffle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { listagemSaida.setText(""); ArrayList
JSeparator separator = new JSeparator(); separator.setBounds(21, 209, 436, 2); contentPane.add(separator); JButton btnReverse = new JButton("Reverse"); btnReverse.setFont(new Font("Tahoma", Font.PLAIN, 10)); btnReverse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { listagemSaida.setText(""); ArrayList
}); btnReplaceAll.setFont(new Font("Tahoma", Font.PLAIN, 10)); btnReplaceAll.setBounds(21, 419, 87, 23); contentPane.add(btnReplaceAll); tfOcorrencia = new JTextField(); tfOcorrencia.setFont(new Font("Tahoma", Font.PLAIN, 10)); tfOcorrencia.setBounds(120, 419, 37, 20); contentPane.add(tfOcorrencia); tfOcorrencia.setColumns(10);
JLabel lblNewLabel_1 = new JLabel("por"); lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 10)); lblNewLabel_1.setBounds(167, 419, 29, 20); contentPane.add(lblNewLabel_1); tfNovoValor = new JTextField(); tfNovoValor.setFont(new Font("Tahoma", Font.PLAIN, 10)); tfNovoValor.setBounds(197, 419, 37, 20); contentPane.add(tfNovoValor); tfNovoValor.setColumns(10); btnFill.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { listagemSaida.setText(""); ArrayList
JButton btnIndexOfSubList = new JButton("IndexOfSubList"); btnIndexOfSubList.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { listagemSaida.setText(""); String[] arr = tfIndexOfSubList.getText().split( "," ); ArrayList
JLabel label = new JLabel(">>"); label.setFont(new Font("Tahoma", Font.PLAIN, 10)); label.setBounds(168, 481, 29, 20); contentPane.add(label); tfBinarySearch = new JTextField(); tfBinarySearch.setFont(new Font("Tahoma", Font.PLAIN, 10)); tfBinarySearch.setBounds(197, 481, 37, 20); contentPane.add(tfBinarySearch); tfBinarySearch.setColumns(10); label_1.setFont(new Font("Tahoma", Font.PLAIN, 10)); label_1.setBounds(168, 450, 29, 20); contentPane.add(label_1); contentPane.add(tfIndexOfSubList); lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 10)); lblNewLabel_2.setBounds(239, 515, 93, 14); contentPane.add(lblNewLabel_2); btnLastIndexOfSubList.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { listagemSaida.setText(""); String[] arr = tfLastIndexOfSubList.getText().split( "," ); ArrayList
btnMax.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { listagemSaida.setText(""); String max = Collections.max (lista1); listagemSaida.setText("Maior valor: " + max); } }); btnMax.setFont(new Font("Tahoma", Font.PLAIN, 10)); btnMax.setBounds(21, 667, 136, 20);
contentPane.add(btnMax); } }