A larger JTextField

I want a text field that is about the size of a 3x5 card for users to enter information. It would be nice if they could use html too. what do i use?

I suggest that you do some reading about Swing from the tutorial here, rather than asking open-ended and random questions. It's obvious that you are in over your head and need to do some independent study.
http://java.sun.com/docs/books/tutorial/uiswing/index.html

Similar Messages

  • Swing JTextField becomes slow after entering large unicode text.

    Hi All,
    We are developing a Indian s/w in Java, where we are using Indic InputMethods for taking user input in Hindi.
    Things works fine for small amount of text entered into a JTextField, but when we try to enter large amount of hindi text (let's say 100+ lines), it becomes slow bit by bit, ultimately giving impression of a application hang.
    We are using linux OS (Mandrake 10.1) on intel boxes with 265 MB RAM.
    Can any one help?
    Thanks in advance.
    Sanjeev

    Hmm .. I think I may be aware of that cutting edge application ;)
    Kindly let me know the solution.
    Abhi.

  • How do I release memory when done with a large Image?

    I've got a sample program here. Enter a filename of a .jpg file, click the button and it will load and display a thumbnail of it. However memory is not released so repeatedly clicking the button will let you watch the memory use grow and grow. What should be done in the code to release the large original image once the thumbnail is obtained? Here's the class:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    import java.util.Iterator;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import javax.swing.*;
    public class ImageMemoryLeak extends JFrame implements ActionListener {
         private JLabel thumbnail = null;
         private JTextField tf = null;
         private JButton button = null;
         public static void main(String[] args) {
              ImageMemoryLeak leaker = new ImageMemoryLeak();
              try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }
              catch (Exception ex) { }
              leaker.showDialog();
         private void showDialog() {
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setBounds(100,100,200,200);
              setBackground(new Color(255,255,255));
              Container cont = getContentPane();
              cont.setBackground(Color.lightGray);
              cont.setLayout(new FlowLayout());
              thumbnail = new JLabel("thumbnail here");      
              cont.add(thumbnail);
              tf = new JTextField("type filename here");     
              cont.add(tf);
              button = new JButton("Load Image");
              button.addActionListener(this);
              cont.add(button);
              pack();
              setVisible(true);
         public void actionPerformed(ActionEvent e) {
              if (e.getSource() == button) {
                   String fname = tf.getText();
                   File f = new File(fname);
                   if (f.exists()) {                    
                        try {
                             // This is where a file is loaded and thumbnail created
                             Iterator<ImageReader> iter = ImageIO.getImageReadersByFormatName("jpeg");
                             ImageReader imgrdr = iter.next();
                             ImageInputStream iis = ImageIO.createImageInputStream(f);     
                             imgrdr.setInput(iis, true);
                             ImageReadParam param = imgrdr.getDefaultReadParam();
                             BufferedImage fullSizeImage = imgrdr.read(0, param);
                             imgrdr.dispose();     // is this enough?     
                             iis.close();               
                             int thWidth = 150;
                             int thHeight = 150;
                             int w = fullSizeImage.getWidth(null);
                             int h = fullSizeImage.getHeight(null);
                             double ratio = (double)w/(double)h;
                             if (w>h) thHeight = (int)((double)thHeight /ratio);
                             else if (w<h) thWidth = (int)((double)thWidth * ratio);
                             BufferedImage thumbImage = new BufferedImage(thWidth, thHeight, BufferedImage.TYPE_INT_RGB);
                             Graphics2D graphics2D = thumbImage.createGraphics();
                             graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                             RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                             graphics2D.drawImage(fullSizeImage, 0, 0, thWidth, thHeight, null);
                             // done with fullSizeImage now - how to release it though?
                             fullSizeImage.flush();     // doesn't seem to do the trick
                             ImageIcon oldicon = (ImageIcon)thumbnail.getIcon();
                             if (oldicon != null) oldicon.getImage().flush();
                             ImageIcon icon = new ImageIcon(thumbImage);
                             thumbnail.setIcon(icon);
                             thumbnail.setText("");
                             pack();
                        } catch (IOException e1) {
                             e1.printStackTrace();
                   else {
                        thumbnail.setText("file not found");
    }

    lecisco wrote:
    AndrewThompson64 wrote:
    lecisco wrote:
    I don't mind having GC getting to it but it's not doing so now. .. Isn't it? GC is only called when the JRE feels it is necessary. Definitive evidence of a memory leak is generally revealed by an OutOfMemoryError. Does the code throw OOMEs?Excellent point. I tried loading over and over to force an OOME. I found that after the memory footprint grew to about 750mb, it reset down to about 130mb again, so it seems that GC does eventually kick in. Perhaps what I have is fine.
    That question brings me to the code sample. Typing an image file name in a text field is soooo 1980s. It would take a long time and much hard work on the part of the person testing it, in order to get to an OOME.In my actual application I'm using drag-and-drop to specify the image. The text field was just to simplify the code sample. How you get the file location is not relevant for the question - it's how the resources are released. If you're saying my code is fine regarding and shouldn't be holding onto any resources, that's great. I'm not saying that. So far I've not looked closely at the code, and am no expert on resource caching in any case.
    ..I am looking to confirm I'm following best practices regarding image resources.Good show. There is too much rubbish code out there.
    ..With the code sample, you just have to specify one .jpg file and repeatedly click the button to see the memory grow, so there's no burden to type a new file each time.Oh right, my bad. I had presumed it required a different image each time. Still (grumbles) a file chooser to select the image file would not have gone astray - for us lazy types. ;)

  • How to capture the event on changing focus from a JTextField?

    Hi All,
    I have got a problem...
    I want to do something (say some sort of validations/calculations) when I change the focus by pressing tab from a JTextField. But I am not able to do that.
    I tried with DocumentListener (jtf01.getDocument().addDocumentListener(this);). But in that case, it's calling the event everytime I ke-in something in the text field. But that's not what I want. I want to call that event only once, after the value is changed (user can paste a value, or even can key-in).
    Is there any way for this? Is there any method (like onChange() in javascript) that can do this.
    Please Help me...
    Regards,
    Ujjal

    Hi Michael,
    I am attaching my code. Actual code is very large containing 'n' number of components and ActionListeners. I am attaching only the relevant part.
    //more codes
    public class PaintSplitDisplay extends JApplet implements ActionListener
         JFrame jf01;
         JPanel jp01;
         JTextField jtf01, jtf02;
         //more codes
         public void start()
              //more codes
             jtf01 = new JTextField();
              jtf01.setPreferredSize(longField);
              jtf01.setFont(new Font("Courier new",0,12));
              jtf01.setInputVerifier(new InputVerifier(){public boolean verify(JComponent input)
                   //more codes
                   System.out.print("updating");
                   jtf02.setText("updated value");
                   System.out.print("updated");
                   return true;
              //more codes
              jtf02 = new JTextField();
              jtf02.setPreferredSize(mediumField);
              jtf02.setEditable(false);
              jp01.add(jtf02, gbc);
              //more codes
              jf01.add(jp01);
              jf01.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              jf01.setVisible(true);
              //more codes
         public static void main(String args[])
              PaintSplitDisplay psp = new PaintSplitDisplay();
              psp.start();
         public void actionPerformed(ActionEvent ae)
              //more codes
    }As you can see I want to update the second JTextField based on some calculations. That should happen when I change the focus from my frist JTextField. I have called jtf02.setText() method inside InputVerifier. But it's giving error...
    Please suggest...
    Ujjal

  • Reading data from a text file into a JTextField

    So I am writing a program that will write to and read from a large database. I was hoping to allow a graphical interface for the reading of the data, but I keep getting an error;
    Incompatible Types
    Found: java.lang.string
    Required: javax.swing.JTextField
    Now I know that this means the are incompatible (like trying to give an integer variable a string command) but I can't find any documentation on how to change the String into a JTextField format. I've found several references on how to do the reverse, but with my lack of JAVA knowledge I can't seem to get it to work. (Tried things like getText() and the like, but just end up with more errors).
    *On a side note, is there an easier way to go about reading a file line by line, with each line going into a seperate JTextField, than;
    BufferedReader r;
    try {
    r = new BufferedReader(new FileReader("C:\\temp\\test.txt"));
    while ((thisLine = r.readLine()) != null) {
    array[i] = thisLine;
    i = i + 1
    and then assigning each JTextField it's own array slot?*
    Thank you for your help.

    Try something like this for putting the text in a control:
    import java.awt.Dimension;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    public class Junk{
      String[] s = {"This is String 1.", "This is String 2.", "This is String 3."};
      Junk(){
      public void makeIt(){
        JFrame j = new JFrame("Forum Junk");
        j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel p = new JPanel();
        p.setPreferredSize(new Dimension(300, 200));
        JTextArea jt = new JTextArea();
        p.add(jt);
        j.add(p);
        jt.setText(s[0]);
        jt.append("\n\r"+s[1]);
        jt.append("\n\r"+s[2]);
        j.pack();
        j.setVisible(true);
      public static void main(String[] args) {
        Junk j = new Junk();
        j.makeIt();
    }Depending on your design you may be able to do away with your array and append the text directly to the JTextArray after each line is read.

  • JTextField/JTable-cell Button

    Is there any known efficient methods of creating the JTextField or JTable-cell Button as like in Forte's Component Inspector window where you click on the property value field and the value is displayed just left of a small button labelled "..." ie: [some text field with value][...] also referred to as the "ellipsis" buttons, or will most answers to this question simply describe the layout of a JField-JButton combination? The action from clicking on the [...] button aligned right of the JTextField simply invokes or displays a larger input interface in which upon completion of the entered data, returns the input to the related JTextField.
    Thanks to anybody for any help with this, and perhaps in return, I may be able to answer any non-gui java questions, or some not so unfamilliar GUI questions.

    Hello StanislavL and Lutianxiong,
    I remember asking this question some time ago, and the time has come again for me to seek this functionality. I have finally achieved the functionality and thought I would post the answer for anybody else. I had not realized that I had recieved a solution/reply to my original question as I come here to post the answer, and in fact, my solution does appear to be very similiar to your reply, StanislavL. As for you, Lutianxiong and other seekers of this info, here is my solution with a JFileChooser style input for the 3rd column which only shows gif,jpg and png files:
    <code>
    ------------- TableCellFileInput.java -------------------
    public class TableCellFileInput extends javax.swing.JPanel {
    private String extensions[];
    public TableCellFileInput(String fileExtensions[]) {
    extensions = fileExtensions;
    self = this;
    initComponents();
    private void initComponents() {
    valueField = new javax.swing.JTextField();
    fileButton = new javax.swing.JButton();
    setLayout(new java.awt.BorderLayout());
    valueField.setText("jTextField1");
    add(valueField, java.awt.BorderLayout.CENTER);
    fileButton.setText("...");
    fileButton.setMargin(new java.awt.Insets(0, 2, 0, 2));
    fileButton.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    fileButtonActionPerformed(evt);
    add(fileButton, java.awt.BorderLayout.EAST);
    private void fileButtonActionPerformed(java.awt.event.ActionEvent evt) {
    String filePath = valueField.getText();
    if(filePath != null && filePath.length() > 0) {
    filePath = new java.io.File(filePath).getParent();
    javax.swing.JFileChooser chooser
    = new javax.swing.JFileChooser(filePath);
    chooser.setFileFilter(new ImageFilter());
    int returnVal = chooser.showOpenDialog(this);
    if(returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
    valueField.setText(chooser.getSelectedFile().getAbsolutePath());
    class ImageFilter extends javax.swing.filechooser.FileFilter {
    public boolean accept(java.io.File f) {
    if(f.isDirectory()) return true;
    String fName = f.getName();
    if(extensions != null) {
    for(int i=0;i<extensions.length;i++) {
    if(fName.endsWith(extensions[ i ])) return true;
    return false;
    public String getDescription() {
    return DESCRIPTION;
    class CustomCellEditor extends javax.swing.AbstractCellEditor
    implements javax.swing.table.TableCellEditor {
    public Object getCellEditorValue() {
    return valueField.getText();
    public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, Object value, boolean isSelected, int row, int column) {
    System.out.println("fileEditor");
    if(value == null) valueField.setText("");
    else valueField.setText(value.toString());
    return self;
    public void setColumn(javax.swing.table.TableColumn column) {
    column.setCellEditor(new CustomCellEditor());
    private javax.swing.JButton fileButton;
    private javax.swing.JTextField valueField;
    private static final String DESCRIPTION = "Image File Filter";
    private java.awt.Component self;
    ------------- TestTable .java -------------------
    public class TestTable extends javax.swing.JFrame {
    public TestTable() {
    editorField = new javax.swing.JTextField();
    String fileExts[] = {"gif","jpg","png"};
    fileEditorField = new TableCellFileInput(fileExts);
    initComponents();
    javax.swing.table.TableColumn column
    = jTable1.getColumn("Title 3");
    fileEditorField.setColumn(column);
    private void initComponents() {
    jScrollPane1 = new javax.swing.JScrollPane();
    jTable1 = new javax.swing.JTable();
    addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowClosing(java.awt.event.WindowEvent evt) {
    exitForm(evt);
    jTable1.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {
    {null, null, null, "cats"},
    {null, null, null, "dogs"},
    {null, null, null, "mice"},
    {null, null, null, "birds"}
    new String [] {
    "Title 1", "Title 2", "Title 3", "Title 4"
    Class[] types = new Class [] {
    java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.String.class
    public Class getColumnClass(int columnIndex) {
    return types [columnIndex];
    jScrollPane1.setViewportView(jTable1);
    getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width-400)/2, (screenSize.height-300)/2, 400, 300);
    private void exitForm(java.awt.event.WindowEvent evt) {
    System.exit(0);
    public static void main(String args[]) {
    new TestTable().show();
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField editorField;
    private TableCellFileInput fileEditorField;
    </code>

  • JTextField array

    I�m using an array of jTextFields within a pane and I want to know which of this jTextFields was edited. I used the getSource method but I cannot interpret the data since I don�t get the index of the jTextField.

    Or, if you really do want to know which field was editted, here's one possible solution
    import javax.swing.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.*;
    public class JTextFieldTester extends JFrame implements ActionListener{
        JTextField[] fields;
        public JTextFieldTester() {
            JPanel mainPane = (JPanel) getContentPane();
            mainPane.setLayout(new GridLayout(5,0,5,5));
            fields = new JTextField[5];
            for (int i = 0 ; i < 5 ; i++){
                fields[i] = new JTextField(20);
                fields.setName(""+i);
    fields[i].addActionListener(this);
    mainPane.add(fields[i]);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    setLocationRelativeTo(null);
    setVisible(true);
    public void actionPerformed(ActionEvent e) {
    Component comp = (Component) e.getSource();
    if ( comp instanceof JTextField) {
    System.out.println(comp.getName());
    public static void main(String[] args) {
    new JTextFieldTester();
    This depends on user hitting enter after editting but you can do simular things with other types of events. The major point is that by assigning a name to each field you can rapidly determine which field fired the event. This is probably far more efficient for very large arrays of tields.
    Good Luck
    DB

  • Custom text painting using JTextField

    Greetings all!
    I would like to implement a custom JTextField that displays text in gradient colors instead of the usual solid colors.
    I guess I would need to override the default painting mechanism in JTextField, but I'm not sure how to go about it.
    Would appreciate if anyone can give me any suggestions/tips!
    Thanks so much!
    Dora
    public class GradientTextField extends JTextField {
    }

    it will work only if the size of the textfield is large enough (no scrolling).Good point. Here's a newer version that seems to work ok, assuming the text is left justified.
    import java.awt.*;
    import javax.swing.*;
    public class GradientTextField extends JTextField
        private Color from;
        private Color to;
        private Insets insets;
        private Point view = new Point();
        public GradientTextField(Color from, Color to)
            this.from = from;
            this.to = to;
            insets = getInsets();
        public void paintComponent(Graphics g)
            setForeground( getBackground() );
            super.paintComponent(g);
            //  Get the text to paint, assuming left justification
            getInsets( insets );
            view.x = insets.left;
            view.y = insets.top;
            int offset = viewToModel( view );
            String text = getText().substring(offset);
            //  Create the GradientPaint object
            FontMetrics fm = g.getFontMetrics();
            int width = fm.stringWidth( text );
            int x = insets.left;
            int y = fm.getAscent() + insets.top;
            GradientPaint paint = new GradientPaint(x, 0, from, x + width, 0, to);
            //  Use the GradientPaint object to overwrite the existing text
            Graphics2D g2d = (Graphics2D)g;
            g2d.setPaint(paint);
            g2d.drawString(text, x, y);
        public static void main(String[] args)
            JTextField textField = new GradientTextField(Color.blue, Color.green);
            textField.setText("ABCDEFGHIJKLMNOPQRSTUVWZYZ");
            JFrame frame = new JFrame("Gradient Text Field");
            frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            frame.getContentPane().add(textField, BorderLayout.SOUTH);
            frame.pack();
            frame.setLocationRelativeTo( null );
            frame.setVisible(true);
    }It's probably not a complete solution, but it may be helpful is specific situations.

  • JTextField - Maximum size

    Hi,
    I've got a JTextField component which contains the content of a file. This file can be very large (>10Mo).
    I fall in memory exception with a file size of 10 Mo but my program runs correctly with a file size < 5 Mo.
    Is there a solution for the treatment of very large files.
    Thanks for your help.

    A JTextField is used to display a single line of text.
    JTextArea/JTextPane are used to display multiple lines of text.

  • Preventing user to enter chars in a JTextField

    Hello,
    I'm working on a small "calculator" applet. I'm pretty much done, except for a couple of problems:
    First I would like to prevent the users to enter non-numeric characters in the JTextField where the numbers go, but I have no idea how to go about that.
    The other thing is that all my JButtons don't show their set text (like +,-,/ , etc) instead they all show "..." , as if the text was too big for the button. I can get the text to show if I enlarge the buttons enough, but I end up with insanely large buttons, and the text is in reality quite small. Any way to decrease the size of the text inside the button? (i'm using setBounds() for positions and sizes by the way).

    Hello,
    I'm working on a small "calculator" applet. I'm
    pretty much done, except for a couple of problems:
    First I would like to prevent the users to enter
    non-numeric characters in the JTextField where the
    numbers go, but I have no idea how to go about that.See JFormattedTextField and MaskFormat in the JavaDocs.
    >
    The other thing is that all my JButtons don't show
    their set text (like +,-,/ , etc) instead they all
    show "..." , as if the text was too big for the
    button. I can get the text to show if I enlarge the
    buttons enough, but I end up with insanely large
    buttons, and the text is in reality quite small. Any
    way to decrease the size of the text inside the
    button? (i'm using setBounds() for positions and
    sizes by the way).Don't. Use a LayoutManager. For a calculator, a group of nested GridLayout Panels should work.
    Jim S.

  • JTextField's default keybindings are disabled  (cut, paste ...)

    Hi,
    The default keybindings for JTextField (ctrl-c for copy, ctrl-x for delete, ctrl-v for paste) on windows platform are not working in my application. They do work per samples in java tutorials. These are of course "standalone".
    So, there is something in my program (reasonably large ) that is causing this default behaviour to change. Any clues ?.
    I disabled UIManager and it' look-n-feel changes. I don't recollect changing JTextField or it's ancestors. (JTextComponent ...)
    Much thanks
    /rk

    If you app. is not 'standalone' is it 'sitwithfriends'? I meant "independent". Anyway your comment is funny :-)
    I have solved my problem. I have explicitly created bindings.
    ctrl-c --> Action
    via InputMap and ActionMap.
    But, my original question is un-answered. I have not made any changes to JTextComponent or JTextField. Yet in my large program JTextField's keybindings are not working as they do in an "independent"/"standalone" program. My program is a pure swing based desktop program. I have not touched the SecurityManager. It is not an applet.
    Cheers ...
    /rk

  • Large os file type icon

    Hi,
    I using FileSystemView to get file type icon. But the icon dimension i am getting is either 16x16 or 32x32.
    Can any one tell me, how to get bigger icons like windows vista have large icons view. upto 256x256

    Mayby this code can help:
        FileSystemView view = FileSystemView.getFileSystemView();
         ShellFolder shellFolder = ShellFolder.getShellFolder(new File("xx.gif"));
    import java.io.File;
    import java.io.IOException;
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.JLabel;
    import javax.swing.BoxLayout;
    import javax.swing.filechooser.FileSystemView;
    import sun.awt.shell.ShellFolder;
    public class FileIconExtractor extends JFrame implements ActionListener{
    private JButton getIconBtn = new JButton("get Icon");
    private JPanel iconPanel = new JPanel();
    private JTextField extField = new JTextField();
    private JLabel smallIconLabel = new JLabel("small Icon here");
    private JLabel bigIconLabel = new JLabel("big Icon here");
    public FileIconExtractor() {
    this.setSize(200, 150);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setLayout(new BorderLayout());
    getIconBtn.setActionCommand("GETICON");
    getIconBtn.addActionListener(this);
    iconPanel.setLayout(new BoxLayout(iconPanel, BoxLayout.Y_AXIS));
    iconPanel.add(smallIconLabel);
    iconPanel.add(bigIconLabel);
    this.add(extField, BorderLayout.NORTH);
    this.add(iconPanel, BorderLayout.CENTER);
    this.add(getIconBtn, BorderLayout.SOUTH);
    this.setVisible(true);
    public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("GETICON")) {
    String ext = extField.getText();
    File file;
    try
          file = File.createTempFile("icon", "." + ext);
          FileSystemView view = FileSystemView.getFileSystemView();
          Icon smallIcon = view.getSystemIcon(file);
          ShellFolder shellFolder = ShellFolder.getShellFolder(file);
          Icon bigIcon = new ImageIcon(shellFolder.getIcon(true));
          setIconLabel(smallIcon, bigIcon);
          file.delete();
    catch (IOException ioe)
    ioe.printStackTrace();
    private void setIconLabel(Icon smallIcon, Icon bigIcon) {
    smallIconLabel.setIcon(smallIcon);
    bigIconLabel.setIcon(bigIcon);
    public static void main(String[] args) {
    FileIconExtractor fie = new FileIconExtractor();
    }

  • Problems with JTextField

    I'm having a very odd problem with a JTextField. I've got on which I'm using to enter barcodes from a barcode scanner. When I type the barcode in manual it works fine, but when I scan the barcode in I get ?'s in random positions. If I scan the barcode in more than once I get the ?'s in different places.
    There is nothing wrong with the scanner because I can quite happily scan barcodes directly into a text document. Any thoughts?

    - As suggested earlier you should test the scanner
    with other text components... JTextArea for exampleI tried a JTextArea and a JTextPane last night an both had the same problem. I also tried using a KeyListener. This printed out the ?'s when I used the getKeyChar() method of KeyEvent but printed some very odd (large 10 digit) numbers when I used the getKeyCode() method.
    - Determine if the characters encoded in the bar-code
    can be displayed with the font that is being used with
    the text fields.Mmmm, not sure how to do this.
    - Determine if the symbology you are trying to de-code
    is configured correctly (and the bar-code reader is
    set up to read it correctly) Be aware that some codes
    have leading "guard" characters which the reader may
    not be removing (this has to be set in the scanner
    itself)The is no configuration for the scanner that I know of. Not sure what these "guard" characters are - maybe they are the ones I'm getting on the KeyListener.
    Built a version of the GUI quickly in Visual Basic 6 (grrrrr) and when I entered numbers into a TextBox there were no problems. Could this be a Java bug?
    Thanks to everyone for your help so far. Any more thoughts?

  • Output formatted number to jTextField

    I am new to Java and am building a desk top application. I perform the calculations and get the correct answer in the jTextField; however, I have been unable to get the answers to format. The numbers are "doubles" at this point in the calculations. I have tried several different variations of the code I am posting below and nothing works. All the answers I have found on the web and in books are set up for a System.out.println() answer as opposed to putting the answer in a jTextField. I believe the problem is between the formatting and putting the answer into the jTextField, but am uncertain. I would appreciate any suggestions to alleviate this problem.
    Thanks - Bob
    if ( M1 > M2) {
    NumberFormat numberFormat = NumberFormat.getInstance();
    DecimalFormat decimalFormat = (DecimalFormat)numberFormat;
    decimalFormat.applyPattern("0.### ### ### ### ### ### ###");
    jTextField3.setText(String.valueOf(MDiff));
    jTextField4.setText(String.valueOf(EDiff));
    else {
    NumberFormat numberFormat = NumberFormat.getInstance();
    DecimalFormat decimalFormat = (DecimalFormat)numberFormat;
    decimalFormat.applyPattern("###,###,###,###,###,###,###");
    jTextField3(setText(String.valueOf(MDiff));
    jTextField4.setText(String.valueOf(EDiff));
    }

    The numbers are entered as text, and then converted to a "float" variable. They are then changed to "double" and multiple computations take place. The code that I posted is after the computations of MDiff and EDiff, and covered the "logical if" where I test to see which of two numbers from the initial data entry was larger and format appropriately. There was error in my post which I have corrected. The error was in the 4th line below "else" where it states: "jTextField3(set....." I have changed it to read "jtTextField3.set....", and it builds without error. Sorry about that.
    As previously stated, I get correct answers from the computations, but am unable to format the answers.
    Bob

  • How large of a hard drive can I install on dual G5, and do I need more RAM?

    I recently had a situation in which my dual-processor 2.0 G5 was completely refurbished by Apple repair-new logic board, both processors, video card, thermistor, all new. Finally it has been working well after a month of trips back and forth from the Apple store. I have two internal hard drives installed on my G5, both 300GB, one for OS applications, and one for audio. I am running out of space on my main hard drive, and so I recently purchased a Maxtor 1TB hard drive, now manufactured by Seagate, from Fry's. After having my G5 refurbished, I was having an issue with my Samsung 930B monitor going into sleep mode when I boot-up from a CD, but other than that G5 was working fine. I removed the main 300GB hard drive from slot #1 and put it into slot #2, from which I had removed my audio hard drive. I installed the Maxtor drive in slot #1 and reformatted it for Mac using my laptop with ATA/USB cables previously purchased for data transfer. This took about 14 hours as I used the "zeros" option. After that I hooked up the internal cables to both drives and tried to boot up from Leopard in order to install it on the Maxtor drive, but again my monitor went into to sleep mode. We went to the Apple store to try to see if there was an issue with the computer, but everything worked fine with their monitors and CD's, as well as my CD. So there is some kind of issue with my monitor, probably software as it works fine when booting up from the main hard drive, and also was fine when I did its self-test function. While at the Apple store, they installed Leopard from their hard drive which took about 30 minutes.
    My problem is this: When I arrived home, I turned on my G5, which had been set to boot from my new Maxtor drive and complete the Leopard setup process, which we had decided to do at home as it would have taken another 20 minutes in the Apple store. The G5 turned on, chimed, I got the Apple screen with the wheel, but then after that my monitor goes into sleep mode. I can hear Leopard's setup intro playing through the speakers, but the screen is in sleep mode. So I reboot holding down the option key so I can boot up from my old (300GB) main hard drive, now in slot #2. This works and the monitor screen does not go to sleep. However, as I am browsing on the web to check for issues concerning this monitor, the G5 freezes, and I get a screen with black bars with writing in them and various technical language across the screen. This happened several times after rebooting. Finally I shut the computer down. I am going to try removing the new hard drive and putting both old ones back in and see if the G5 stops crashing. I think the monitor issue is a separate issue, and I am more concerned with the crashing, as previous to the new hard drive installation the G5 was working fine, monitor fine, other than the issue when booting up from a CD. Do I need more memory? Is the 1TB hard drive too large for my dual-processor 2.0 G5 and overloading it? Would I be better off with a 500GB drive? Would appreciate advice from persons with experience in this area. Thank you.

    I have replaced my 5 year old G5 with a Mac Pro, as the G5 just had too many issues, even after replacing all major components (logic board, both processors, video card, etc.) Once I took out the 1 TB hard drive from my old G5, it stopped having the kernel panic issue. Nonetheless I had been through a lengthy repair process previous to this issue, so I didn't care to trust an older machine any longer, especially since being told by an Apple tech that the "new" parts were really just older parts stockpiled from a central location. Could be new, could be refurbished. Apple was kind enough to credit the money we had spent on the G5 repairs towards the purchase of my Mac Pro.

Maybe you are looking for

  • Insert into database table

    Hi Guy's, Please help me, trying to insert the records into database table. when i debug the program work area contain  data records  but not insert into databse table.  Here pasted my code pls suggest me where i did mistake. FUNCTION ZEXM_PHOTOCOPYD

  • Can't change external editor. Why?

    I use iPhoto 6.0.3. I have Photoshop installed and was using it as the external editor in iPhoto. I've not bought and installed Photoshop Elements 4 and installed it. If I Control click on a photo in iPhoto, the only option I still have is Photoshop.

  • Ipod nano (new) no sound on resumption

    I have downloaded my audible books without problem, but when I resume listening the following day, having cancelled "hold", the reading starts up on the time bar but there is simply no sound.If I then reset I am returned to zero and have to scrub for

  • Migration assistant restart

    Fired up new iMac today and migration from Windows XP PC to iMac stopped after 3 hours.  That was using wireless on the iMac.  So now trying to restart with wired connection but iMac says 'looking for other sources' and PC 'waiting for you Mac to con

  • Random people use my printer all the time :(

    Hi. I have a USB printer connected to my airport express. My airport is connected via ethernet to a subnet in the college dorm where I live. Unfortunately, random people are always printing on my printer. I know there is no way to put a password on t