1.

Solve : regarding programing?

Answer»

i have one problem. (how to make button in swing which come in a single column,and gap in EVERY button like
.....................button 1...............

....................button2............ .......

.....................button3........... .......



....plz give the solution...you can try this code.,.,. i cant give you the full JAVA Source codes of your problem,.,.,
but you can, make my code as a sample.,.,/* A program that ddetermined if the SECOND Number is a MULTIPLE of the first
* Programmer: Reynante C. Tancio
* Proram Title: Multiple.java
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;



public class Multiple extends JFrame {

int num1;
int num2;

private JLabel numLabel,Labelnum;
private JTextField numField,Fieldnum,print;
private JButton testButton;


public Multiple() {

super( "\t MULTIPLE NUMBERS" );

Container tanz = getContentPane();

tanz.setLayout( new FlowLayout() );

numLabel = new JLabel( "First integer:");
numField = new JTextField(4);


tanz.add ( numLabel );
tanz.add ( numField );


Labelnum = new JLabel( "Second integer:");
Fieldnum = new JTextField(4);
tanz.add ( Labelnum );
tanz.add ( Fieldnum );


testButton = new JButton("Test");
testButton.addActionListener(
new ActionListener() {
public void actionPerformed( ActionEvent e ) {

String num1,num2;
int n1, n2;

num1 = numField.getText();
num2 = numField.getText();

n1 = Integer.parseInt(num1);
n2 = Integer.parseInt(num2);


if ( n2 % n1 == 0 ) {

print.setText("The second number is multiple of the first.");

}


else {
print.setText("The second number is not a multiple of the first.");
}
}
}
);


tanz.add(testButton);

print = new JTextField(25);
print.setEditable (false);
tanz.add(print);


}


public STATIC void main ( String [] reynz ) {

Multiple my = new Multiple();

my.setSize(300,150);
my.show();

}

}


no try = no how



Discussion

No Comment Found