Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Awkward Title problem  RSS feed

 
Olivier Legat
Ranch Hand
Posts: 176
Chrome Mac Windows
  • Mark post as helpful
  • send pies
  • 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 ]
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Chrome Mac Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tried that... still doesn't work
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Chrome Mac Windows
  • Mark post as helpful
  • send pies
  • 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: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Chrome Mac Windows
  • Mark post as helpful
  • send pies
  • 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
 
Haizea O'Brien
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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)
{
}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!