karlomutschler
Programmer
Hi all,
to the Application Frame (JFrame) I have added a Status Bar in which to display the following information:
system date and time
status of the keys (CapsLock, NumLock, ScrollLock)
Any help and advice how to go about it is most welcome.
Kind regards,
Karlo.
This is the condensed code of my application
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class MainFrame_Test extends JFrame {
//Object Variables
JTextField messageField;
JTextField userField;
JTextField dateLongField;
JTextField capsLockField;
JTextField numLockField;
JTextField scrollLockField;
JTextField timeField;
public MainFrame_Test() {
//Frame title
setTitle("Frame Title"
;
setBounds(100, 80, 600, 400);
Container contentPane = getContentPane();
//StatusBar
Box sbar = Box.createHorizontalBox();
messageField = new JTextField(30);
messageField.setBackground(Color.LIGHT_GRAY);
userField = new JTextField(12);
userField.setText("User Name"
;
userField.setBackground(Color.LIGHT_GRAY);
dateLongField = new JTextField(18);
dateLongField.setText("Thursday, 6th November 2002"
;
dateLongField.setBackground(Color.LIGHT_GRAY);
//---->> how do I center the text ?
capsLockField = new JTextField(5);
capsLockField.setText("Caps On"
;
capsLockField.setBackground(Color.LIGHT_GRAY);
numLockField = new JTextField(5);
numLockField.setText("Num On"
;
numLockField.setBackground(Color.LIGHT_GRAY);
scrollLockField = new JTextField(5);
scrollLockField.setText("Scroll On"
;
scrollLockField.setBackground(Color.LIGHT_GRAY);
timeField = new JTextField(5);
timeField.setText("23:47"
;
timeField.setBackground(Color.LIGHT_GRAY);
sbar.add(messageField);
sbar.add(Box.createGlue());
sbar.add(userField);
sbar.add(dateLongField);
sbar.add(capsLockField);
sbar.add(numLockField);
sbar.add(scrollLockField);
sbar.add(timeField);
sbar.add(timeField);
contentPane.add(sbar, BorderLayout.SOUTH);
//To close the Frame
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args) {
MainFrame_Test mf = new MainFrame_Test();
}
} meistertools@gmx.net
to the Application Frame (JFrame) I have added a Status Bar in which to display the following information:
system date and time
status of the keys (CapsLock, NumLock, ScrollLock)
Any help and advice how to go about it is most welcome.
Kind regards,
Karlo.
This is the condensed code of my application
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class MainFrame_Test extends JFrame {
//Object Variables
JTextField messageField;
JTextField userField;
JTextField dateLongField;
JTextField capsLockField;
JTextField numLockField;
JTextField scrollLockField;
JTextField timeField;
public MainFrame_Test() {
//Frame title
setTitle("Frame Title"
setBounds(100, 80, 600, 400);
Container contentPane = getContentPane();
//StatusBar
Box sbar = Box.createHorizontalBox();
messageField = new JTextField(30);
messageField.setBackground(Color.LIGHT_GRAY);
userField = new JTextField(12);
userField.setText("User Name"
userField.setBackground(Color.LIGHT_GRAY);
dateLongField = new JTextField(18);
dateLongField.setText("Thursday, 6th November 2002"
dateLongField.setBackground(Color.LIGHT_GRAY);
//---->> how do I center the text ?
capsLockField = new JTextField(5);
capsLockField.setText("Caps On"
capsLockField.setBackground(Color.LIGHT_GRAY);
numLockField = new JTextField(5);
numLockField.setText("Num On"
numLockField.setBackground(Color.LIGHT_GRAY);
scrollLockField = new JTextField(5);
scrollLockField.setText("Scroll On"
scrollLockField.setBackground(Color.LIGHT_GRAY);
timeField = new JTextField(5);
timeField.setText("23:47"
timeField.setBackground(Color.LIGHT_GRAY);
sbar.add(messageField);
sbar.add(Box.createGlue());
sbar.add(userField);
sbar.add(dateLongField);
sbar.add(capsLockField);
sbar.add(numLockField);
sbar.add(scrollLockField);
sbar.add(timeField);
sbar.add(timeField);
contentPane.add(sbar, BorderLayout.SOUTH);
//To close the Frame
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args) {
MainFrame_Test mf = new MainFrame_Test();
}
} meistertools@gmx.net