AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Line break with flowlayout

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Wed Sep 13, 2006 5:23 am    Post subject: Line break with flowlayout Reply with quote



Is there any way i can force a line break using flowlayout(Or another
way I can have one line of text centered, and another centered line
below it?)
Back to top
Guest






PostPosted: Wed Sep 13, 2006 9:41 pm    Post subject: Re: Line break with flowlayout Reply with quote



gamespotlogin (AT) gmail (DOT) com wrote:
Quote:
Is there any way i can force a line break using flowlayout(Or another
way I can have one line of text centered, and another centered line
below it?)

What are you trying to do? Where are you writing the text to? Is it
really just a couple lines of text, or does the solution need to work
for a whole bunch of lines?
Eric
Back to top
k0m0r
Guest





PostPosted: Thu Sep 14, 2006 7:10 am    Post subject: Re: Line break with flowlayout Reply with quote



Quote:
Is there any way i can force a line break using flowlayout(Or another
way I can have one line of text centered, and another centered line
below it?)

I don't clearly see what you're trying to do.
But it looks like some kind of strange behaviour. You sure you're going
the right way?
Back to top
Ian Wilson
Guest





PostPosted: Thu Sep 14, 2006 3:26 pm    Post subject: Re: Line break with flowlayout Reply with quote

gamespotlogin (AT) gmail (DOT) com wrote:
Quote:
Is there any way i can force a line break using flowlayout(Or another
way I can have one line of text centered, and another centered line
below it?)


Have you considered BoxLayout? Sun's example looks exactly like what you
describe

http://java.sun.com/docs/books/tutorial/uiswing/layout/box.html

Lightly modified ...

import java.awt.Component;
import java.awt.Container;

import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class CentreText {
public static void addComponentsToPane(Container pane) {
pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));

addALine("A", pane);
addALine("Lorem ipsum dolor sit amet", pane);
addALine("Twas brillig and the slithy toves", pane);
addALine("End", pane);
}

private static void addALine(String text, Container container) {
JLabel label = new JLabel(text);
label.setAlignmentX(Component.CENTER_ALIGNMENT);
container.add(label);
}

/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("BoxLayoutDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set up the content pane.
addComponentsToPane(frame.getContentPane());

//Display the window.
frame.pack();
frame.setVisible(true);
}

public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.