JBuilder: using Design Enviroment

Hey experts,

I want to do a quick graphical interface for several forms in java using JBuilder's design enviroment (I just want to do an interface - no code behind is needed). Apparently it's not that easy as when you are using Visual Studio .NET's enviroment.....any help in this matter on design issues by someone who has used the design enviroment in JBuilder??
LVL 3
mte01Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

b_locoCommented:
I've used JBuilder and at first I also didn't understand how it worked.

First of all I recommend reading this:
http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html

Specially:
http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html#choosing

I think that if you read it, it will be clearer.

Understanding layouts is the most important thing
0
mte01Author Commented:
I have read all these sun tutorials regarding layout managers, and I know all of them from the FlowLayout manager to the GridBagLayoutManager to the XYLayout Manager of Borland.

I want to know some tricks regarding using the design enviroment in JBuilder...for example how to add an icon with a bitmap picture to a JButton.....how to add a JFrame.....etc, and of course all of this in the Design Env. (I know how to do it in the code).....
0
mjmohanCommented:
Hi,
   Once you create a new project, open a 'Frame' based application. (File -> New -> General -> Frame).  By default, source tab will be opened for you.  Open 'Design' tab.  On the right hand side panel, select 'null' for layout.  Then, you can start adding components to the frame.  You can add 'Swing Containers' or  'Swing components' by choosing the option from top bar which will be displayed after you open the frame.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

delphi3Commented:
Hi mte01,

As noted above there are things to read. You will have to plow through the details.
here is, in my opinion a good set of info for the details:

http://www.computer-logic.net/javadelphi/chapter1.htm

and chapters that follow from that address.


The other way to do it is to start with something that is
already written using the JBuilder X designer that may or may not be what you want.
Then decided that what might be added or subtracted from what is there.

Here are 2 models that were done with the JBuilder  designer that were made:
The first model has a frame and panels, textarea and button.  Load the porgrams in and then press the designer
tab and since it was made with the designer, it will display in the designer.


package hellowordusingdesigner;

import javax.swing.UIManager;
import java.awt.*;

public class HelloWorld {
  boolean packFrame = false;

  //Construct the application
  public HelloWorld() {
    HelloWorldFrame frame = new HelloWorldFrame();
    //Validate frames that have preset sizes
    //Pack frames that have useful preferred size info, e.g. from their layout
    if (packFrame) {
      frame.pack();
    }
    else {
      frame.validate();
    }
    //Center the window
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = frame.getSize();
    if (frameSize.height > screenSize.height) {
      frameSize.height = screenSize.height;
    }
    if (frameSize.width > screenSize.width) {
      frameSize.width = screenSize.width;
    }
    frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    frame.setVisible(true);
  }
  //Main method
  public static void main(String[] args) {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
    catch(Exception e) {
      e.printStackTrace();
    }
    new HelloWorld();
  }
}

package hellowordusingdesigner;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

public class HelloWorldFrame
    extends JFrame {
  JPanel jpnlDisplay;
  BorderLayout borderLayout1 = new BorderLayout();
  JPanel jPanel1 = new JPanel();
  JLabel jlblTitle = new JLabel();
  JLabel jlblHelloWorld = new JLabel();
  JButton jbtnSayHello = new JButton();
  JButton jbtnExit = new JButton();
  private TitledBorder titledBorder1;
  private JPanel jPnlMiddle = new JPanel();
  private BorderLayout borderLayout2 = new BorderLayout();
  private JPanel jPnlOnTop = new JPanel();
  private JPanel jPnlBack = new JPanel();
  private GridLayout gridLayout1 = new GridLayout();

  //Construct the frame
  public HelloWorldFrame() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

  //Component initialization
  private void jbInit() throws Exception {
    jpnlDisplay = (JPanel)this.getContentPane();
    titledBorder1 = new TitledBorder("");
    jpnlDisplay.setLayout(borderLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("HeloWld");
    jPanel1.setLayout(null);
    jlblTitle.setFont(new java.awt.Font("SansSerif", 1, 16));
    jlblTitle.setForeground(Color.blue);
    jlblTitle.setAlignmentY( (float) 0.5);
    jlblTitle.setText("My First Java Application");
    jlblTitle.setBounds(new Rectangle(113, 25, 235, 18));
    jlblHelloWorld.setFont(new java.awt.Font("SansSerif", 0, 24));
    jlblHelloWorld.setForeground(Color.red);
    jlblHelloWorld.setText("Hello World from Java");
    jlblHelloWorld.setBounds(new Rectangle(93, 148, 250, 18));
    jbtnSayHello.setBounds(new Rectangle(71, 234, 130, 27));
    jbtnSayHello.setText("Say Hello Java");
    jbtnSayHello.addActionListener(new
                                   HelloWorldFrame_jbtnSayHello_actionAdapter(this));
    jbtnExit.setBounds(new Rectangle(220, 234, 130, 27));
    jlblHelloWorld.setVisible(false);
    jbtnExit.setText("Exit");
    jbtnExit.addActionListener(new HelloWorldFrame_jbtnExit_actionAdapter(this));
    jPnlBack.setLayout(gridLayout1);
    jpnlDisplay.add(jPanel1, BorderLayout.CENTER);
    jPanel1.add(jbtnSayHello, null);
    jPanel1.add(jbtnExit, null);
    jPanel1.add(jlblHelloWorld, null);
    jPanel1.add(jlblTitle, null);
  }

  //Overridden so we can exit when window is closed
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }

  void jbtnExit_actionPerformed(ActionEvent e) {
    System.exit(0);
  }

  void jbtnSayHello_actionPerformed(ActionEvent e) {
    if (jlblHelloWorld.isVisible() == false) {
      jlblHelloWorld.setVisible(true);

    }
  }
}

class HelloWorldFrame_jbtnExit_actionAdapter
    implements java.awt.event.ActionListener {
  HelloWorldFrame adaptee;

  HelloWorldFrame_jbtnExit_actionAdapter(HelloWorldFrame adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.jbtnExit_actionPerformed(e);
  }
}

class HelloWorldFrame_jbtnSayHello_actionAdapter
    implements java.awt.event.ActionListener {
  HelloWorldFrame adaptee;

  HelloWorldFrame_jbtnSayHello_actionAdapter(HelloWorldFrame adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.jbtnSayHello_actionPerformed(e);
  }
}



The second program is my sample "package mjtfdesignerdemo" ; provided in this EE link:

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21221232.html

Load it, then use the designer to view the items. Add and delete as desired to meet your
needs.

Delphi3

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mte01Author Commented:
Ok....I will be waiting for other tricks that make some of the things that I mentioned earlier more flexible........
0
mte01Author Commented:
One question....what has delphi got to do with Java & Borland's JBuilder????
0
delphi3Commented:
Hi mte01,
you wrote:
what has delphi got to do with Java & Borland's JBuilder?

The answer is: The author of javadelphi discusses the connection that delphi  pascal programmers must  make in order to make the transition to writing java programs. The text  tells others too, especially those learning java,  how to start using the designer and use it to make a simple hello program and other java programs.

This is the bag of "other tricks" that you could  read (javadelphi) 6 chapters in all, so that you can correctly set up the java package forms and frames to use the designer. This text comes along with good illustrations. But then again this is my own opinion and I don't expect that you would agree.

As suggested by me earlier:
Make a package name it : "hellowordusingdesigner", copy the "HelloWorld"  and "HelloWorldFrame" program lines I gave you above by using copy, pasting.

Now  using the designer when the tab for HelloWorldFrame is up, click on any  item viewed on the designer form, then  just keep cut(ing) out the various items on the frame until you have what you want and or add more as you would select from the various pallets.  A bit of reverse construction.  Sort of like ordering a Big Mac from MacDonald's and then tossing away all the lettuce, pickle and other stuff, including the bun to get to just the meat. This is a  poor illustration at best.

D3
0
mte01Author Commented:
Yes okk, I agree with you delphi3, and I can make without any help a helloworld application just like the one you did....but I think that the JBuilder's design env. remains inferior to that of Microsoft's .NET, and I want to fill the gap between them...for example add a picture to a JButton at design time....add items to a JComboBox at design time.....etc...any help on doing that??
0
mte01Author Commented:
I sent an e-mail to myself at 10:08 AM (Sent Items)...I opened it using my webmail, it arrived at 10:09 AM (Webmail-Inbox), then I sent another e-mail to myself from the webmail at around 10:10 AM...it appeared in the sent items of the webmail as being sent at 9:00 AM, and I opened it from the inbox of the webmail, and the time of its arrival was 9:00 AM also. Then I downloaded both e-mails to the outlook......the time of the 1st e-mail was 8:59 AM, and the 2nd was 9:00 AM!!

Do I have to contact my university's mail administrator regarding this problem in the mail server, or is there a way to synchronize it from the webmail directly???
0
mjmohanCommented:
How is it related to your original question posted?
0
mte01Author Commented:
I apologize......I posted this comment here by mistake......(it should have been in my other question :))
0
mte01Author Commented:
PLEASE IGNORE COMMENT 12/01/2004 10:19AM EET
0
mte01Author Commented:
Ahhh.....I just realized that it only appears using my configurations 10:19AM EET.....I apologize also.....
0
mjmohanCommented:
Excused, because this is life and we tend to do mistakes... :-) Bit of philosophy...
0
delphi3Commented:
Hi mte01,

Considering one of your earlier comments:

To get an ImageIcon to appear on one of  the buttons when running the program  this statement below "ImageIcon..... "  should be placed within the group of statements within the JFrame statements such as:


  JLabel jlblHelloWorld = new JLabel();
  JButton jbtnSayHello = new JButton();
  JButton jbtnExit = new JButton();
  // this next line is the item that should appear. It could be a .jpg, .gif, .png.
  ImageIcon TestIcon0 = new ImageIcon("bullet_red.gif"); // .gif format
 //ImageIcon TestIcon1 = new ImageIcon("bullet_red.bmp"); // .bmp format: does not  work with what I have.
  ImageIcon TestIcon2 = new ImageIcon("bullet_red.jpg"); // .jpg format
  ImageIcon TestIcon3 = new ImageIcon("bullet_red.png"); // .png format

.........

Locate the  "bullet_red.gif", "bullet_red.jpg" and "bullet_red.png" in the same folder as the .jpx listing,  That is,  with the other items such as the src, classes, bak.

Now opening the designer, and clicking on the button that the icon will be added, the properties listing will show a new options within the options for icon as 4 options:
 <none>, TestIcon0,TestIcon2,TestIcon3.
 
Select the any of these later 3 icon choices  and  that ImageIcon will be added to the program by the designer appearing as a new line:

jbtnExit.setIcon(TestIcon0);

Should one of the others been selected that line would be modified accordingly.

It will also appear while the designer is viewable, provided it can find the image selected and if it is acceptable type, and if the exit button is clicked on.  And of course when a run is executed.

I have also tested  the .bmp and a  .ico image format and it does not show. However if  with addtional resources, it may be shown.

Delphi3



 
0
mte01Author Commented:
Ahaa....I see.....what I was afraid of, is that there are still things that you have to do in the code (unlike Visual Studio .NET), if I was the one who is using it, I would rather do everything in the code, but this for a friend of mine who would like to have the ease of Microsoft's .NET in JBuilder's GUI Design Environment.....
0
delphi3Commented:
Hi mte01,
Yes, I have come to realize that for a java learner, a general programming tool, IDE,  like JBuilder X Foundation, a free download,  is not without some shortcomings in the "do everything" department.

 I suspect that,  if you had the full blown version, not for "free",  "might, or possibly" have those desired features.  But to avoid being disappointed in the costly, full blown version,  that you get some guarantees that it will perform as you expected.
 
Often, I design JAVA programs using previous models and with some  copy, paste,  modify.  But of course I do need the models to call upon to get the more efficient layouts.

D3
0
mte01Author Commented:
Yes....right...I have JBuilder 6 with the full blown enterprise edition, and it has the same features as JBuilder X Foundation, but with only additional "server-based" features like using JDBC & JBCL (JBuilder's DB) drivers, and wizards for JSP pages, and multi-threaded programs, in addition to drawing UML diagrams for the code that you are writing (but this is only per class), but all of these features do not fit us in the design enviroment, so as you said it is better to design java models from existing ones.....which would help us in some cases after having drawn several forms.

I'll be waiting for any extra comments before closing the question.......
0
delphi3Commented:
Hi mte01,

Thanks for the points and grade.  I appreciate it.

Delphi3
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.