AJBM Posted July 16, 2012 at 01:20 PM Report Share #468859 Posted July 16, 2012 at 01:20 PM Boas! Eu queria fazer uma interface gráfica simples, com uma área de texto e dois botões, mas quando clicasse num dos botões abrisse outra janela.Tipo como um botão seguinte Alguem me pode ajudar Link to comment Share on other sites More sharing options...
jpedro20 Posted July 16, 2012 at 05:50 PM Report Share #468902 Posted July 16, 2012 at 05:50 PM Procura por CardLayout Link to comment Share on other sites More sharing options...
Guest skinie18 Posted July 18, 2012 at 10:28 AM Report Share #469114 Posted July 18, 2012 at 10:28 AM NetBeans Tem um creador automático de Interfaces. Cria um novo projecto e depois crias uma nova Frame e na frame ele deixa-te arrastar componentes para lá, e programa-los Link to comment Share on other sites More sharing options...
AJBM Posted July 19, 2012 at 08:33 AM Author Report Share #469228 Posted July 19, 2012 at 08:33 AM Obrigado já consegui fazer. 👍 Agora tenho outra duvida ainda na parte gráfica. Eu queria que quando eu clicasse num botão, a seguir aparecessem mais botões em baixo, e quando clicasse no botão que cliquei anteriormente, os botões que apareceram desaparecessem. Nao sei se estou a explicar bem, mas se perceberem podem me dar alguma dica? Link to comment Share on other sites More sharing options...
Flinger Posted July 19, 2012 at 10:53 AM Report Share #469239 Posted July 19, 2012 at 10:53 AM Podes criar um panel, onde colocas os novos botões. Esse panel não está visível por defeito, e quando clicas no botão, o método executado torna este panel visível. Assim evitas estar a mexer no campo visible dos vários botões. Link to comment Share on other sites More sharing options...
AJBM Posted July 19, 2012 at 12:01 PM Author Report Share #469240 Posted July 19, 2012 at 12:01 PM O que estas a dizer e que quando carrego no botão sou encaminhado para outro painel e ai estão os novos botões certo? Eu já sei fazer isso. Agora eu queria fazer no mesmo painel clico num botão, aparecem mais nesse mesmo painel. Link to comment Share on other sites More sharing options...
Rui Carlos Posted July 19, 2012 at 09:55 PM Report Share #469289 Posted July 19, 2012 at 09:55 PM Convinha dizeres que biblioteca/framework/... estás a usar. E não estou muito bem a ver qual o problema de ter um painel separado. Muito provavelmente também consegues fazer tudo no mesmo painel, mas para o utilizador da aplicação, tal é irrelevante, pois ele regra geral não vê os painéis. Rui Carlos Gonçalves Link to comment Share on other sites More sharing options...
AJBM Posted July 20, 2012 at 08:28 PM Author Report Share #469434 Posted July 20, 2012 at 08:28 PM Boas. Não tem nenhum problema em ter um painel separado, só que eu queria ver se consegui fazer no mesmo painel. Por exemplo eu tenho duas funcionalidade que é alterar nome, e alterar password, e eu queria fazer assim Alterar dados na interface principal, depois carregava em alterar dados e em baixo aparecia alterar nome alterar password e quando clicasse num deles ia para outro painel, era esta a minha ideia. Estou a utilizar arrays. Link to comment Share on other sites More sharing options...
Guest skinie18 Posted July 21, 2012 at 03:26 AM Report Share #469468 Posted July 21, 2012 at 03:26 AM (edited) Agora so precisas construir os painéis alterauser e alterapass. Podes colar isso no teu programa de codificação que funciona direito. SO nao tem os alterauser e alterapass preenchidos.. import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.event.*; import javax.swing.*; public class NewClass extends JFrame { private JButton user, pass; private JPanel alterauser, alterapass; public NewClass() { // -- Criar os buttons -- user = new JButton("Alterar nome de utilizador!"); pass = new JButton("Alterar palavra pass!"); // -- Inicia os paineis em modo oculto -- alterauser = new JPanel(); alterauser.setVisible(false); alterapass = new JPanel(); alterapass.setVisible(false); // -- Criar um painel para meter os buttons -- JPanel header = new JPanel(); header.add(user); header.add(pass); // -- Programar o que os botoes fazem quando clica neles -- user.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { // -- Codigo que vai ser feito no click -- alterauser.setVisible(true); // o painel de alterar user vai ficar visivel } }); pass.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { // -- Codigo que vai ser feito no click -- alterapass.setVisible(true); // o painel de alterar pass vai ficar visivel } }); // -- Painel que agrupa os 2 paineis de editar (nao é obrigatório so fica mais bonito) -- JPanel center_panel = new JPanel(new GridLayout(0,1)); center_panel.add(alterauser); center_panel.add(alterapass); // -- Add os buttons a interface -- add(BorderLayout.NORTH, header); add(BorderLayout.CENTER, center_panel); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Fechar quanco clicar na cruz setSize(500, 420); // tamanho da janela setLocationRelativeTo(null); // aparecer ao centro do ecra setVisible(true); // aparecer uma janela } } Edited July 21, 2012 at 03:27 AM by skinie18 Link to comment Share on other sites More sharing options...
AJBM Posted July 21, 2012 at 12:15 PM Author Report Share #469497 Posted July 21, 2012 at 12:15 PM Boas! Eu para programar a parte gráfica arrasto os botões e depois digo o que eu quero que eles façam. Ao fazer isto é criado @SuppressWarnings("unchecked") e já tentei acrescentar aqui dentro mas não da, também copiei o teu código para antes disto e da-me erros. Onde é que tenho de acrescentar esta parte de código Link to comment Share on other sites More sharing options...
Guest skinie18 Posted July 21, 2012 at 02:28 PM Report Share #469523 Posted July 21, 2012 at 02:28 PM Pois, é que eu estou nesse exemplo estou a fazer o codigo a mao, tu fizeste o codigo com a ajuda de um programa qualquer. Manda o codigo que o teu programa gerou para a tua interface grafica para eu ver. Link to comment Share on other sites More sharing options...
AJBM Posted July 21, 2012 at 03:31 PM Author Report Share #469531 Posted July 21, 2012 at 03:31 PM Não posso juntar código a mão e código feito pelo programa? @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jPanelDisplay = new javax.swing.JPanel(); jPanelLogin = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextAreaLoginNome = new javax.swing.JTextArea(); jPasswordFieldLoginPassword = new javax.swing.JPasswordField(); jButtonLoginLogin = new javax.swing.JButton(); jButtonRegistar = new javax.swing.JButton(); jPanelAluno = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); jTextAreaAlunoNome = new javax.swing.JTextArea(); jButtonAlunoLogout = new javax.swing.JButton(); jButtonAlunoAlterarPassword = new javax.swing.JButton(); jButtonAlunoAlterarNome = new javax.swing.JButton(); jScrollPane6 = new javax.swing.JScrollPane(); jTextAreaAlunoAlterar = new javax.swing.JTextArea(); jButtonAlunoConsultarNotas = new javax.swing.JButton(); jPanelDocente = new javax.swing.JPanel(); jScrollPane7 = new javax.swing.JScrollPane(); jTextAreaDocenteNome = new javax.swing.JTextArea(); jButtonDocenteListarAlunos = new javax.swing.JButton(); jScrollPane8 = new javax.swing.JScrollPane(); jTextAreaDocenteListar = new javax.swing.JTextArea(); jButtonDocenteAdicionarNota = new javax.swing.JButton(); jScrollPane9 = new javax.swing.JScrollPane(); jTextAreaDocentePosicao = new javax.swing.JTextArea(); jScrollPane10 = new javax.swing.JScrollPane(); jTextAreaDocenteNota = new javax.swing.JTextArea(); jPanelRegistar = new javax.swing.JPanel(); jLabelRegistarNome = new javax.swing.JLabel(); jLabelRegistarNumero = new javax.swing.JLabel(); jScrollPane4 = new javax.swing.JScrollPane(); jTextAreaRegistarNumero = new javax.swing.JTextArea(); jScrollPane3 = new javax.swing.JScrollPane(); jTextAreaRegistarNome = new javax.swing.JTextArea(); jLabelRegistarPassword = new javax.swing.JLabel(); jScrollPane5 = new javax.swing.JScrollPane(); jTextAreaRegistarPassword = new javax.swing.JTextArea(); jButtonResgistarRegistar = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Paradigmas da Programacao"); jPanelDisplay.setLayout(new java.awt.CardLayout()); jPanelLogin.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); jPanelLogin.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION); jLabel1.setText("Nome"); jLabel2.setText("Password"); jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); jTextAreaLoginNome.setColumns(20); jTextAreaLoginNome.setRows(5); jScrollPane1.setViewportView(jTextAreaLoginNome); jButtonLoginLogin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/login/images.jpg"))); // NOI18N jButtonLoginLogin.setText("Login"); jButtonLoginLogin.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonLoginLoginActionPerformed(evt); } }); jButtonRegistar.setText("Registar"); jButtonRegistar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonRegistarActionPerformed(evt); } }); javax.swing.GroupLayout jPanelLoginLayout = new javax.swing.GroupLayout(jPanelLogin); jPanelLogin.setLayout(jPanelLoginLayout); jPanelLoginLayout.setHorizontalGroup( jPanelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelLoginLayout.createSequentialGroup() .addGap(30, 30, 30) .addGroup(jPanelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanelLoginLayout.createSequentialGroup() .addComponent(jLabel2) .addGap(60, 60, 60) .addComponent(jPasswordFieldLoginPassword)) .addGroup(jPanelLoginLayout.createSequentialGroup() .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelLoginLayout.createSequentialGroup() .addGap(29, 29, 29) .addComponent(jButtonLoginLogin) .addGap(63, 63, 63) .addComponent(jButtonRegistar) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(jPanelLoginLayout.createSequentialGroup() .addGap(37, 37, 37) .addComponent(jScrollPane1))))) .addContainerGap(116, Short.MAX_VALUE)) ); jPanelLoginLayout.setVerticalGroup( jPanelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelLoginLayout.createSequentialGroup() .addGroup(jPanelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelLoginLayout.createSequentialGroup() .addGap(81, 81, 81) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanelLoginLayout.createSequentialGroup() .addGap(82, 82, 82) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(73, 73, 73) .addGroup(jPanelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPasswordFieldLoginPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 70, Short.MAX_VALUE) .addGroup(jPanelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButtonLoginLogin) .addComponent(jButtonRegistar)) .addGap(38, 38, 38)) ); jPanelDisplay.add(jPanelLogin, "Login"); jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); jTextAreaAlunoNome.setBackground(new java.awt.Color(240, 240, 240)); jTextAreaAlunoNome.setColumns(20); jTextAreaAlunoNome.setRows(5); jTextAreaAlunoNome.setBorder(null); jTextAreaAlunoNome.addAncestorListener(new javax.swing.event.AncestorListener() { public void ancestorMoved(javax.swing.event.AncestorEvent evt) { } public void ancestorAdded(javax.swing.event.AncestorEvent evt) { jTextAreaAlunoNomeAncestorAdded(evt); } public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { } }); jScrollPane2.setViewportView(jTextAreaAlunoNome); jButtonAlunoLogout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/login/icon_sair.jpg"))); // NOI18N jButtonAlunoLogout.setText("Logout"); jButtonAlunoLogout.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonAlunoLogoutActionPerformed(evt); } }); jButtonAlunoAlterarPassword.setText("Alterar Password"); jButtonAlunoAlterarPassword.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonAlunoAlterarPasswordActionPerformed(evt); } }); jButtonAlunoAlterarNome.setText("Alterar Nome"); jButtonAlunoAlterarNome.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonAlunoAlterarNomeActionPerformed(evt); } }); jScrollPane6.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane6.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); jTextAreaAlunoAlterar.setColumns(20); jTextAreaAlunoAlterar.setRows(5); jScrollPane6.setViewportView(jTextAreaAlunoAlterar); jButtonAlunoConsultarNotas.setText("Consultar Notas"); javax.swing.GroupLayout jPanelAlunoLayout = new javax.swing.GroupLayout(jPanelAluno); jPanelAluno.setLayout(jPanelAlunoLayout); jPanelAlunoLayout.setHorizontalGroup( jPanelAlunoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelAlunoLayout.createSequentialGroup() .addGroup(jPanelAlunoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanelAlunoLayout.createSequentialGroup() .addGroup(jPanelAlunoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jButtonAlunoLogout, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButtonAlunoAlterarPassword, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButtonAlunoAlterarNome, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButtonAlunoConsultarNotas, javax.swing.GroupLayout.Alignment.LEADING)) .addGap(79, 79, 79) .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(83, Short.MAX_VALUE)) ); jPanelAlunoLayout.setVerticalGroup( jPanelAlunoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelAlunoLayout.createSequentialGroup() .addGap(4, 4, 4) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(62, 62, 62) .addGroup(jPanelAlunoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanelAlunoLayout.createSequentialGroup() .addComponent(jButtonAlunoAlterarPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonAlunoAlterarNome, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(12, 12, 12) .addComponent(jButtonAlunoConsultarNotas, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButtonAlunoLogout))) .addGap(0, 98, Short.MAX_VALUE)) ); jPanelDisplay.add(jPanelAluno, "interface"); jScrollPane7.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane7.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); jTextAreaDocenteNome.setBackground(new java.awt.Color(240, 240, 240)); jTextAreaDocenteNome.setColumns(20); jTextAreaDocenteNome.setRows(5); jScrollPane7.setViewportView(jTextAreaDocenteNome); jButtonDocenteListarAlunos.setText("Listar Alunos"); jButtonDocenteListarAlunos.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonDocenteListarAlunosActionPerformed(evt); } }); jTextAreaDocenteListar.setColumns(20); jTextAreaDocenteListar.setRows(5); jScrollPane8.setViewportView(jTextAreaDocenteListar); jButtonDocenteAdicionarNota.setText("Adicionar Nota"); jButtonDocenteAdicionarNota.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonDocenteAdicionarNotaActionPerformed(evt); } }); jScrollPane9.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane9.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); jTextAreaDocentePosicao.setColumns(20); jTextAreaDocentePosicao.setRows(5); jScrollPane9.setViewportView(jTextAreaDocentePosicao); jScrollPane10.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane10.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); jTextAreaDocenteNota.setColumns(20); jTextAreaDocenteNota.setRows(5); jScrollPane10.setViewportView(jTextAreaDocenteNota); javax.swing.GroupLayout jPanelDocenteLayout = new javax.swing.GroupLayout(jPanelDocente); jPanelDocente.setLayout(jPanelDocenteLayout); jPanelDocenteLayout.setHorizontalGroup( jPanelDocenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelDocenteLayout.createSequentialGroup() .addGroup(jPanelDocenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelDocenteLayout.createSequentialGroup() .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(jPanelDocenteLayout.createSequentialGroup() .addContainerGap() .addGroup(jPanelDocenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelDocenteLayout.createSequentialGroup() .addGroup(jPanelDocenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jButtonDocenteListarAlunos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButtonDocenteAdicionarNota, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(76, 76, 76)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelDocenteLayout.createSequentialGroup() .addGroup(jPanelDocenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE))) .addGap(0, 10, 10)) ); jPanelDocenteLayout.setVerticalGroup( jPanelDocenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelDocenteLayout.createSequentialGroup() .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(51, 51, 51) .addComponent(jButtonDocenteListarAlunos) .addGap(30, 30, 30) .addComponent(jButtonDocenteAdicionarNota) .addGap(18, 18, 18) .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(jPanelDocenteLayout.createSequentialGroup() .addGap(57, 57, 57) .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE) .addContainerGap()) ); jPanelDisplay.add(jPanelDocente, "docente"); jLabelRegistarNome.setText("Nome"); jLabelRegistarNumero.setText("Numero"); jScrollPane4.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane4.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); jTextAreaRegistarNumero.setColumns(20); jTextAreaRegistarNumero.setRows(5); jScrollPane4.setViewportView(jTextAreaRegistarNumero); jScrollPane3.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane3.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); jTextAreaRegistarNome.setColumns(20); jTextAreaRegistarNome.setRows(5); jScrollPane3.setViewportView(jTextAreaRegistarNome); jLabelRegistarPassword.setText("Password"); jScrollPane5.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane5.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); jTextAreaRegistarPassword.setColumns(20); jTextAreaRegistarPassword.setRows(5); jScrollPane5.setViewportView(jTextAreaRegistarPassword); jButtonResgistarRegistar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/login/images.jpg"))); // NOI18N jButtonResgistarRegistar.setText("Registar"); jButtonResgistarRegistar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonResgistarRegistarActionPerformed(evt); } }); javax.swing.GroupLayout jPanelRegistarLayout = new javax.swing.GroupLayout(jPanelRegistar); jPanelRegistar.setLayout(jPanelRegistarLayout); jPanelRegistarLayout.setHorizontalGroup( jPanelRegistarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelRegistarLayout.createSequentialGroup() .addGroup(jPanelRegistarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelRegistarLayout.createSequentialGroup() .addGap(21, 21, 21) .addGroup(jPanelRegistarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabelRegistarNome, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabelRegistarNumero) .addComponent(jLabelRegistarPassword)) .addGap(57, 57, 57) .addGroup(jPanelRegistarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(jPanelRegistarLayout.createSequentialGroup() .addGap(177, 177, 177) .addComponent(jButtonResgistarRegistar))) .addContainerGap(129, Short.MAX_VALUE)) ); jPanelRegistarLayout.setVerticalGroup( jPanelRegistarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelRegistarLayout.createSequentialGroup() .addGap(66, 66, 66) .addGroup(jPanelRegistarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabelRegistarNome, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addGroup(jPanelRegistarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelRegistarLayout.createSequentialGroup() .addGap(35, 35, 35) .addComponent(jLabelRegistarNumero)) .addGroup(jPanelRegistarLayout.createSequentialGroup() .addGap(26, 26, 26) .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(50, 50, 50) .addGroup(jPanelRegistarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabelRegistarPassword) .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE) .addComponent(jButtonResgistarRegistar) .addGap(45, 45, 45)) ); jPanelDisplay.add(jPanelRegistar, "registar"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanelDisplay, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanelDisplay, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); pack(); }// </editor-fold> Link to comment Share on other sites More sharing options...
Guest skinie18 Posted July 21, 2012 at 09:20 PM Report Share #469588 Posted July 21, 2012 at 09:20 PM Abre isto com o NetBeans http://d.pr/f/iSZ8 Fiz um exemplo de como fazes o que tu queres. O que tu queres sao eventos. Quando fazes a interface gráfica se clicares 2 vezes no botao que criaste ele abre-te o codigo. E o codigo que te abre é numa class ActionListener, tudo que meteres dentro desse método só acontece quando clicas no botao. Mas devias aprender a programar interface grafica só por codigo, como reparaste o mesmo que te enviei agora enviei-te lá em sima com menos de metade das linhas que vais usar. Link to comment Share on other sites More sharing options...
AJBM Posted July 22, 2012 at 11:08 AM Author Report Share #469639 Posted July 22, 2012 at 11:08 AM (edited) Boas! Obrigado skinie18 👍 . Conheces algum tutorial fixe sobre a parte gráfica? Edited July 22, 2012 at 11:09 AM by AJBM Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now