Hace poco tiempo me meti con las interfaces graficas en java, usando netbeans (5.5), y no se mucho de usar cosas junto con las interfaces graficas, bueno, el problema es el siguiente, hoy me he puesto a hacer un MSN simulado y encima cutre , y tengo varios problemas a la hora de hacer cosillas, aqui os pongo los problemas:
Código:
Al hacer la lista de contactos, no se como se hace una tabla o como seria de agregar una fila o quitarla
No se poner imagenes
No se si se pueden poner imagenes de fondo en los JPanel, JText, JSelectBox, etc, y si se pone como se haria
No se si utilizo bien la accion de un JText para que actualize el nick o cualquier String o variable de ejemplar (o algo)
Y creo que nada mas.
Bueno, a continuacion os pongo el codigo del "programa" y el link con las instrucciones para ejecutar el .jar:
Código:
package wmsn;
import java.awt.event.*;
import javax.swing.*;
public class escritorio extends JFrame {
// VARIABLES DE EJEMPLAR ________________________________________________________________
String wmsnCFG_Nick;
String wmsnCFG_PMessage;
String wmsnCFG_Status;
String wmsnCFG_C_Say;
String wmsnCFG_C_MsgSent;
String wmsnCFG_C_ClrMsg;
String wmsnCFG_C_ConvAd;
String wmsnCFG_C_JMsgrTitle;
String wmsnCFG_C_CWindowTitle;
/** Creates new form escritorio */
public escritorio() {
initComponents();
// Configuracion de los textos...
// Configuracion del perfil
wmsnCFG_Nick = "The Sixth Halcon";
wmsnCFG_PMessage = "Este es mi mensaje personal";
String wmsnCFG_Status = "Conectado";
// Configuracion de otros textos
wmsnCFG_C_Say = " dice:";
wmsnCFG_C_MsgSent = "Mensaje enviado";
wmsnCFG_C_ClrMsg = "Texto borrado";
wmsnCFG_C_ConvAd = "No revele sus contraseñas a nadie. \n" +
"______________________________";
wmsnCFG_C_JMsgrTitle = " - Java Messenger";
wmsnCFG_C_CWindowTitle = "Contactos";
// Configuracion media...
int L_PMsg = wmsnCFG_PMessage.length();
String a = "";
if (!(L_PMsg <= 97)){
L_PMsg = 97;
a = "...";
} //Fin if
wmsnCFG_PMessage = wmsnCFG_PMessage.substring(0, L_PMsg)+a;
// Configurando las ventanas...
// Ventana de contactos
wmsnContactsWindow.setTitle(wmsnCFG_C_CWindowTitle);
wmsnNick.setText(wmsnCFG_Nick);
wmsnPersonalMessage.setText(wmsnCFG_PMessage);
wmsnStatus.setText(wmsnCFG_Status);
// Ventana de conversacion
wmsnChatWindow.setTitle(wmsnCFG_Nick+" -|"+wmsnCFG_Status+"|- "+wmsnCFG_C_JMsgrTitle);
wmsn_T_PersonalMessage.setText(wmsnCFG_PMessage);
wmsnConversation.setText(wmsnCFG_C_ConvAd);
}
// INICIO DE LOS METODOS ________________________________________________________________
public void sendMessage(){
String t = wmsnText.getText();
String x = wmsnConversation.getText();
wmsnConversation.setText(x+"\n"+wmsnCFG_Nick+wmsnCFG_C_Say+"\n"+t);
wmsnText.setText("");
wmsnConsole.setText(wmsnCFG_C_MsgSent);
}
public void clearInput(){
wmsnText.setText("");
wmsnConsole.setText(wmsnCFG_C_ClrMsg);
}
public void changeNick(){
String a = wmsnNick.getText();
wmsnCFG_Nick = a;
}
public void changePMsg(){
String a = wmsnPersonalMessage.getText();
wmsnCFG_PMessage = a;
}
public void changeStatus(){
String a = wmsnStatus.getText();
wmsnCFG_Status = a;
}
// FIN DE LOS METODOS ___________________________________________________________________
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
wmsnChatWindow = new javax.swing.JInternalFrame();
jScrollPane1 = new javax.swing.JScrollPane();
wmsnConversation = new javax.swing.JTextArea();
jScrollPane2 = new javax.swing.JScrollPane();
wmsnText = new javax.swing.JTextArea();
wmsnSend = new javax.swing.JButton();
wmsn_T_PersonalMessage = new javax.swing.JLabel();
wmsnConsole = new javax.swing.JTextField();
wmsnClearInput = new javax.swing.JButton();
wmsnContactsWindow = new javax.swing.JInternalFrame();
wmsn_JP_ProfileConfiguration = new javax.swing.JPanel();
wmsnNick = new javax.swing.JTextField();
wmsnPersonalMessage = new javax.swing.JTextField();
wmsn_JP_Photo = new javax.swing.JPanel();
wmsnStatus = new javax.swing.JTextField();
wmsn_JP_ContactList = new javax.swing.JPanel();
jTextField1 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
wmsnGeneralMenu = new javax.swing.JMenu();
wmsn_GM_Exit = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("CutreMSN");
wmsnChatWindow.setIconifiable(true);
wmsnChatWindow.setMaximizable(true);
wmsnChatWindow.setVisible(true);
wmsnConversation.setColumns(20);
wmsnConversation.setEditable(false);
wmsnConversation.setRows(5);
jScrollPane1.setViewportView(wmsnConversation);
wmsnText.setColumns(20);
wmsnText.setRows(5);
jScrollPane2.setViewportView(wmsnText);
wmsnSend.setText("Enviar");
wmsnSend.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
wmsnSendActionPerformed(evt);
}
});
wmsn_T_PersonalMessage.setForeground(new java.awt.Color(153, 153, 153));
wmsnConsole.setBackground(new java.awt.Color(235, 233, 237));
wmsnConsole.setEditable(false);
wmsnConsole.setForeground(new java.awt.Color(153, 153, 153));
wmsnConsole.setMargin(new java.awt.Insets(0, 0, 0, 0));
wmsnClearInput.setText("Borrar");
wmsnClearInput.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
wmsnClearInputActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout wmsnChatWindowLayout = new org.jdesktop.layout.GroupLayout(wmsnChatWindow.getContentPane());
wmsnChatWindow.getContentPane().setLayout(wmsnChatWindowLayout);
wmsnChatWindowLayout.setHorizontalGroup(
wmsnChatWindowLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, wmsnConsole, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 609, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.TRAILING, wmsnChatWindowLayout.createSequentialGroup()
.addContainerGap()
.add(wmsnChatWindowLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE)
.add(wmsnChatWindowLayout.createSequentialGroup()
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(wmsnChatWindowLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(wmsnClearInput, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
.add(wmsnSend, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)))
.add(org.jdesktop.layout.GroupLayout.LEADING, wmsn_T_PersonalMessage, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE))
.addContainerGap())
);
wmsnChatWindowLayout.setVerticalGroup(
wmsnChatWindowLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(wmsnChatWindowLayout.createSequentialGroup()
.add(wmsn_T_PersonalMessage)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(wmsnChatWindowLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 103, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(org.jdesktop.layout.GroupLayout.TRAILING, wmsnChatWindowLayout.createSequentialGroup()
.add(wmsnSend, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(wmsnClearInput)))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(wmsnConsole, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
);
wmsnContactsWindow.setIconifiable(true);
wmsnContactsWindow.setVisible(true);
wmsn_JP_ProfileConfiguration.setBackground(new java.awt.Color(255, 255, 255));
wmsn_JP_ProfileConfiguration.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
wmsnNick.setBackground(new java.awt.Color(235, 233, 237));
wmsnNick.setMargin(new java.awt.Insets(0, 0, 0, 0));
wmsnPersonalMessage.setBackground(new java.awt.Color(235, 233, 237));
wmsnPersonalMessage.setMargin(new java.awt.Insets(0, 0, 0, 0));
wmsn_JP_Photo.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
org.jdesktop.layout.GroupLayout wmsn_JP_PhotoLayout = new org.jdesktop.layout.GroupLayout(wmsn_JP_Photo);
wmsn_JP_Photo.setLayout(wmsn_JP_PhotoLayout);
wmsn_JP_PhotoLayout.setHorizontalGroup(
wmsn_JP_PhotoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 69, Short.MAX_VALUE)
);
wmsn_JP_PhotoLayout.setVerticalGroup(
wmsn_JP_PhotoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 66, Short.MAX_VALUE)
);
wmsnStatus.setBackground(new java.awt.Color(235, 233, 237));
wmsnStatus.setMargin(new java.awt.Insets(0, 0, 0, 0));
org.jdesktop.layout.GroupLayout wmsn_JP_ProfileConfigurationLayout = new org.jdesktop.layout.GroupLayout(wmsn_JP_ProfileConfiguration);
wmsn_JP_ProfileConfiguration.setLayout(wmsn_JP_ProfileConfigurationLayout);
wmsn_JP_ProfileConfigurationLayout.setHorizontalGroup(
wmsn_JP_ProfileConfigurationLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, wmsn_JP_ProfileConfigurationLayout.createSequentialGroup()
.add(wmsn_JP_Photo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(wmsn_JP_ProfileConfigurationLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(wmsnStatus, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 162, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(wmsnNick, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE)
.add(wmsnPersonalMessage, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE)))
);
wmsn_JP_ProfileConfigurationLayout.setVerticalGroup(
wmsn_JP_ProfileConfigurationLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(wmsn_JP_ProfileConfigurationLayout.createSequentialGroup()
.add(wmsn_JP_ProfileConfigurationLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(wmsn_JP_ProfileConfigurationLayout.createSequentialGroup()
.add(wmsnNick, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(wmsnPersonalMessage, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(wmsnStatus, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(wmsn_JP_Photo, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
wmsn_JP_ContactList.setBackground(new java.awt.Color(255, 255, 255));
wmsn_JP_ContactList.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
jTextField1.setBackground(new java.awt.Color(235, 233, 237));
jTextField1.setText("Buscar un contacto");
jTextField1.setMargin(new java.awt.Insets(0, 0, 0, 0));
jButton1.setText("+M");
org.jdesktop.layout.GroupLayout wmsn_JP_ContactListLayout = new org.jdesktop.layout.GroupLayout(wmsn_JP_ContactList);
wmsn_JP_ContactList.setLayout(wmsn_JP_ContactListLayout);
wmsn_JP_ContactListLayout.setHorizontalGroup(
wmsn_JP_ContactListLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(wmsn_JP_ContactListLayout.createSequentialGroup()
.addContainerGap()
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 328, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton1)
.addContainerGap())
);
wmsn_JP_ContactListLayout.setVerticalGroup(
wmsn_JP_ContactListLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(wmsn_JP_ContactListLayout.createSequentialGroup()
.add(wmsn_JP_ContactListLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton1)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addContainerGap(469, Short.MAX_VALUE))
);
org.jdesktop.layout.GroupLayout wmsnContactsWindowLayout = new org.jdesktop.layout.GroupLayout(wmsnContactsWindow.getContentPane());
wmsnContactsWindow.getContentPane().setLayout(wmsnContactsWindowLayout);
wmsnContactsWindowLayout.setHorizontalGroup(
wmsnContactsWindowLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, wmsn_JP_ProfileConfiguration, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(wmsn_JP_ContactList, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
wmsnContactsWindowLayout.setVerticalGroup(
wmsnContactsWindowLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(wmsnContactsWindowLayout.createSequentialGroup()
.add(wmsn_JP_ProfileConfiguration, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(wmsn_JP_ContactList, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
wmsnGeneralMenu.setText("Archivo");
wmsn_GM_Exit.setText("Salir");
wmsn_GM_Exit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
wmsn_GM_ExitActionPerformed(evt);
}
});
wmsnGeneralMenu.add(wmsn_GM_Exit);
jMenuBar1.add(wmsnGeneralMenu);
setJMenuBar(jMenuBar1);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(wmsnContactsWindow, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(wmsnChatWindow, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(166, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, wmsnChatWindow)
.add(org.jdesktop.layout.GroupLayout.LEADING, wmsnContactsWindow))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void wmsn_GM_ExitActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void wmsnClearInputActionPerformed(java.awt.event.ActionEvent evt) {
clearInput();
}
private void wmsnSendActionPerformed(java.awt.event.ActionEvent evt) {
sendMessage();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame frame = new escritorio();
frame.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextField jTextField1;
private javax.swing.JInternalFrame wmsnChatWindow;
private javax.swing.JButton wmsnClearInput;
private javax.swing.JTextField wmsnConsole;
private javax.swing.JInternalFrame wmsnContactsWindow;
private javax.swing.JTextArea wmsnConversation;
private javax.swing.JMenu wmsnGeneralMenu;
private javax.swing.JTextField wmsnNick;
private javax.swing.JTextField wmsnPersonalMessage;
private javax.swing.JButton wmsnSend;
private javax.swing.JTextField wmsnStatus;
private javax.swing.JTextArea wmsnText;
private javax.swing.JMenuItem wmsn_GM_Exit;
private javax.swing.JPanel wmsn_JP_ContactList;
private javax.swing.JPanel wmsn_JP_Photo;
private javax.swing.JPanel wmsn_JP_ProfileConfiguration;
private javax.swing.JLabel wmsn_T_PersonalMessage;
// End of variables declaration
}
Y aqui os dejo el link del rar para que lo descomprimais, si no sabes como ejecutarlo dentro hay un txt con las instrucciones a seguir
http://rapidshare.com/files/30597143/Java_MSN_Cutre.rar.html
Por si no fui concreto, querria que me explicarais como resolver las dudas que tengo.
Gracias de antemano!