• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Awkward Title problem

 
Ranch Hand
Posts: 176
Mac Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Hello everyone,

I'm still quite new to GUI programming and I'm having some trouble with a frame's title. When I create a new instance of the class Box I get the window with its buttons, labels, etc.. (expect the buttons don't work yet because I haven't added listeners but never mind that for the moment). The title I get is "T" (i.e. the first character of the String "Test"). I have no idea why that happens but I'm thinking it could be a Vista problem, if that is the case could any Mac/Linux users try this code out. (Unless I'm totally wrong and there's just a one method missing around the corner)
[ November 27, 2008: Message edited by: Olivier Legat ]
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you have already defined your frame size, comment out to see your title in all its glory
 
Olivier Legat
Ranch Hand
Posts: 176
Mac Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tried that... still doesn't work
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Olivier Legat:
Tried that... still doesn't work



Are you seeing your frame size 250x150 or just a tiny one?
 
Olivier Legat
Ranch Hand
Posts: 176
Mac Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "just a tiny one". Do you mean do you I have to resize it when it opens or does it directly open up as 250x150? If that's the case it opens up automatically to 250x150. Note that in my taskbar it also say "T" instead of test.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Olivier Legat:
What do you mean by "just a tiny one". Do you mean do you I have to resize it when it opens or does it directly open up as 250x150? If that's the case it opens up automatically to 250x150. Note that in my taskbar it also say "T" instead of test.



I meant does it open 250x150.
Tried out your code on WinXP. Works for me.
Sorry. Can't help.
Anybody else?
 
Olivier Legat
Ranch Hand
Posts: 176
Mac Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have no idea why that happens but I'm thinking it could be a Vista problem



I fixed the problem and it turns out not to be an OS problem, it was a problem with my IDE. Works when I run it in BlueJ but not in JCreator... strange
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a modified version of your code:
import java.awt.*;
import java.awt.event.*;

class Box extends Frame
implements ActionListener
{
private Frame fMain;

public Box(){
fMain = new Frame();
fMain.setTitle("Test"); //setting the text in the Title bar
fMain.setSize(250,150);
Label info = new Label("Informations sur l'auditoire");

info.setAlignment(Label.CENTER);
info.setForeground(Color.WHITE);
info.setBackground(Color.BLACK);

Button bAvgr = new Button("Calculer la moyenne");
Button bPass = new Button("No# d'etudiant reussi");
Panel p = new Panel(new FlowLayout());
TextField tf = new TextField("10");

p.add(new Label("Points:"));
p.add(tf);
fMain.setLayout(new GridLayout(4,1));
fMain.add(info);
fMain.add(bAvgr);
fMain.add(bPass);
fMain.add(p);

fMain.setVisible(true);
fMain.pack();
}

public void actionPerformed(ActionEvent e)
{
}
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic