Distance between buttons (Flow Layout)

Hi people,
I Have 100 buttons inside a JPane with Flow Layout.
How do I set the distance between the buttons to 0(width and height)?
Regards.
Thank's.

Yes, I did!
I have a class "Board" that extends JPanel with GridLayout.
This class has a constructor that takes the rows, cols, number of mines and size of squares!
package view;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.Random;
import javax.swing.JPanel;
import model.Square;
import control.SquareHandler;
public class Board extends JPanel {
     private Square square[][] = new Square[16][30];
     private int mines, width, height;
     Board(int width, int height, int mines, int size) {
          Dimension dimension = new Dimension(size,size);
          //FlowLayout layout = new FlowLayout();
          GridLayout layout = new GridLayout();
          //layout.setHgap(0);
          //layout.setVgap(0);
          layout.setRows(height);
          layout.setColumns(width);
          this.mines = mines;
          this.width = width;
          this.height = height;
          setLayout(layout);
          for (int j = 0; j < height; j++){
               for (int i = 0; i < width; i++){
                    square[j] = new Square(i,j);
                    square[j][i].setPreferredSize(dimension);
                    square[j][i].addActionListener(new SquareHandler(this, i, j));
                    add(square[j][i]);
          makeMines();
     public void makeMines() {
          Random randomizer = new Random();
          int randomX, randomY;
          for (int i = 0; i < mines; i++){
               while (true) {
                    randomX = randomizer.nextInt();
                    randomX = Math.abs(randomX);
                    randomX = randomX % width;
                    randomY = randomizer.nextInt();
                    randomY = Math.abs(randomY);
                    randomY = randomY % height;
                    if(!square[randomY][randomX].getMine()){
                         square[randomY][randomX].setMine();
                         break;
     public Square getSquare(int x, int y){
          if (x < 0 || x >= width || y < 0 || y >= height ){
               // Error
               return new Square(-1,-1);
          return square[y][x];

Similar Messages

  • GridBag or Flow Layout: Help Please!!!

    Requirement: Allow the user to input the amount of a mortgage and then select from a menu of mortgage loans: 7 years at 5.35%, 15 years at 5.5%, and 30 years at 5.75%. Use an array for the different loans. Display the mortgage payment amount. Then, list the loan balance and interest paid for each payment over the term of the loan. Allow the user to loopback and enter a new amount and make a new selection or quit.
    I have written the code so far that allows for the creation of the pane, texts, user entry, combobox, and buttons.
    My problem is that I cannot get it sorted out to look like a usable interface. I don't know if I should go with a GridBag Layout or a Flow Layout.
    I am using the GridBag Layout in this example, but obviously I am missing the correct procedure on how to do it.
    Can anyone give me a hand?
    My goal for the interface is to have the following fields set up in the pane to lay out like this:
    Mortgage ------ MortgageTF
    Loan ----- LoanCB
    Payment ----- PaymentTF
    Balance
    Compute----- Reset----- Exit
    Thank you for any assistance.
    Havok
    My written code is below:
    import javax.swing.*;
    import java.awt.*;
    public class MCalc002 extends JFrame
    public MCalc002()
    super("Mortgage Calculator");
    setSize(500, 800);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
    Container pane = getContentPane();
    GridBagLayout gridBag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    pane.setLayout(gridBag);
    JLabel mortgage = new JLabel("Mortgage:");
    c.gridx = 0; c.gridy = 0;
    pane.add(mortgage);
    JLabel loan = new JLabel("Loan Menu:");
    c.gridx = 2; c.gridy = 2;
    pane.add(loan);
    JLabel payment = new JLabel("Monthly Payment:");
    c.gridx = 3; c.gridy = 3;
    pane.add(payment);
    JLabel balance = new JLabel("Loan Balance:");
    c.gridx = 4; c.gridy = 4;
    pane.add(balance);
    JTextField mortgageTF = new JTextField(10);
    c.gridx = 4; c.gridy = 4;
    pane.add(mortgageTF);
    JComboBox loanCB = new JComboBox();
    c.gridx = 5; c.gridy = 5;
    loanCB.addItem("Please Select");
    loanCB.addItem("7yrs @ 5.35%");
    loanCB.addItem("15yrs @ 5.5%");
    loanCB.addItem("30yrs @ 5.75%");
    pane.add(loanCB);
    JTextField paymentTF= new JTextField(10);
    c.gridx = 4; c.gridy = 4;
    pane.add(paymentTF);
    JButton compute = new JButton("Compute");
    c.gridx = 5; c.gridy = 5;
    pane.add(compute, c);
    JButton reset = new JButton("Reset");
    c.gridx = 6; c.gridy = 6;
    pane.add(reset, c);
    JButton exit = new JButton("Exit");
    c.gridx = 7; c.gridy = 7;
    pane.add(exit, c);
    setContentPane(pane);
    public static void main(String[] arguments)
    MCalc002 pb = new MCalc002();
    //EOF

    My problem is that I cannot get it sorted out to look
    like a usable interface. I don't know if I should go
    with a GridBag Layout or a Flow Layout.
    My goal for the interface is to have the following
    fields set up in the pane to lay out like this:
    Mortgage ------ MortgageTF
    Loan ----- LoanCB
    Payment ----- PaymentTF
    Balance
    Compute----- Reset----- Exit
    import javax.swing.*;
    import java.awt.*;
    public class MCalc002 extends JFrame {
        public MCalc002() {
            super("Mortgage Calculator");
            setSize(500, 800);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            Container pane = getContentPane();
            GridBagLayout gridBag = new GridBagLayout();
            GridBagConstraints c = new GridBagConstraints();
            pane.setLayout(gridBag);
            JLabel mortgage = new JLabel("Mortgage:");
            c.gridx = 0; c.gridy = 0;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(mortgage, c);
            pane.add(mortgage);
            JLabel loan = new JLabel("Loan Menu:");
            c.gridx = 0; c.gridy = 1;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(loan, c);
            pane.add(loan);
            JLabel payment = new JLabel("Monthly Payment:");
            c.gridx = 0; c.gridy = 2;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(payment, c);
            pane.add(payment);
            JLabel balance = new JLabel("Loan Balance:");
            c.gridx = 0; c.gridy = 3;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(balance, c);
            pane.add(balance);
            JTextField mortgageTF = new JTextField(10);
            c.gridx = 3; c.gridy = 0;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(mortgageTF, c);
            pane.add(mortgageTF);
            JComboBox loanCB = new JComboBox();
            c.gridx = 3; c.gridy = 1;
            c.insets = new Insets(20,10,20,10);
            loanCB.addItem("Please Select");
            loanCB.addItem("7yrs @ 5.35%");
            loanCB.addItem("15yrs @ 5.5%");
            loanCB.addItem("30yrs @ 5.75%");
            gridBag.setConstraints(loanCB, c);
            pane.add(loanCB);
            JTextField paymentTF= new JTextField(10);
            c.gridx = 3; c.gridy = 2;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(paymentTF, c);
            pane.add(paymentTF);
            JButton compute = new JButton("Compute");
            c.gridx = 0; c.gridy = 4;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(compute, c);
            pane.add(compute, c);
            JButton reset = new JButton("Reset");
            c.gridx = 1; c.gridy = 4;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(reset, c);
            pane.add(reset, c);
            JButton exit = new JButton("Exit");
            c.gridx = 3; c.gridy = 4;
            c.insets = new Insets(20,10,20,10);
            gridBag.setConstraints(exit, c);
            pane.add(exit, c);
            setContentPane(pane);
            setVisible(true);  // Generally speaking, this should be the last operation in setting up GUI components.
        public static void main(String[] arguments) {
            MCalc002 pb = new MCalc002();
    }

  • Another bug in Flow layout ?

    If a Flow object gets its content during initialization it doesn't take the specified size of the children into account. The sizes are kept if the children are added afterwards. But then they're stacked on top of each other; as described in the other thread.
    Example: The buttons sizes are ignored.
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.layout.Flow;
    import javafx.scene.control.*;
    def okButton = Button {
        text: "OK"
        strong: true
        width: 100
        height: 100
    def cancelButton = Button {
        text: "Cancel"
        width: 100
        height: 100
    def layout = Flow {
        content: [okButton, cancelButton];
    Stage {
        title: "Flowlayout Demo"
        scene: Scene {
            width: 400
            height: 400
            content: layout
    }Example: The sizes are not ignored, but the positions are.
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.layout.Flow;
    import javafx.scene.control.*;
    def okButton = Button {
        text: "OK"
        strong: true
        width: 100
        height: 100
    def cancelButton = Button {
        text: "Cancel"
        width: 100
        height: 100
    def layout = Flow {};
    layout.content = [okButton, cancelButton];
    Stage {
        title: "JavaFX 1.2 Controls Demo"
        scene: Scene {
            width: 400
            height: 400
            content: layout
    }

    CORRECTION: It works if a child gets a LayoutInfo object. False alarm. MEA CULPA.
    def largeButtonDimension = LayoutInfo {
          width: 100
          height: 100
          minWidth: 100
          minHeight: 100
    def smallButtonDimension = LayoutInfo {
          width: 50
          height: 50
          minWidth: 50
          minHeight: 50
    def okButton = Button {
        text: "OK"
        layoutInfo: largeButtonDimension;
        strong: true
    def cancelButton = Button {
        text: "Cancel"
        layoutInfo: smallButtonDimension
    def layout = Flow {
        content: [okButton, cancelButton];
    }

  • Spacing JButtons on Flow Layout....

    Hello,
    I am a Java student. The assignment was to create a calculator. I have just begun the layout portion (to me the hardest part).... I decided to go with Flow Layout due to its easiest nature to a beginner.
    Here is the code i have so far:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Calculator extends JFrame
         public static final int width = 300;
         public static final int height = 260;
         public static void main(String[] args)
              Calculator gui = new Calculator();
              gui.setVisible(true);
         public Calculator()
              setSize(width, height);
              addWindowListener(new WindowDestroyer());
              setTitle("Calculator");
              Container contentPane = getContentPane();
              contentPane.setLayout(new FlowLayout());
              contentPane.setBackground(Color.LIGHT_GRAY);
              JPanel aPanel = new JPanel();
              JTextField display = new JTextField(25);
              contentPane.add(aPanel);
              aPanel.add(display);
              JPanel anotherPanel = new JPanel();
              contentPane.add(anotherPanel);
              JButton backspace = new JButton("Backspace");
              contentPane.add(backspace);
              JButton clearEntry = new JButton("CE");
              contentPane.add(clearEntry);
              JButton clear = new JButton("C");
              contentPane.add(clear);
              JButton mc = new JButton("MC");
              contentPane.add(mc);
              JButton sevenButton = new JButton("7");
              contentPane.add(sevenButton);
              JButton eightButton = new JButton("8");
              contentPane.add(eightButton);
              JButton nineButton = new JButton("9");
              contentPane.add(nineButton);
              JButton divide = new JButton("/");
              contentPane.add(divide);
              JButton sqrt = new JButton("sqrt");
              contentPane.add(sqrt);
              JButton mr = new JButton("MR");
              contentPane.add(mr);
              JButton fourButton = new JButton("4");
              contentPane.add(fourButton);
              JButton fiveButton = new JButton("5");
              contentPane.add(fiveButton);
              JButton sixButton = new JButton("6");
              contentPane.add(sixButton);
              JButton multiply = new JButton("*");
              contentPane.add(multiply);
              JButton percent = new JButton("%");
              contentPane.add(percent);
              JButton ms = new JButton("MS");
              contentPane.add(ms);
              JButton oneButton = new JButton("1");
              contentPane.add(oneButton);
              JButton twoButton = new JButton("2");
              contentPane.add(twoButton);
              JButton threeButton = new JButton("3");
              contentPane.add(threeButton);
              JButton minusButton = new JButton("-");
              contentPane.add(minusButton);
              JButton reciprocal = new JButton("1/x");
              contentPane.add(reciprocal);
              JButton mplus = new JButton("M+");
              contentPane.add(mplus);
              JButton zeroButton = new JButton("0");
              contentPane.add(zeroButton);
              JButton plusMinus = new JButton("+/-");
              contentPane.add(plusMinus);
              JButton dotButton = new JButton(".");
              contentPane.add(dotButton);
              JButton additionButton = new JButton("+");
              contentPane.add(additionButton);
              JButton equalsButton = new JButton("=");
              contentPane.add(equalsButton);
    Keep in mind i will do the action listeners and everything later..... i am NOT looking for anyone to do coding for me, but here's what i would like if at all possible:
    the assignment calls for the calculator to visually appear similar/just like the windows calculator..... so in other words i need the "MC" button to start the second line, MR button to start the third, etc....
    My text book, Introduction to Java by Walter Savitch, explains Swing and JButtons, but at no time provides an example with buttons on more than one line, or how to create a new line.
    **Keep in mind this is not for an applet!!!**
    I appreciate all your help!
    -ABT-

    i almost forgot to mention what the problem was...
    with Flowlayout, it prints the buttons in order, but just as many can fit on one line.... so when you compile and run the code, the MC button appears on the first line with the 7 button starting the second line....
    I need to figure out how to insert a (web-equivalent) <br> in the code, to tell the swing module to start a new line for the next set of JButtons.
    thanks
    -ABT-

  • Flow Layout....please help!

    Hi all,
    I am having trouble with my flow Layout manager. As i add more and more components to the panel, I am not able to see the components unless the resize the frame, I am wondering is there a way that I can make flow Layout manager to creat a new line rather than continuing adding to one horizontal line!!!!!??????
    Thank you for your attention,
    Dan

    thank you all for all the help, however, i am still having trouble setting the layout of my control panel......
    so here is my sample code!!!
    and please correct me!!!!
    public DrawControls(DrawPanel target) {
         this.target = target;
         //setLayout( new GridBagLayout());
         //setLayout(new FlowLayout());
         setBackground(Color.white);
         target.setForeground(Color.red);
         CheckboxGroup group = new CheckboxGroup();
         Checkbox b;
         add(b = new Checkbox(null, group, false));
         b.addItemListener(this);
         b.setForeground(Color.red);
         add(b = new Checkbox(null, group, false));
         b.addItemListener(this);
         b.setForeground(Color.green);
         add(b = new Checkbox(null, group, false));
         b.addItemListener(this);
         b.setForeground(Color.blue);
         add(b = new Checkbox(null, group, false));
         b.addItemListener(this);
         b.setForeground(Color.pink);
         add(b = new Checkbox(null, group, false));
         b.addItemListener(this);
         b.setForeground(Color.orange);
         add(b = new Checkbox(null, group, true));
         b.addItemListener(this);
         b.setForeground(Color.black);
         target.setForeground(b.getForeground());
         //setLayout(new FlowLayout());
         //Line buttons
         //setLayout(new BorderLayout());
         insertLine = new Button("H.Lines");
              insertLine.addActionListener(this);
              insertLine.setBackground(Color.lightGray);
         add(insertLine);
         // String buttons
         insertVerLine = new Button("V.Lines");
         insertVerLine.addActionListener(this);
         insertVerLine.setBackground(Color.lightGray);
         add(insertVerLine);
         insertString = new Button("Descripion");
                   insertString.addActionListener(this);
                   insertString.setBackground(Color.lightGray);
         add(insertString);
         // logo button
         insertLogo = new Button("Graphics");
                   insertLogo.addActionListener(this);
                   insertLogo.setBackground(Color.lightGray);
         add(insertLogo);
         //delete button
         delete = new Button("Delete");
                   delete.addActionListener(this);
                   delete.setBackground(Color.lightGray);
         add(delete);
         //reset button
         reset = new Button("Reset");
                   reset.addActionListener(this);
                   reset.setBackground(Color.lightGray);
                   reset.setForeground(Color.red);
         add(reset);
         //label
         Label label1 = new Label("Text");
         add(label1);
         //textbox
         yourText = new TextField(10);
         //yourText.setMaximumSize(yourText.getPreferredSize());
         add(yourText);
    TextField yourText;
    Button insertLine;
    Button insertVerLine;
    Button insertString;
    Button insertLogo;
    Button delete;
    Button reset;

  • Increase distance between objects w/o resizing the objects

    Is it posible to increase distance between objects in illustrator cs3 without resizing the individual objects?
    For example, I have a series of circles separated from one another by about 20 pixels, aligned into a grid-like formation.  I would like to increase or decrease the distance of the circles from one another, without changing the size of the circles themselves.
    Thanks,
    Regina

    As Chris said, use the Distribute functions of the Align Palette. Assume a 5 x 5 array of circles separated by 20 points in each direction. You now want the array spacing to be 30 points.
    1. Black Pointer: drag a marquee selection across the top row of 5. Then click once on the leftmost one.
    2. Align Palette: Show Options. In the distance field of the Distribute area, enter 30. Click the Distribute Horiizontally button.
    3. Select and group each of the other four rows.
    4. Select the four rows and one of the top row's circles. Click once again on the selected top row circle.
    5. Align Palette: Make sure the 30 value is still there. Click the Distribute Vertically button.
    JET

  • Horizontal flowed layout

    I am creating a questionnaire and I would like to form to only display answered questions when I click the generate report button.
    For example:
    If the user has a question and they have the following options:
    The user selects Not Sure.
    Currently because the subforms are all the same and the logic is to only display answered questions, the form displays:
    Is there a way that I can set up the template to move the answer to the left so that the form does not show blank/white space?
    Thanks
    Yvette

    Oh, apparently I failed to make my point clear.
    Consider this example:
    [  ] Checkbox1     [  ] Checkbox2     [   ] Checkbox3
    [  ] Checkbox4
    Whenever I click on one of those checkboxes I would like to change the height of all checkboxes in the same row (this.h = ...)
    [Why this is necessary is too complicated to explain. These are forms that are part of fairly big environment with very specific reader add-ons .....]
    Thus: If I click on checkbox2 I would like to find the checkboxes with the same vertical position (in this case: checkbox1, checkbox2 and checkbox3) to change their heights.
    As it is a flowed layout checkbox4 has slipped over onto the next row. It is vertically further down in the current layout. Therefore I do not want to change its height.
    What I need, is not really the y-attribute of the checkbox, but the vertical position in the layout. I just cannot find an attribute that delivers this information.
    Does this make it clear?

  • Distance between columns

    Hi all,
    I know we have a property called distance between records to maintain distance between records, what property i have to set to maintain a distance between columns.....

    I use the following method often:
    Once you have all columns displayed on your canvas, select all of them, then use the pulldown menu: Layout, Align components. Set "Align To" to "each other", set "Vertically" to "None", and "Horizontally" to "distribute", then click ok.
    (In Forms 6i, the pull-down is Arrange, Align Objects.)

  • Distance between options in an af:selectOneRadio

    Hi
    Is it possible to control the distance between the options in an af:selectOneRadio component?
    I am currently making an af:selectOneRadio with horizontal layout. The users complain say that they would prefere a longer distance between the radio options and I have tried doing that by putting spaces in the end of the labels but the spaces are ignored and the distance therefore stays the same. How I can make this distance longer?

    try this between af:selectRadio
    <af:spacer width="4"/>regards
    srini

  • HorizontalList distance between elements

    Hello!
    I can't find the property that sets the distance between elements (horizontal distance).
    What is it please?
    Q2: Is there a preset way of making the HorizontalList scroll when the mouse is near the edge?
    Q3: How can I manually scroll the HorizontalList, say when a user presses a button?

    Thank you Alex!
    I will code the zone-proximity scroll, was just wondering if there was a preset shortcut for this.
    Is there a way to limit the number of elements shown precisely? By that I mean not just test until I get the desired width in pixels.
    This I need because I wanted the buttons that control the scrolling for the HorizontalList to reveal an entire element.

  • In latest version of MF there`s missing button, which was in previous version: between buttons back/forward and the typing bar there used to be little flash, which showed few last pages I have just browsed. How can I restore it?

    In latest version of MF there`s missing button, which was in previous version: between buttons back/forward and the typing bar there used to be little flash, which showed few last pages I have just browsed. How can I restore it?

    If you mean the drop marker then you can still get the History of the Back and Forward buttons if any by either Left-Click and hold for a second or by Right-Clicking them.
    If you still want the drop mark there also then there is this Extension at https://addons.mozilla.org/en-US/firefox/addon/backforward-dropmarker/
    Also the abbreviation for Firefox is '''Fx'''

  • HP Envy 17t-j100 Distance between USB Slots suggestion

    I intended this post as a recommandation for HP. 
    I have an HP Envy Touchsmart 17t-j100 and everything is excelent up until now.
    The only thing that is very annoying is the distance between USB ports. PLEASE increase the distance between USB ports for the future models. I have a lot of problems tryng to connect everything I need.
    Even if I try to open the DVD drive, it will stuck in my USB device. I mean how much difficult is to put a distance of 1 cm between them? 
    If the USB cables are the standard size, there are no problems but most of the USB devices nowadays are much more wider than a standard USB cable and I keep having problems.
    I mean it's a 17" laptop, there is plenty of space on the sides. In the end, it's better to drop the DVD drive and put a VGA slot instead, but with bigger distance between USB ports.
    I am planning to buy another ENVY in the future but I really want my new laptop to have USB ports with a wider distance bewtween them. 
    Thank you very much and I hope HP will take care of this little problem on the future models.
    Have a nice day.
    This question was solved.
    View Solution.

    Hi @catapara89 ,
    Thank you for visiting the HP Support Forums and Welcome. Thanks so much for taking the time to let us know of your suggestions on the USB slots. It is important and has been viewed.
    Have a great week.
    Thanks.
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the bottom to say “Thanks” for helping!

  • Calculating co-ordinate distances between specific atoms

    Hi,
    Below is some code to calculate distances between all pairs of atoms. However, i need to make it slightly more specific by only calculating the distance between certain pairs of atoms
    input
    ATOM 5 CA PHE 1 113.142 75.993 130.862
    ATOM 119 CA LEU 7 113.101 72.808 140.110
    ATOM 138 CA ASP 8 109.508 74.207 140.047
    ATOM 150 CA LYS 9 108.132 70.857 141.312
    ATOM 172 CA LEU 10 110.758 70.962 144.119
    e.g distance between all pairs for atoms 5, 119, 150 and 172 (say), last three columns are x,y and z co-ordinates
    code it self
    import java.util.*;
    import java.io.*;
    public class Distance {
    public static void main(String[] args) {
    System.out.println("***Campbells PDB Distance Calculator***" + "\n");
    new Distance();
    System.out.println("\nResults printed to file DistanceCalculations" + "\n");
    System.out.println("\nDue to nature of code, if rerun results will be appended to the end of previous run.");
    public Distance() {
    Vector atomArray = new Vector();
    String line;
    try{
    System.out.println("Enter PDB file:" + "\n");
    BufferedReader inputReader =new BufferedReader (new InputStreamReader(System.in));
    String fileName = inputReader.readLine();
    if ( fileName !=null) {
    BufferedReader inputDistance = new BufferedReader (new FileReader (fileName));
    while (( line = inputDistance.readLine()) !=null && !line.equals(""))
    Atom atom = new Atom(line);
    atomArray.addElement(atom);
    for (int j=0; j<atomArray.size(); j++) {
    for (int k=j+1; k<atomArray.size(); k++) {
    Atom a = (Atom) atomArray.elementAt(j);
    Atom b = (Atom) atomArray.elementAt(k);
    Atom.printDistance (a,b);
    } //if
    } //try
    catch (IOException e) {
    System.out.println("Input file problem");
    } catch (Exception ex) {
    System.out.println (ex);
    class Atom {
    public double x, y, z;
    public String name;
    public Atom(String s) throws IllegalArgumentException {
    try {
    StringTokenizer t = new StringTokenizer (s, " ");
    t.nextToken();
    this.name = t.nextToken();
    for (int j=0; j<3; j++) t.nextToken();
    this.x = new Double(t.nextToken()).doubleValue();
    this.y = new Double(t.nextToken()).doubleValue();
    this.z = new Double(t.nextToken()).doubleValue();
    catch (Exception ex) {
    throw new IllegalArgumentException ("Problem!!!! :-(");
    public String toString() {
    return "atom : " + name + "(x=" + x + " y=" + y + " z=" + z + ")";
    public double distanceFrom (Atom other) {
    return calculateDistance (x, y, z, other.x, other.y, other.z);
    public static double calculateDistance (double x1, double y1, double z1, double x2, double y2, double z2) {
    return Math.sqrt(Math.sqrt(Math.pow(Math.abs(x1-x2),2)+Math.pow(Math.abs(y1-y2),2))+Math.pow(Math.abs(z1-z2),2));
    public static void printDistance (Atom a, Atom b) {
    try{
    FileWriter fw = new FileWriter("DistanceCalculations", true);
    PrintWriter pw = new PrintWriter (fw, true);
    if
    (a.distanceFrom(b) <9){
    pw.println("Distance between " + a.toString() + " and " + b.toString() + " is " + a.distanceFrom(b));
    pw.flush();
    pw.close();
    } // if??
    } //try loop
    catch(IOException e) {
    System.out.println("System error");
    }

    ok, essentially
    want to calculate distance between to ranges. Say
    range 1 is the first three, range 2 the rest. THen
    calculate distance between all possible pairs between
    these two rangesYes - and no doubt that any number of people here could write it for you. But that's not what the forum is about. So what, exactly, is preventing you from doing it?
    Sylvia.

  • Flow Layout

    Hey,
    i got a little problem. I need to write a clozeTest in JavaFx and it´s not function like i want.
    The problem that i have, is that the text shouldn´t start on a new line in case he hasn´t enough place.
    * clozeStage.fx
    * Created on 03.06.2010, 13:17:03
    package progressbar;
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.text.Text;
    import javafx.scene.text.Font;
    import javafx.ext.swing.SwingTextField;
    import javafx.scene.layout.Flow;
    import javafx.scene.shape.Ellipse;
    import javafx.scene.paint.Color;
    import javafx.geometry.HPos;
    import javafx.scene.layout.Tile;
    import javafx.scene.layout.HBox;
    import javafx.scene.Group;
    import javafx.scene.layout.VBox;
    * @author Dori
    var tf: SwingTextField[];
    var luecken: String [];
    var test:Boolean;
    luecken = ["Ich werde gleich ausflippen. Ich","(lernen) dieses JavaFX. Ich finde das echt toll. Außerdem werde ich jetzt mal ein bisschen extrem langen dummen Text schreiben, damit ich überprüfen kann, ob das gute FlowLayout auch einen Umbruch macht.",
                "Das ist ein Test, ob er auch"," automatisch zwischen Wörtern trennen kann.", " Voila", "Ohyeah"];
    for(i in [0..10]){
         tf=SwingTextField {
         columns: 5
         text: ""
         editable: true
    Stage {
    title: "Application title"
    scene: Scene {
    width: 900
    height: 400
    content: [
    Flow{
    width:700
    hpos: HPos.LEFT
    content:[
    for (m in [0..20]){
    if(test == false){
    test = true;
    Text{
    content: luecken[m/2]
    font: Font{size:15}
    wrappingWidth:700
    else{
    test = false;
    tf[m]
    It would be nice if somebody could help me.
    Edited by: avalonne on Jun 7, 2010 3:51 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Answered (I think) in the second [Flow Layout|http://forums.sun.com/thread.jspa?threadID=5441485] topic.

  • What is the maximum distance between a time capsule and an airport express?

    What is the maximum distance between a time capsule and an airport express?

    You can only "extend" the signal one time, so you need to have the AirPort Express located approximately 1/2 to 2/3 of the distance from the Time Capsule to the area that needs more wireless coverage.
    I doubt that this will help much since you have a very challenging setup. Wireless is really only for "same room" or "nearby rooms" around the corner.
    To do this correctly you will need to use an Ethernet cable connection from the Time Capsule to the AirPort Express, which could then be located close to the xBox.
    If it is not possible to run the Ethernet cable, you might look at a pair of Ethernet powerline adapters to send a "psuedo" Ethernet signal over the AC wiring in your home.
    This will not be anywhere near the performance of a regular Ethernet cable, but it will likely be much better than wireless.
    Since Ethernet over powerline (EOP) is somewhat unpredictable, you would want to have a very clear understanding of the store's return policy in case things don't work out as hoped.  Any computer / electronics superstore will have a selection of powerline adapters to choose from.

Maybe you are looking for