Parte gráfica em Java
Publicado por Perfil removido 14/05/2005
[ Hits: 6.980 ]
Utilize um exemplo de como definir um pequeno formulario em Java, somente a parte grafica. A implementação do código, acesso a banco de dados ou eventos de botões ficam por conta de sua criatividade... ou posso colocar em outro Script futuramente.
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class CadastroFrame extends JFrame implements ActionListener{ private JPanel _mainPanel = null; public CadastroFrame(){ setTitle("Cadastro de Contatos: "); setSize(300,300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); initComponentes(); } private void initComponentes() { _mainPanel = new JPanel(); getContentPane().add(_mainPanel); _mainPanel.setLayout(new GridBagLayout()); addMenu(); addLabelNome(); addLabelTelefone(); addLabelEnd(); addTexFieldNome(); addTexFieldTelefone(); addTextFieldEndereço(); addButtonOK(); } private void addMenu() { JMenuBar menuBar = new JMenuBar(); JMenu menuArquivo = new JMenu("Arquivo"); JMenuItem menuItemSair = new JMenuItem("Sair"); menuItemSair.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.exit(0); } }); menuArquivo.add(menuItemSair); menuBar.add(menuArquivo); setJMenuBar(menuBar); } private void addLabelNome() { JLabel label = new JLabel("Nome:"); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; _mainPanel.add(label, gbc); } private void addLabelTelefone() { JLabel label = new JLabel("Telefone:"); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; _mainPanel.add(label, gbc); } private void addLabelEnd() { JLabel label = new JLabel("End.:"); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; _mainPanel.add(label, gbc); } private void addTexFieldNome() { JTextField textfield = new JTextField(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; textfield.setPreferredSize(new Dimension(100, 22)); _mainPanel.add(textfield, gbc); } private void addTexFieldTelefone() { JTextField textfield = new JTextField(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.fill = GridBagConstraints.HORIZONTAL; _mainPanel.add(textfield, gbc); } private void addTextFieldEndereço() { JTextField textfield = new JTextField(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.fill = GridBagConstraints.HORIZONTAL; _mainPanel.add(textfield, gbc); } private void addButtonOK() { JButton button = new JButton("OK"); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; gbc.gridwidth = 2; _mainPanel.add(button, gbc); } public static void main(String[] args) { new CadastroFrame().setVisible(true); } public void actionPerformed(ActionEvent arg0) { //năo foi implementado o método } }
Retorno de nomes (com gráficos)
Caixa eletrônico usando a classe Hashtable
Calcular horas faltas de um funcionário
Nenhum comentário foi encontrado.
Atençăo a quem posta conteúdo de dicas, scripts e tal (6)
Como Configurar um Túnel SSH Reverso para Acessar Sua Máquina Local a Partir de uma Máquina Remota
Configuração para desligamento automatizado de Computadores em um Ambiente Comercial
O mínimo que você precisa saber sobre o terminal (parte 2)
O mínimo que você precisa saber sobre o terminal (parte 1)
Como iniciar uma máquina virtual do VirtualBox automaticamente no boot do LUbuntu 18 LTS
Flatpak: remover runtimes năo usados e pacotes
Mudar o gerenciador de login (GDM para SDDM e vice-versa) - parte 2
Como deixar as abas do Firefox mais fininhas
Mudar o gerenciador de login (GDM para SDDM)
"Tentando" fazer com que programas rodem no Wayland e no X11
[Python] Automaçăo de scan de vulnerabilidades
[Python] Script para analise de superficie de ataque
[Shell Script] Novo script para redimensionar, rotacionar, converter e espelhar arquivos de imagem
[Shell Script] Iniciador de DOOM (DSDA-DOOM, Doom Retro ou Woof!)
[Shell Script] Script para adicionar bordas ŕs imagens de uma pasta