[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

JBuilder: using Design Enviroment

Posted on 2004-11-30
19
Medium Priority
?
407 Views
Last Modified: 2013-12-03
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??
0
Comment
Question by:mte01
  • 10
  • 5
  • 3
  • +1
19 Comments
 
LVL 2

Expert Comment

by:b_loco
ID: 12709579
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
 
LVL 3

Author Comment

by:mte01
ID: 12709656
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
 
LVL 2

Assisted Solution

by:mjmohan
mjmohan earned 450 total points
ID: 12712468
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Accepted Solution

by:
delphi3 earned 1050 total points
ID: 12713060
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
 
LVL 3

Author Comment

by:mte01
ID: 12713129
Ok....I will be waiting for other tricks that make some of the things that I mentioned earlier more flexible........
0
 
LVL 3

Author Comment

by:mte01
ID: 12713141
One question....what has delphi got to do with Java & Borland's JBuilder????
0
 
LVL 4

Expert Comment

by:delphi3
ID: 12713610
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
 
LVL 3

Author Comment

by:mte01
ID: 12713656
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
 
LVL 3

Author Comment

by:mte01
ID: 12713758
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
 
LVL 2

Expert Comment

by:mjmohan
ID: 12713781
How is it related to your original question posted?
0
 
LVL 3

Author Comment

by:mte01
ID: 12713817
I apologize......I posted this comment here by mistake......(it should have been in my other question :))
0
 
LVL 3

Author Comment

by:mte01
ID: 12713820
PLEASE IGNORE COMMENT 12/01/2004 10:19AM EET
0
 
LVL 3

Author Comment

by:mte01
ID: 12713823
Ahhh.....I just realized that it only appears using my configurations 10:19AM EET.....I apologize also.....
0
 
LVL 2

Expert Comment

by:mjmohan
ID: 12713835
Excused, because this is life and we tend to do mistakes... :-) Bit of philosophy...
0
 
LVL 4

Expert Comment

by:delphi3
ID: 12750810
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
 
LVL 3

Author Comment

by:mte01
ID: 12751060
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
 
LVL 4

Assisted Solution

by:delphi3
delphi3 earned 1050 total points
ID: 12751183
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
 
LVL 3

Author Comment

by:mte01
ID: 12751204
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
 
LVL 4

Expert Comment

by:delphi3
ID: 12771030
Hi mte01,

Thanks for the points and grade.  I appreciate it.

Delphi3
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question