From: jason on
On May 4, 2:28 pm, markspace <nos...(a)nowhere.com> wrote:
> jason wrote:
> > haha
>
> > thanks for humoring me. due to the fact that i have now committed to
>
> I'm not humoring you or answering lightly.  I'm dead serious.  The only
> way to be productive and produce robust, multi-platform GUIs is to use a
> builder tool.  Trying to do this by hand is basically a fool's errand.
> You'll just end up re-inventing the wheel.  Put some effort into
> learning how to make the builder tool do what you want, the long term
> rewards are worth it.
>
> > building the GUI the good old fashioned way i am going to try my best
> > to steer clear of GUI's for GUI's etc.
>
> Learning is OK, just don't loose sight of the overall goal: producing
> code efficiently.  Start with the Java tutorials.  You'll need to
> understand LayoutManagers to lay out by hand.  There's lots of good
> examples of how to layout components manually here:
>
> <http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html>
>
> You should also look up "Separation of Concerns" before rolling too many
> of your own GUI components.  Using a GUI builder will help keep you
> honest there.
>
> >       MyButton.setLocation(0,0);
>
> Use "setBounds" to position a component manually.  You will need to
> remove the layout manager first, because a layout manager will call
> setBounds itself to reposition its components. See this example here:
>
> <http://java.sun.com/docs/books/tutorial/uiswing/layout/none.html>



Understood. you have done more than i bargained for. thank you. i am
definitely on my way now.

i cannot thank you enough.
From: Lew on
jason wrote:
> [code]
> //file: PopUpColorMenu.java
> import java.awt.*;
> import java.awt.event.*;
>
> import javax.swing.*;
>
> public class PopUpColorMenu extends JFrame
> implements ActionListener {
....
> JMenu File_Menu = new JMenu("File"); //create main menu item
> File_Menu .setMnemonic(KeyEvent.VK_F);

<http://java.sun.com/docs/codeconv/index.html>
<http://java.sun.com/docs/codeconv/index.html>
<http://java.sun.com/docs/codeconv/index.html>

>
> JMenuItem Def_Save=new JMenuItem("Save As Default");
> Def_Save.setMnemonic(KeyEvent.VK_S);

<http://java.sun.com/docs/codeconv/index.html>
<http://java.sun.com/docs/codeconv/index.html>
<http://java.sun.com/docs/codeconv/index.html>

....
> JMenuItem Def_Restore=new JMenuItem("Restore Default");
> Def_Restore.setMnemonic(KeyEvent.VK_R);

<http://java.sun.com/docs/codeconv/index.html>
<http://java.sun.com/docs/codeconv/index.html>
<http://java.sun.com/docs/codeconv/index.html>

....
> JMenuItem File_Exit=new JMenuItem("Exit");
> File_Exit.setMnemonic(KeyEvent.VK_X);

<http://java.sun.com/docs/codeconv/index.html>
<http://java.sun.com/docs/codeconv/index.html>
<http://java.sun.com/docs/codeconv/index.html>

....
> JLabel JLabel1 = new JLabel("Search: ");
> //JLabel1.setHorizontalAlignment(SwingConstants.LEFT);
> //JLabel1.setVerticalAlignment(SwingConstants.TOP);
> JLabel1.setLocation(100, 100);
> content.add(JLabel1);

<http://java.sun.com/docs/codeconv/index.html>
<http://java.sun.com/docs/codeconv/index.html>
<http://java.sun.com/docs/codeconv/index.html>

....
> public static void main(String[] args) {
> new PopUpColorMenu( );
> }
> }

Always confine GUI calls to the Event Dispatch Thread (EDT) or bizarre bugs
will result.

--
Lew
From: jason on
On May 4, 2:28 pm, markspace <nos...(a)nowhere.com> wrote:
> jasonwrote:
> > haha
>
> > thanks for humoring me. due to the fact that i have now committed to
>
> I'm not humoring you or answering lightly.  I'm dead serious.  The only
> way to be productive and produce robust, multi-platform GUIs is to use a
> builder tool.  Trying to do this by hand is basically a fool's errand.
> You'll just end up re-inventing the wheel.  Put some effort into
> learning how to make the builder tool do what you want, the long term
> rewards are worth it.
>
> > building the GUI the good old fashioned way i am going to try my best
> > to steer clear of GUI's for GUI's etc.
>
> Learning is OK, just don't loose sight of the overall goal: producing
> code efficiently.  Start with the Java tutorials.  You'll need to
> understand LayoutManagers to lay out by hand.  There's lots of good
> examples of how to layout components manually here:
>
> <http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html>
>
> You should also look up "Separation of Concerns" before rolling too many
> of your own GUI components.  Using a GUI builder will help keep you
> honest there.
>
> >       MyButton.setLocation(0,0);
>
> Use "setBounds" to position a component manually.  You will need to
> remove the layout manager first, because a layout manager will call
> setBounds itself to reposition its components. See this example here:
>
> <http://java.sun.com/docs/books/tutorial/uiswing/layout/none.html>

hey,

one more question in here. everything is working beautifully, now i am
having one issue:
i am trying to run my app outside of netbeans as a .jar file. all
works well but it is in desperate need of a progress bar.

i am trying to implement the following but all i am getting is a
second blank popup window (no progress bar). i am so close (or think i
am) that i can smell it (or maybe i just need to shower).

this UI is popped up after i click a "go!" button or whatever. the
meat of the analysis code executes.

once this starts i would like to watch my progress bar do what it is
made to do. you know. progress!
[code]

public void actionPerformed(ActionEvent arg0) {


JFrame1.setSize(270, 250);
JFrame1.setLocation(200, 200);
JFrame1.setResizable(false);
Insets insets = JFrame1.getInsets();
JFrame1.setLayout(null);
JProgressBar JProgressBar1=new JProgressBar(0,100);
JProgressBar1.setValue(50);
JProgressBar1.setStringPainted(true);
Dimension size=JProgressBar1.getPreferredSize();

JProgressBar1.setBounds(insets.left,insets.top,size.width,size.height);
JFrame1.add(JProgressBar1);
JFrame1.setVisible(true); //i can see this. and all
the applied choices are true. i cannot resize and it appears where it
should at the correct size. but lo and behold, not progressbar.

for (int i=0;i<=Out.size()-1;i++){

JProgressBar1.setValue(i);
//other operations..
}
System.exit(0);
}
From: John B. Matthews on
In article
<5ab965c4-96b2-4ff1-8160-e1717c94340f(a)p2g2000yqh.googlegroups.com>,
jason <jason.mellone(a)gmail.com> wrote:

> once this starts i would like to watch my progress bar do what it is
> made to do. you know. progress!
> [code]
>
> public void actionPerformed(ActionEvent arg0) {

This would appear to be blocking the Event Dispatch Thread. Instead use
a SwingWorker:

<http://java.sun.com/javase/6/docs/api/javax/swing/SwingWorker.html>
<http://sites.google.com/site/drjohnbmatthews/randomdata>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>