Jump to content



Photo

design help?

java

  • Please log in to reply
6 replies to this topic

#1 Original Poster

Original Poster

    Systems Developer

  • Tech Issues Solved: 1
  • Joined: 15-July 08
  • Location: my room
  • OS: windows 7/8, Kali, ubuntu, OSx 10.9
  • Phone: Android

Posted 19 December 2012 - 01:34

I am trying to make my chat program all snazzy ... but I suck at it ... I a horrible it is awful I want to cry it looks like that... it has an interface not even a mother could love ....


so basically i need help with gui programming.... look what happens when i try .... an links or tips or anything

import java.awt.*;		 
import java.awt.event.*;   
import javax.swing.*;	  
import javax.swing.event.*;
@SuppressWarnings("unused")
public class SwingChatGUI extends JFrame
{
/**
  *
  */
private static final long serialVersionUID = 1L;
public JButton sendButton;
public static JTextArea txArea;
public static JTextArea rxArea;
 
  public Container container;

public JPanel n1, s1, w1, all;
	 
	
public SwingChatGUI (String title)
{
  super (title);
 
	    container = getContentPane();			
	    container.setLayout( new BorderLayout() );
	    container.setPreferredSize(new Dimension(600, 600));
	    all = new JPanel(new BorderLayout());
	    container.add(all, BorderLayout.CENTER);
	   
	    n1 = new JPanel(new BorderLayout());
	    n1.setPreferredSize(new Dimension(400, 200));
	    n1.setBorder(BorderFactory.createLineBorder(Color.black));
	    all.add(n1, BorderLayout.NORTH);
	   
	    s1 = new JPanel(new BorderLayout());
	    s1.setPreferredSize(new Dimension(400, 200));
	    s1.setBorder(BorderFactory.createLineBorder(Color.black));
	    all.add(s1, BorderLayout.CENTER);
	   
	   
	    w1 = new JPanel(new BorderLayout());
	    w1.setPreferredSize(new Dimension(50, 400));
	    w1.setBorder(BorderFactory.createLineBorder(Color.black));
	    container.add(w1, BorderLayout.EAST);
	  
	   
  txArea = new JTextArea (6, 40);
  txArea.setLineWrap(true);
  txArea.setWrapStyleWord(true);
 
  rxArea = new JTextArea (6, 40);
  rxArea.setLineWrap(true);
  rxArea.setWrapStyleWord(true);
 
  sendButton = new JButton ("Send");
  sendButton.setPreferredSize(new Dimension(10, 20));
  setResizable(false);
  
  n1.add (rxArea);
  s1.add (txArea);
  w1.add (sendButton);
 
}


public static void main (String[] args)
{
  Frame f = new SwingChatGUI ("Chat Program");
  f.pack ();
  f.setVisible(true);
}
}



#2 Andre S.

Andre S.

    Asik

  • Tech Issues Solved: 11
  • Joined: 26-October 05

Posted 19 December 2012 - 23:06

Do you expect someone else to compile and run this code, understand what it does, guess what your intent is and what isn't working out with it for you, and by sheer intuition come up with just the advice you need?

Perhaps you should at least explain what you're trying to do and what the problem is, in more detail than "it sucks". And if it's a visual issue, perhaps you could even a post a screenshot illustrating what the issue is. The less work and guessing you force us to do, the more quickly you'll get a quick and informative answer.

#3 chuck.oak

chuck.oak

    Resident One Post Wonder

  • Joined: 20-December 12

Posted 20 December 2012 - 13:55

Consider using NetBeans built-in GUI Builder for drag-and-drop Swing development. Eclipse has a similar plugin, but I find myself more productive in NetBeans. Your mileage may vary.

#4 OP Original Poster

Original Poster

    Systems Developer

  • Tech Issues Solved: 1
  • Joined: 15-July 08
  • Location: my room
  • OS: windows 7/8, Kali, ubuntu, OSx 10.9
  • Phone: Android

Posted 22 December 2012 - 23:36

Consider using NetBeans built-in GUI Builder for drag-and-drop Swing development. Eclipse has a similar plugin, but I find myself more productive in NetBeans. Your mileage may vary.


?? does eclipse have this plugin ? I would rather code it in my self but this whole panel panel panel panel panel ENDLESS PANELS is getting to me a bit ..

#5 kjordan2001

kjordan2001

    Mystery Solver

  • Tech Issues Solved: 1
  • Joined: 27-May 02

Posted 23 December 2012 - 21:43

?? does eclipse have this plugin ? I would rather code it in my self but this whole panel panel panel panel panel ENDLESS PANELS is getting to me a bit ..

http://www.eclipse.org/windowbuilder/

#6 Ryano121

Ryano121

    Neowinian

  • Joined: 07-August 10

Posted 23 December 2012 - 22:07

Although be very wary when using GUI builders for Java. They more often than not produce buckets of horrible code that quickly becomes a maintenance nightmare somewhere along the road. Use them with care.

#7 kjordan2001

kjordan2001

    Mystery Solver

  • Tech Issues Solved: 1
  • Joined: 27-May 02

Posted 23 December 2012 - 23:07

Although be very wary when using GUI builders for Java. They more often than not produce buckets of horrible code that quickly becomes a maintenance nightmare somewhere along the road. Use them with care.

Yeah, I think doing it via XML is a cleaner way to design a GUI: http://java-source.n...erface-toolkits