cheers
public class StockTicker extends JFrame
{
String firstRow[] = {"1","2","3","4","5","6","7","8","9","0","Back\nSpace"};
String secondRow[] = {"Q","W","E","R","T","Y","U","I","O","P"};
String thirdRow[] = {"A","S","D","F","G","H","J","K","L","Enter"};
String fourthRow[] = {"Z","X","C","V","B","N","M","."};
JButton first[] = new JButton[11];
JButton second[] = new JButton[10];
JButton third[] = new JButton[10];
JButton fourth[] = new JButton[8];
public StockTicker()
{
super ("A Simple Stock Market GUI");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
initWidgets();
}
private void initWidgets()
{
JLabel jlOutput = new JLabel("Output: ");
JLabel jlInput = new JLabel("Intput: ");
final JLabel jtfOutput = new JLabel("");
final JLabel jtfInput = new JLabel();
setLayout(new BorderLayout());
JPanel jpNorth = new JPanel();
JPanel jpCenter = new JPanel();
JPanel jpKeyboard = new JPanel();
add( jpNorth, BorderLayout.NORTH);
add( jpCenter, BorderLayout.CENTER);
add(jpKeyboard, BorderLayout.SOUTH);
jpNorth.setLayout(new BorderLayout());
jpNorth.add(jlOutput, BorderLayout.WEST);
jpNorth.add(jtfOutput, BorderLayout.SOUTH);
jpCenter.setLayout( new BorderLayout());
jpCenter.add(jlInput, BorderLayout.WEST);
jpCenter.add(jtfInput, BorderLayout.CENTER);
jpKeyboard.setLayout(new GridLayout(4,1));
pack();
for(int i = 0; i < firstRow.length ; i++)
{
first[i] = new JButton(firstRow[i]);
jpKeyboard.add(first[i]);
}
for(int i = 0; i < secondRow.length; i++)
{
second[i] = new JButton(secondRow[i]);
jpKeyboard.add(second[i]);
}
for(int i = 0; i <thirdRow.length; i++)
{
third[i] = new JButton(thirdRow[i]);
jpKeyboard.add(third[i]);
}
for(int i = 0; i < fourthRow.length; i++)
{
fourth[i] = new JButton(fourthRow[i]);
jpKeyboard.add(fourth[i]);
}
}
public class Main
{
public static void main(String[] args)
{
JFrame window = new StockTicker();
window.setSize(600,500);
window.setVisible(true);
}
}
}

New Topic/Question
Reply



MultiQuote




|