Java JFrame setInfo(String info, JFrame root)

Here you can find the source of setInfo(String info, JFrame root)

Description

set Info

License

Apache License

Declaration

public static void setInfo(String info, JFrame root) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.awt.Component;

import javax.swing.JFrame;

import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class Main {
    private static int sumError = 0;
    private static int sumExistError = 0;
    private static int sumNotFoundError = 0;
    private static int sumSuccess = 0;
    private static int sumNum = 1;

    public static void setInfo(String info, JFrame root) {
        sumError += 1;/*w ww .j  a  va 2  s  .co m*/
        info.equals("");

        Component[] components = root.getRootPane().getContentPane().getComponents();
        for (int i = 0; i < components.length; i++) {
            if (components[i].getClass().toString().equals("class javax.swing.JScrollPane")) {
                JTextArea textarea = (JTextArea) ((JScrollPane) components[i]).getViewport().getView();
                if (info.equals("")) {
                    sumError = 0;
                    sumExistError = 0;
                    sumNotFoundError = 0;
                    sumSuccess = 0;
                    sumNum = 1;
                    textarea.setText("");
                } else if ((textarea.getText().equals("")) || (textarea.getText() == null)) {
                    textarea.setText(sumNum + ". " + info);
                } else {
                    textarea.setText(textarea.getText() + "\n" + sumNum + ". " + info);
                }
            }
        }
    }
}

Related

  1. setESCCloseable(final JFrame aFrame)
  2. setFrameBottomRight(final JFrame frame)
  3. setFramePositon(JFrame inTargetFrame)
  4. setFrameTitle(JFrame frame, File file)
  5. setGeneralParameters(final JFrame window)
  6. setJFrameAlwaysOnTop(JFrame frame, boolean newValue)
  7. setMainWindowLocation(JFrame jfrm, String strPropertiesFilePath, String strPropertiesFileName)
  8. setPanel(JPanel parent, JPanel child, JFrame f)
  9. setPersistentExtendedStateMask(JFrame frame, int persistentExtendedStateMask)