Jframe text scaling

Hi,
I would be very grateful for some help. I need to create window with some text inside (given size). This text have to be centered horizontally and vertically. After window is resized it should scale respectively.

This one I hope will satisfy requirements ;) So the question is:
How do I make this text scale with window when it is resized?
import java.awt.*;
import javax.swing.*;
public class Test extends JFrame {
public void text(){
  int fontSize = 32;
  setLayout(new BorderLayout());
  JLabel label = new JLabel("KONIEC");
  label.setFont(new Font("Helvetica", Font.BOLD, fontSize));
  label.setVerticalAlignment(SwingConstants.CENTER);
  label.setHorizontalAlignment(SwingConstants.CENTER);
  add(label, BorderLayout.CENTER);
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  setVisible(true);
  pack();
public static void main(String args[]){           
  new Test().text();
}Edited by: user10509371 on Dec 5, 2010 1:16 PM

Similar Messages

  • Text scaling

    My knowledge on vectoring is not good, and I think this is the issue.  But need some help trying to understand text.  I understand that it's bitmap based not vector and therefore can become pixelated if text is reduced/enlarged.  I've heard (correct me if I'm wrong) that text can be vectored in potoshop (like Illustrator) so that the document's text will come out razor sharp at whatever size the document is printed at.  If so, how do I do this exactly?
    Thanks

    Dougnik12 wrote:
    "It will be in vector form until you deliberately Rasterize it."
    Yes I understand it's fully scalable until you Save it (is this what Rasterize means?), but what is the point of photoshop then converting it to bitmap, is there anyway the vector text can be maintained upon saving, because the quality reduces as soon as you save, or should I be looking at Illustrator to do the text properly?
    Rasterize is an option in the Layers drop down menu... it converts a vector object to a bitmap object. (In this case, your text.)You may need to do this – rasterize – for several reasons, including using certain filters or creating certain effects. If you don't need to rasterize the text, leave it as it is.
    As long as you don't convert the text layer by rasterizing, it will remain a vector and stay editable (and infinitely scalable) no many how many times you save the file as a PSD (Photoshop file). The moment you save as a .tiff, .jpg, etc the text gets rasterized and as no longer editable in that file.
    Hope that explains it....

  • Fix text scaling on Youtube?

    Hi Firefox Support! I have a 3k monitor on my Laptop and Youtube has really small text on its UI. This doesn't happen to me on any other browsers like Chrome and IE. Is there a way to fix it or do I wait for an update?
    Thanks! I have a sample photo below.

    Is the video and other parts of the page the same size as normal? It's possible the page could be zoomed out. Try resetting the zoom by clicking on the three-bar menu icon in the top right. You should see + and – signs with a percentage in the middle. Try clicking on that percentage to reset the zoom.

  • Text scaling/resizing?

    So when I format all my text in Iweb it's perfect, however when I veiw it in safari or Chrome the text gets all messed up. The reason for this is because when the browser is zoomed in or out it reformats and enlarges or shrinks the text.
    is there someway I can lock the text so it can't resize the text in a browser?
    (hold command + or - to zoom in or out on a browser)

    You can convert the text boxes and text to image files by applying an drop shadow with 5% opacity.
    Click to view full size
    However, there are two downsides to this: 1- the text will not be available to search engines and: 2-the image files will take longer to load than just text and that can impact the loading speed of the page.
    OT

  • Magic Move not scaling text

    Hi - despite assurances from the manual and the help files, I cannot get Magic Move to scale and move a text box - it just dissolves instead. This from a single slide with nothing else on it, duplicated and then the text moved and resized.
    Any ideas?

    Using Grab or any other screen grab application will indeed copy the background color behind the text. In some cases that won't matter, but if you have a gradient background color or something more complex than a solid color, it could be an issue. Also, if you have another object behind the grabbed text, the background will also be visible. Instant Alpha can help, but we can detect flaws in text more than in other graphics, so the results may be disappointing.
    If you do use the screen grab method, if backgrounds are not a problem, and your text is being scaled up, then use this technique with the text created in Keynote in its largest size, and then copy and paste accordingly across the Magic Move transition. Since you are creating bitmapped images, text will look a bit chunky if scaled up too large, but scaling down will look fine. Keep in mind you can "reverse engineer" a Magic Move (i.e. create an object in the second slide, copy and paste it into the first, scale down, etc.).
    Or you can avoid all this work and just created the vector-based text from another app, as I outlined in my previous post. All issues of backgrounds and text scaling are eliminated.

  • Text displays in wrong size

    Hi,
    I'm working on a Flash presentation, and I have a lot of text pages with buttons and movie clips on. The problem I have is that all subheads are set to size 35pt using Helvetica Neue Heavy, but on a couple of the pages a random subhead is displaying a lot larger than 35pt (I'd say 50pt) but it is definitely set to size 35pt in the Character palette. I have no idea why this is happening and it's driving me mad. Please can someone help me, I need to get this problem solved by Monday?
    Kind regards

    If the text is assigned as the correct size, then it might be a case where you have something that contains the text scaled larger.  You could try selecting the text or whatever contains it and then in the top menu choose Modify -> Reome Transform and see if that helps (might need to do it a couple times)

  • Screen resolution too high - text is tiny - how to change?

    I'm a newbie to Audition, and spent 2.5 hours this weekend editing a 6.5 minute talk. Ended up with a massive headache, largely because of the small size of the text in the screen menues, etc.
    Anyone know how to change these? I Use a MS Surface 3 pro with very high resolution (21160*1440)  with a 22" screen set at 1680 *1050 (max for the screen) .
    Any help would be greatly appreciated...
    Pounding head...
    Mike Bland

    You don't mention which version of Audition you are using, but support for High DPI displays was added to Audition and other Adobe applications last year.  This adds support for icon and text scaling, which is configured at the OS level.  Found a good overview and write-up about this at How to Make the Windows Desktop Work Well on High-DPI Displays and Fix Blurry Fonts but the quick-and-dirty method is to right-click on your Windows desktop and choose Screen Resolution then click on the item Make text and other items larger or smaller.  There, you can select scaling at 125% and 150%.  You'll probably need to log back into your Windows account for the change to take effect.

  • Characteristic texts from Query in APD

    Hello Comiunity,
    In BI 7.0 Iu2019ve created an Query. This Query shows (long) texts for characteristic. When I use the Query in BEx Web Analyzer and BEx Analyzer these texts are displayed correctly.
    Now I have to use the Query as a source in an analysis process in the APD. Result of this analysis process is a CSV file. It seems like the APD doesnu2019t work with the texts for the characteristic. In the result CSV file only the keys of the charactersisics are show u2013 not the texts.
    How can I use characteristics texts in APD? At moment I join the text tables of the characteristics. But is there a more elegant solution for this problem?
    Kind Regards,
    Andreas

    Hi Andreas,
    unfortunately not. APD does only consider the keys (internal presentation) and ignores all kinds of query output properties (display like text, scaling key figures etc.).
    Apparantly, you want to persist the query result in a way which is close to the Bex output, right? I would guess that APD is not suitable for that.
    Cheers!
    Thomas

  • Illustrator CC 2014 UI scaling issue

    Hi. Why the new Adobe Illustrator CC (2014) show the toolbox and tool to much large in the screen. I have the two software install in my computer
    Look the differences between the screen:
    Thanks for the help if you know the problem.
    MHCDESIGN

    That really doesn't fix anything. My computer is already scaled to 125%, and everything else is properly scaled. Here is a side by side on-screen comparison (CC on the left, CC 2014 on the right, and text scaled to 125%). I was annoyed at first that CC 2014 didn't update and replace CC, but now I'm glad, because until this issue is resolved I won't be using CC 2014.

  • Help!  Using GUI button to update text file

    Desperately needing help on the following:
    As you will see, I have created two classes - one for reading and writing to a text file on my hard drive, and one for the GUI with two buttons - Display and Update. The Display button works perfectly in that it displays text from a file path. The Update button, however, does not work correctly. I seek for the Update button to update any edits to the same exact text file I view using the Display button.
    Any help would be greatly appreciated. Thanks!
    Class TextFile
    import java.io.*;
    public class TextFile
        public String read(String fileIn) throws IOException
            FileReader fr = new FileReader(fileIn);
            BufferedReader br = new BufferedReader(fr);
            String line;
            StringBuffer text = new StringBuffer();
            while((line = br.readLine()) != null)
              text.append(line+'\n');
            return text.toString();
        } //end read()
        public void write(String fileOut, String text, boolean append)
            throws IOException
            File file = new File(fileOut);
            FileWriter fw = new FileWriter(file, append);
            PrintWriter pw = new PrintWriter(fw);
            pw.println(text);
            fw.close();
        } // end write()
    } // end class TextFileClass TextFileGUI
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class TextFileGUI implements ActionListener
        TextFile tf = new TextFile();
        JTextField filenameField = new JTextField (30);
        JTextArea fileTextArea = new JTextArea (10, 30);
        JButton displayButton = new JButton ("Display");
        JButton updateButton = new JButton ("Update");
        JPanel panel = new JPanel();
        JFrame frame = new JFrame("Text File GUI");
        public TextFileGUI()
            panel.add(new JLabel("Filename"));
            panel.add(filenameField);
            panel.add(fileTextArea);
            fileTextArea.setLineWrap(true);
            panel.add(displayButton);
            displayButton.addActionListener(this);
            panel.add(updateButton);
            updateButton.addActionListener(this);
            frame.setContentPane(panel);
            frame.setSize(400,400);
            frame.setVisible(true);
        } //end TextFileGUI()
        public void actionPerformed(ActionEvent e)
            if(e.getSource() == displayButton)
                String t;
                try
                    t = tf.read(filenameField.getText());
                    fileTextArea.setText(t);
                catch(Exception ex)
                    fileTextArea.setText("Exception: "+ex);
                } //end try-catch
            } //end if
            else if(e.getSource() == updateButton)
                try
                  tf.write(filenameField.getText());
                catch(IOException ex)
                    fileTextArea.setText("Exception: "+ex);
                } //end try-catch
            } //end else if
         } //end actionPerformed()
    } //end TextFileGUI

    Here's your working example.
    In my opinion u do not have to append \n when u reading the file
    Look the source, if u have some problem, please, ask me.
    Regards
    public class TextFileGUI implements ActionListener
    TextFile tf = new TextFile();
    JTextField filenameField = new JTextField(30);
    JScrollPane scrollPane = new JScrollPane();
    JTextArea fileTextArea = new JTextArea();
    JButton displayButton = new JButton("Display");
    JButton updateButton = new JButton("Update");
    JPanel panel = new JPanel();
    JFrame frame = new JFrame("Text File GUI");
    public static void main(String args[])
    new TextFileGUI();
    public TextFileGUI()
    panel.setLayout(new BorderLayout());
    JPanel vName = new JPanel();
    vName.setLayout(new BorderLayout());
    vName.add(new JLabel("Filename"), BorderLayout.WEST);
    vName.add(filenameField, BorderLayout.CENTER);
    panel.add(vName, BorderLayout.NORTH);
    scrollPane.setViewportView(fileTextArea);
    panel.add(scrollPane, BorderLayout.CENTER);
    fileTextArea.setLineWrap(true);
    JPanel vBtn = new JPanel();
    vBtn.setLayout(new FlowLayout());
    vBtn.add(displayButton);
    displayButton.addActionListener(this);
    vBtn.add(updateButton);
    updateButton.addActionListener(this);
    panel.add(vBtn, BorderLayout.SOUTH);
    frame.setContentPane(panel);
    frame.setSize(400, 400);
    frame.setVisible(true);
    } // end TextFileGUI()
    public void actionPerformed(ActionEvent e)
    if (e.getSource() == displayButton)
    String t;
    try
    t = tf.read(filenameField.getText());
    fileTextArea.setText(t);
    catch (Exception ex)
    ex.printStackTrace();
    else if (e.getSource() == updateButton)
    try
    tf.write(filenameField.getText(), fileTextArea.getText(), false);
    catch (IOException ex)
    ex.printStackTrace();
    } // end try-catch
    } // end else if
    } // end actionPerformed()
    } // end TextFileGUI
    class TextFile
    public String read(String fileIn) throws IOException
    String line;
    StringBuffer text = new StringBuffer();
    FileInputStream vFis = new FileInputStream(fileIn);
    byte[] vByte = new byte[1024];
    int vPos = -1;
    while ((vPos = vFis.read(vByte)) > 0)
    text.append(new String(vByte, 0, vPos));
    vFis.close();
    return text.toString();
    } // end read()
    public void write(String fileOut, String text, boolean append) throws IOException
    File file = new File(fileOut);
    FileWriter fw = new FileWriter(file, append);
    PrintWriter pw = new PrintWriter(fw);
    pw.println(text);
    fw.close();
    } // end write()
    } // end class TextFile

  • Getting line count of wrapped text in JTextArea

    I'm trying to get the line count of wrapped text in a JTextArea, but I see no way to do it other than to write a function for manually determining the line count, which I'm struggling with. I'm trying to get the following code to print out "4 4" on both lines, but it's printing out "1 1" instead. Is there a built-in way to get the actual line count? I'm guessing the JTextArea.getLineCount() function is supposed to count line breaks, which I don't have.
    public class SSCCE
         public static void main(String args[])
              String s = "abc def ghi jkl mno pqr stu vwx yz1 234 567 890";
              JFrame f = new JFrame("test");
              JPanel p = new JPanel();
              JTextArea t[] = {cta(s,1,3),cta(s,1,4)};
              p.add(t[0]);
              p.add(t[1]);
              f.setSize(500,500);
              f.add(p);
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.setVisible(true);
              try
                   Thread.sleep(200);
              catch (InterruptedException e)
                   e.printStackTrace();
              System.out.println(t[0].getRows()+" "+t[1].getRows());
              System.out.println(t[0].getLineCount()+" "+t[1].getLineCount());
    }

    Oh wait, I see. Never mind. I went back there and saw that there were indeed two (last time I checked, I looked for the first one I saw since you didn't give me the full signature), and I got the one for the JTextArea, but I still need Thread.sleep to get the accurate line count.
    import java.awt.Font;
    import java.awt.KeyboardFocusManager;
    import java.lang.reflect.InvocationTargetException;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import javax.swing.SwingUtilities;
    import javax.swing.text.View;
    public class SSCCE implements Runnable
         private static JTextArea t = cta("abc def ghi jkl mno pqr stu vwx yz1 234 567 890");
         public SSCCE()
              SwingUtilities.invokeLater(this);
              try
                   SwingUtilities.invokeAndWait(this);
              catch (InterruptedException e){
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              catch (InvocationTargetException e){
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         @Override
         public void run()
              System.out.println(t.getLineCount());
         public static JTextArea cta(String text)
              JTextArea ta = new JTextArea(text,4,12);
              ta.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
              ta.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
              ta.setFont(new Font("Courier New",Font.PLAIN,12));
              ta.setLineWrap(true);
              ta.setWrapStyleWord(true);
              return ta;
         public static int getWrappedLines(JTextArea component)
              return (int)component.getUI().getRootView(component).getView(0).getPreferredSpan(View.Y_AXIS)/component.getFontMetrics(component.getFont()).getHeight();
         public static void main(String args[])
              JFrame f = new JFrame("Text Area Lines");
              JPanel p = new JPanel();
              p.add(t);
              f.add(p);
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.setSize(200,200);
              f.setLocationRelativeTo(null);
              f.setVisible(true);
              System.out.println(getWrappedLines(t));
              try
                   Thread.sleep(50);
              catch(Exception e)
              System.out.println(getWrappedLines(t));
    }Although, it's not working exactly the way I want it to. Is there a way to get this to work before I paint? It works fine after I paint, but I was just wondering.

  • Java2D text rendering quality

    Dear all,
    I am currently trying to get high quality rendering for monochrome text, targeting epaper viewers. I draw strings into a BufferedImage, and display it on my LCD monitor in order to quickly check the rendering quality, before transferring it to epaper. I am encountering some disappointing surprises using Java2D, and cannot get a good output quality:
    - TextAttribute.WEIGHT produces only 2 different renderings, regular or bold.
    - Fonts appear very very light for sizes up to 17pt, and suddenly appear bold at 18pt+ sizes
    I am working under Windows XP SP 2, with JDK 1.6.0. Here follows a small piece of code illustrating the second problem. When comparing output with Photoshop or Fireworks outputs, the results are really disapointing, and I am sure that I am missing something...
    Thanks in advance for any help/tip.
    Sincerely,
    Jean-Marie
    import javax.swing.*;
    import java.awt.*;
    import java.awt.font.FontRenderContext;
    import java.awt.font.TextLayout;
    import java.awt.font.TextAttribute;
    import java.awt.image.BufferedImage;
    import java.text.AttributedString;
    public class TextRendering extends JPanel {
        private static final int WIDTH = 2000;
        private static final int HEIGHT = 8000;
        private static final int MIN_SIZE = 13;
        private static final int MAX_SIZE = 72;
        private static final int STEP = 1;
        private BufferedImage buf;
        public TextRendering() {
            setMinimumSize(new Dimension(WIDTH, HEIGHT));
            setPreferredSize(new Dimension(WIDTH, HEIGHT));
            buf = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_BYTE_GRAY);
            Graphics2D g2d = (Graphics2D) buf.getGraphics();
            g2d.setColor(Color.WHITE);
            g2d.fillRect(0, 0, WIDTH, HEIGHT);
            g2d.setColor(Color.BLACK);
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
            g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
            g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
            // g2d.setRenderingHint(RenderingHints.KEY_TEXT_LCD_CONTRAST, 250);
            FontRenderContext frc = g2d.getFontRenderContext();
            Font f = new Font("Arial", Font.PLAIN, 24);
            int y = 20;
            for (int i = MIN_SIZE; i <= MAX_SIZE; i += STEP) {
                String s = new String(i + "pt- I would like to get a better rendering ! ");
                AttributedString attText = new AttributedString(s);
                attText.addAttribute(TextAttribute.FOREGROUND, Color.black);
                attText.addAttribute(TextAttribute.FONT, f.deriveFont((float)i));
                TextLayout textlayout = new TextLayout(attText.getIterator(), frc);
                textlayout.draw(g2d, 10, y);
                y += i + 10;
        public void paint(Graphics g) {
            Graphics2D g2d = (Graphics2D) g;
            g2d.drawImage(buf, 0, 0, null);
        public static void main(String[] args) {
            JFrame f = new JFrame("Text rendering demo");
            f.getContentPane().add(new JScrollPane(new TextRendering()), BorderLayout.CENTER);
            f.setSize (600, 800);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setVisible(true);
    }

    Of course, the same rendering problem can be observed with the more sophisticated "Font2DTest" example which can be found in the JDK samples: with the Arial font, the text becomes "semi-bold" starting from 18pt size, whereas it is very light for sizes up to 17pt.
    Thanks again for any help.
    Jean-Marie

  • Text reragging

    Hi, I made a site, which can be found here: http://www.glueadvertising.com
    The menu is comprised of text buttons that use pinning and anchor points. When I view it in Muse and Preview it, it looks fine. I export to HTML, and upload it, it looks fine on my computer, using all browsers. When my client views it, it only looks right some of the time. The other time all of the copy on all of the pages rerags and makes for very odd breaks. It mostly happens in Chrome and Safari, on both Macs and PCs. Why is this happening? It seems so random. Can I set something in Muse so this does not happen anymore? My client is very unhappy.
    I have attached screens hots of the messy site.

    Sorry, should have taken a closer look at your site and the screenshots before my initial reply.
    Your client is using a browser that supports Text-only Zooming and has the text scaled to be a larger point size than your original design. That combined with your use of hard returns on every line make for the re-rag you're seeing.
    If the client does Command/Control+0 in their browser it will reset the text to normal 100% scale. That said, if they have the text scaled they may have poor eye sight and thus want/need the text to always be larger than what you designed. If that's the case, you're going to need to significantly revise your design to be able to accommodate large fluctuations in the point size of the text.
    Specifically, you need to let Muse (and thus the browser) wrap the text rather than using hard returns at the end of every line and you'll need to make text frames significantly taller than the amount of text they normally contain, so the text frame don't need to resize in height when the font size grows.

  • Adobe Muse - Text resizer

    Does anyone know how to add a Text Resizer on a Muse project?

    Hello,
    You can try the widget in the link below to achieve the same.
    Text Scaling Muse widget – Adobe Muse Widget Directory
    Regards
    Vivek

  • Server code text sending

    Hello, I've got this server code below. When a Client program has connected, it sends its text messages to this server and it prints them out. What I need it to do is determine who is to receive the message and send it to only those client programs. I need Help figuring out how to do this.
    // MultiThreadServer.java
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MultiThreadServer extends JFrame {
         // Text area for displaying contents
         //private JTextArea jta = new JTextArea();
         public static void main(String[] args) {
              new MultiThreadServer();
         public int cn = 0;
         public Socket connectToDaemon;
         // IO streams
         DataOutputStream osToDaemon;
         DataInputStream isFromDaemon;
         public String un;
         public BufferedReader fin;
         public MultiThreadServer() {
              // Place text area on the frame
    /**          getContentPane().setLayout(new BorderLayout());
              getContentPane().add(new JScrollPane(jta), BorderLayout.CENTER);
              jta.setLineWrap(true);
              jta.setWrapStyleWord(true);
              jta.setEditable(false);
              setTitle("MultiThreadServer");
              setSize(500, 300);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true); // It is necessary to show the frame here!
              String user = "";
              boolean decision = true;
              try {
                   // Create a server socket
                   ServerSocket serverSocket = new ServerSocket(8000);
                   System.out.println("MultiThreadServer started at " + new Date() + '\n');
                   // Number a client
                   int clientNo = 1;
                   int adminNo = 1;
                   while (true) {
                        // Listen for a new connection request
                        Socket connectToClient = serverSocket.accept();
                        /**  Get Username
                        fin = new BufferedReader(new InputStreamReader(connectToClient.getInputStream()));
                        StringBuffer readfinBuffer = new StringBuffer();
                        String s = fin.readLine();
                        String s = "NewUser";
    //--------------CHECK USERNAME TO SEE IF IT'S A USER OR AN ADMIN------------------------------------
                        String beginning = "";
                        String name = "";
    //--------------FIND ADMIN, CONNECT TO HIS DAEMON AND ASK IF HE WANTS TO TALK-----------------------
                        if (beginning.equals("Admin"))
                             user = "Admin";
                        } else {
                             user = "Client";
                             adminNo = clientNo;
              //GET ADMINS LOCATION  -- to be developed later
                             //connect to MessageDaemon
                             connectToDaemon = new Socket("10.0.5.39", 8001);
                             isFromDaemon = new DataInputStream(connectToDaemon.getInputStream());
                             osToDaemon = new DataOutputStream(connectToDaemon.getOutputStream());
                             // Send QueryString to Daemon
                             PrintWriter socketfinOut =
                                  new PrintWriter(new BufferedWriter(new OutputStreamWriter(connectToDaemon.getOutputStream())));
                             socketfinOut.println("Ask");
                             socketfinOut.flush();
                             //Return decision value,
                             int des = isFromDaemon.readInt();
                             //get yes/no decision from MessageDaemon
                             decision = des == 0;
                        if (decision) {
                             if (beginning.equals("Admin"))
                                  // Display the client number
                                  System.out.println("Starting thread for " + user + ":" + name + " Num" + adminNo +
                                       " at " + new Date() + '\n');
                             } else {
                                  // Display the client number
                                  System.out.println("Starting thread for " + user + ":" + name + " Num" + clientNo +
                                       " at " + new Date() + '\n');
                                  // Find the client's host name, and IP address
                                  InetAddress clientInetAddress =
                                       connectToClient.getInetAddress();
                                  System.out.println("Client " + clientNo + " " + s + "'s host name is "
                                       + clientInetAddress.getHostName() + "\n");
                                  System.out.println("Client " + clientNo + " " + s + "'s IP Address is "
                                       + clientInetAddress.getHostAddress() + "\n");
                             // Create a new thread for the connection     SEND CLIENT# AND IP ADDRESS
                             HandleAClient thread = new HandleAClient(connectToClient);
                             un = s;
                             cn = clientNo;
                             // Start the new thread
                             thread.start();
                        } else {
                             //Send unable to connect signel
                        // Increment clientNo
                        clientNo++;
              catch(IOException ex) {
                   System.err.println(ex);
         // Inner class
         // Define the thread class for handling new connection
         class HandleAClient extends Thread {
              private Socket connectToClient; // A connected socket
              // Construct a thread
              public HandleAClient(Socket socket) {
                   connectToClient = socket;
              public BufferedReader in;
              // Run a thread
              public void run() {
                   try {
                        // Create data input and output streams
                        DataInputStream isFromClient = new DataInputStream(
                             connectToClient.getInputStream());
                        DataOutputStream osToClient = new DataOutputStream(
                             connectToClient.getOutputStream());
                        //Send Thread number back to client
                        osToClient.writeDouble(cn);
                        // Continuously serve the client
                        while (true) {
                             int newNum = 0;
                             String n = "";
                   //GET TEXT FROM CLIENT
                        //  Create your BufferedReader
                             in = new BufferedReader(new InputStreamReader(connectToClient.getInputStream()));
                        //  Create an empty StringBuffer to hold the data that you read...
                             StringBuffer readBuffer = new StringBuffer();
                        //  ... and read each character.
                             String readString = in.readLine();
                   //PARSE STRING FOR RELEVANT INFO
                   //SEND THE TEXT TO CLIENT
                        //SET IP VS CLIENT NUM ARRAY DATA
                        //WHILE NOT END OF ARRAY
                             //IF CLIENT NUM = CLIENT NUM OF SENDER, SEND MESSAGE
                        //  a conduit for writing (printing) over that socket:
                             PrintWriter socketOut =
                                       new PrintWriter(new BufferedWriter(new OutputStreamWriter(connectToClient.getOutputStream())));
                        //  Here's where we write out the string
                             socketOut.println(readString);
                        //  ... and here's where we make sure it's on its way!
                             socketOut.flush();
                        //  Now you can do what you want with the String:
                             System.out.println(readString + "\n");
                   catch(IOException e) {
                        System.err.println(e);
    }

    Hello....HEllo.....HELlo.....HELLo......HELLO......
    testing.......testing.......is this thing on?

Maybe you are looking for