Getting pixels from jtextarea

Hi, I have a jtextarea which I want to analyze by extracting from it all of the pixels (pixel by pixel in row order). I want to have arrays of pixels representing the black pixels in the jtextarea (each array represents a row).
I'll be happy to recieve any counsel.
Thanks

this should help
http://java.sun.com/j2se/1.3/docs/guide/2d/spec/j2d-image.fm3.html

Similar Messages

  • Need help!-----How to get pixel from pixel location??

    Hi, I have the location of a pixel (x, y), how to get the pixel value which will be used in DirectColorModel cm.getRGB(int pixel)?
    thanks a lot!!!

    Hi, my image is created by Toolkit.createImage(byte[]). I think I should use PixelGrabber to grab all pixels value to int[], use location(x,y) to get pixel index(y*width+x), then use ColorModel.getRGB(int pixelIndex) to get the rgb value at that location, right? is there any other way to do it?
    thank you.

  • High CPU Usage while getting input from JTextArea

    I have a core class (emulator) that can receive and handle command strings of varying sorts. I have an Interface that, when implemented, can be used to work with this emulator.
    I have code that works, but the CPU is pegged. The emulator has its own thread, and my GUI, which implements the aforementioned Interface and extends JFrame, clearly has its own as well.
    So, the emulator calls the gatherResponse(prompt) method of the interface driving it, in order to find out the next command :
    Here is the code for this method (note that the console member variable is referring to the JTextArea that is within the JFrame) :
         public String gatherResponse(String prompt) {
              printPrompt(prompt);          
              lastPrompt = prompt;
              class ResponseListener extends Thread implements KeyListener {
                   public volatile String response = null;
                   public ResponseListener() {
                        super();
                   public void run() {
                        while (getResponse() == null) {
                             try {
                                       Thread.sleep((int)Math.random() * 100);
                             catch (InterruptedException ie) {
                                  System.out.println("ResponseListener.run==>"+ie.toString());
                   public String getResponse() {
                        return response;
                   public void keyPressed(KeyEvent e) {
                        System.out.println("ResponseListener.keyPressed==>"+e.getKeyCode());
                        if (e.getKeyCode() == 10) {
                             try {
                                  response = getLastConsoleLine();
                                  System.out.println("response found:"+response);
                             catch (Exception exc) {}
                   } //end public void keyPressed(KeyEvent e)
                   public void keyTyped(KeyEvent e) {}
                   public void keyReleased(KeyEvent e) {}
              } //end class ResponseListener implements KeyListener
              ResponseListener rl = new ResponseListener();
              console.addKeyListener(rl);
              System.out.println("Starting ResponseListener");
              rl.start();
              String response = null;
              while ((response = rl.getResponse()) == null) {
                   try {
                        Thread.sleep((int)Math.random() * 1000);
                   catch (InterruptedException ie) {
                        System.out.println(ie.toString());
              } //end while((response = rl.getResponse())==null)
              console.removeKeyListener(rl);
              System.out.println("returning "+response);
              return response;
         } //end public void gatherResponse(String prompt)     Like I said, this works just fine, but I don't want to go with it when it pegs the CPU. I've never really done any work w/ Threads, so I could be making a real newbie mistake here...

    Code adapted from The Producer/Consumer Example
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    public class Listening
        Scheduler scheduler;
        JTextField north, south;
        public Listening(Scheduler s)
            scheduler = s;
            north = new JTextField();
            south = new JTextField();
            north.setName("north");
            south.setName("south");
            scheduler.register(north);
            scheduler.register(south);
        private JTextField getNorth() { return north; }
        private JTextField getSouth() { return south; };
        public static void main(String[] args)
            Scheduler scheduler = new Scheduler();
            Listening test = new Listening(scheduler);
            Monitor monitor = new Monitor(scheduler);
            JFrame f = new JFrame("Listening");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(test.getNorth(), "North");
            f.getContentPane().add(test.getSouth(), "South");
            f.setSize(240,125);
            f.setLocation(200,200);
            f.setVisible(true);
            monitor.start();
    class Scheduler
        private String contents;
        private boolean available = false;
        public synchronized String get(String caller)
            while(!available)
                try
                    wait();
                catch (InterruptedException ie)
                    System.err.println("Scheduler.get interrupted: " + ie.getMessage());
            available = false;
            System.out.println(caller + " get: " + contents);
            notifyAll();
            return contents;
        public synchronized void put(String sender, String input)
            while(available)
                try
                    wait();
                catch (InterruptedException ie)
                    System.err.println("Scheduler.put interrupted: " + ie.getMessage());
            contents = input;
            available = true;
            System.out.println(sender + " put: " + contents);
            notifyAll();
        protected void register(final JTextComponent tc)
            Document doc = tc.getDocument();
            doc.addDocumentListener(new DocumentListener()
                public void changedUpdate(DocumentEvent e) { /*styles*/ }
                public void insertUpdate(DocumentEvent e)  { report(); }
                public void removeUpdate(DocumentEvent  e) { report(); }
                private void report()
                    put(tc.getName(), tc.getText());
    class Monitor extends Thread
        Scheduler scheduler;
        JTextField  listenerField;
        public Monitor(Scheduler s)
            scheduler = s;
            launchDialog();
        public void run()
            boolean continueToMonitor = true;
            while(continueToMonitor)
                try
                    Thread.sleep(10);
                catch(InterruptedException ie)
                    System.err.println("Monitor.run interrupted: " + ie.getMessage());
                    continueToMonitor = false;
                String text = scheduler.get(this.getClass().getName());
                listenerField.setText(text);
        private void launchDialog()
            listenerField = new JTextField();
            JDialog d = new JDialog(new Frame(), getClass().getName(), false);
            d.getContentPane().add(listenerField, "North");
            d.setSize(300,100);
            d.setLocation(585,200);
            d.setVisible(true);
    }

  • Getting pixels from an image

    I'm currently writing a Java3D-based renderer for terrain data. The rendering engine works great, and I've tested it with OS DEM files.
    I thought it would be neat to code a class similar to the one I use to parse DEM files, but that takes Jpeg images and specifies altitude from the brightness component of the HSB of each pixel. This is where the problem begins.
    I (naively) thought it would be a simple case of getting the image with something like
    Image image = Toolkit.getDefaultToolkit().getImage(fname);
    Then using a getColor(x,y) or similar method to get the data out of the image. Only it doesn't seem to be so simple. It looks like I need to use a BufferedImage, which in turn wants a Raster, which wants two other classes.... and the whole thing gets complicated.
    If anyone knows a quick (hoping it's a 3 or 4 line thing) way to set up an object that can be readily accessed to read the HSB value of each pixel (ideally by returning it as an awt.Color class), I'd really appreciate it. Or a link to a good tutorial on the subject.
    Thanks.

    Thanks :) Knew it should be simpler than it looked :)

  • How to get InputStream from JTextArea.getText() string?

    hello,
    well the postname pretty much says it, i need to get an InputStream for the String of a JTextArea.
    thing is, i want to save the string in a textfile, but the new line isnt recognized when i write it to the file.
    FileWriter fw = new FileWriter ("text.txt");
    fw.write(editField.getText());  // editField is my JTextArea instanceso i thought of doing smth like this
    String lineSeparator = System.getProperty("line.separator");
    // somehow getting the InputStream for my editField and save it in "is"
    BufferedReader br = new BufferedReader(new InputStreamReader (is));
    String line;
    while ((line = br.readLine()) != null) {
    fw.write(line);
    fw.write(lineSeparator);
    }

    pSaiko wrote:
    hello,
    well the postname pretty much says it, i need to get an InputStream for the String of a JTextArea.
    thing is, i want to save the string in a textfile, but the new line isnt recognized when i write it to the file.
    FileWriter fw = new FileWriter ("text.txt");
    fw.write(editField.getText());  // editField is my JTextArea instanceso i thought of doing smth like this
    String lineSeparator = System.getProperty("line.separator");
    // somehow getting the InputStream for my editField and save it in "is"
    BufferedReader br = new BufferedReader(new InputStreamReader (is));
    String line;
    while ((line = br.readLine()) != null) {
    fw.write(line);
    fw.write(lineSeparator);
    This is very simple, it isn't buffered, but it should work for you.
    Sting s = editfield.getText();
    for(int i=0; i<s.length();i++) fw.write((int)s.charAt(i));
    fw.flush();
    fw.close();

  • Exporting from Media Encoder using Vimeo Preset and getting pixelated footage in a specific location

    I am exporting a video using Vimeo preset 1080p 23.976 H.264.  Everytime I export the entire video approx 5 minutes long I get pixelated footage at a very specific point every time.  I've tried multiple workarounds, relinking the media, exporting to different location (willing to try anything at this point).
    When I just export the specific problem area the problem is non existent. 
    Any advice/help is greatly appreciated.

    I am using the CC version, so I should be up to date from my understanding.
    Magically, that worked!  I'm just curious why I had that problem in the first place?  Any insight?
    Thanks again! You're quick response is much appreciated!

  • How to get Text from (.txt) file to display in the JTextArea ?

    How to get Text from (.txt) file to display in the JTextArea ?
    is there any code please tell me i am begginer and trying to get data from a text file to display in the JTextArea /... please help...

    public static void readText() {
      try {
        File testFile = new File(WorkingDirectory + "ctrlFile.txt");
        if (testFile.exists()){
          BufferedReader br = new BufferedReader(new FileReader("ctrlFile.txt"));
          String s = br.readLine();
          while (s != null)  {
            System.out.println(s);
            s = br.readLine();
          br.close();
      catch (IOException ex){ex.printStackTrace();}
    }rykk

  • How can we get the selected line number from JTextArea ?

    how can we get the selected line number from JTextArea ? and want to insert line/string given line number into JTextArea??? is it possible ?

    Praitheesh wrote:
    how can we get the selected line number from JTextArea ?
    textArea.getLineOfOffset(textArea.getCaretPosition());
    and want to insert line/string given line number into JTextArea??? is it possible ?
    int lineToInsertAt = 5; // Whatever you want.
    int offs = textArea.getLineStartOffset(lineToInsertAt);
    textArea.insert("Text to insert", offs);

  • Can not get data from mySql

    I prepared a GUI user connection application in NebBeans 5.5 accessing mySql database in the company server. The application run very well in desktop.
    However, when I post it to the company server web, it gets nothing from the database.
    Can any one give advice???
    Thank you in advance.
    The following is my application
    import java.util.Vector;
    import java.awt.event.*;
    import java.awt.*;
    import java.awt.event.*;
    public class UserConnection extends javax.swing.JFrame {
    //constants for database
    private final String userName = "labmanage";
    private final String password = "labmanage";
    private final String server = "jdbc:mysql://svr.corp.com/labmanage";
    private final String driver = "com.mysql.jdbc.Driver";
    private JDBCAdapter data = new JDBCAdapter(server, driver, userName, password);
    //variables
    private String user, pwd;
    private Vector<Vector<String>> userTable = new Vector<Vector<String>>();
    private Vector<String>colUserNames = new Vector<String>();
    * Creates new form UserConnection
    public UserConnection() {
    initComponents();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
    userLabel = new javax.swing.JLabel();
    pwdLabel = new javax.swing.JLabel();
    userTextField = new javax.swing.JTextField();
    passwordField = new javax.swing.JPasswordField();
    submitButton = new javax.swing.JButton();
    statusLabel = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    statusTextArea = new javax.swing.JTextArea();
    changePwdButton = new javax.swing.JButton();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("User's Connection");
    setBackground(new java.awt.Color(153, 204, 255));
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    setFont(new java.awt.Font("aakar", 1, 12));
    userLabel.setText("User Name:");
    pwdLabel.setText("Password:");
    submitButton.setText("Submit");
    submitButton.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    submitButtonMouseClicked(evt);
    submitButton.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    submitButtonActionPerformed(evt);
    submitButton.addKeyListener(new java.awt.event.KeyAdapter() {
    public void keyTyped(java.awt.event.KeyEvent evt) {
    submitButtonKeyTyped(evt);
    statusLabel.setText("Status:");
    statusTextArea.setColumns(20);
    statusTextArea.setEditable(false);
    statusTextArea.setLineWrap(true);
    statusTextArea.setRows(3);
    statusTextArea.setText("Initial assigned password is \"dime\".");
    statusTextArea.setWrapStyleWord(true);
    jScrollPane1.setViewportView(statusTextArea);
    changePwdButton.setText("Change password");
    changePwdButton.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    changePwdButtonActionPerformed(evt);
    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(layout.createSequentialGroup()
    .addContainerGap()
    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(userLabel)
    .add(pwdLabel)
    .add(statusLabel))
    .add(35, 35, 35)
    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(layout.createSequentialGroup()
    .add(submitButton)
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
    .add(changePwdButton))
    .add(passwordField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
    .add(userTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
    .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE))
    .addContainerGap())
    layout.setVerticalGroup(
    layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(layout.createSequentialGroup()
    .addContainerGap()
    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    .add(userLabel)
    .add(userTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    .add(pwdLabel)
    .add(passwordField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    .add(statusLabel)
    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
    .add(15, 15, 15)
    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    .add(submitButton)
    .add(changePwdButton))
    .addContainerGap(27, Short.MAX_VALUE))
    pack();
    }// </editor-fold>
    private void submitButtonKeyTyped(java.awt.event.KeyEvent evt) {                                     
    if(evt.getKeyCode() == KeyEvent.VK_ENTER) {
    submitButton.doClick();
    submitButton.requestFocus();
    changePwdButton.requestFocus();
    private void changePwdButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               
    String command = evt.getActionCommand();
    if(command.equals("Change password")) {
    passwordField.setText("");
    //Get connection to the changing password panel
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new ChangePassword().setVisible(true);
    private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
    // TODO add your handling code here:
    String command = evt.getActionCommand();
    if(command.equals("Submit")) {
    user = getUser();
    pwd = getPwd();
    data = new JDBCAdapter(server, driver, userName, password);
    data.executeQuery("SELECT * FROM USERTABLE");
    colUserNames = data.getColumnNames();
    userTable = data.getDataTable();
    if(colUserNames.elementAt(0).equals("")) {
    statusTextArea.setText("Can not connect to database");
    boolean checkUser = false;
    int i = 0;
    while(!checkUser && i<userTable.size()) {
    if(user.equalsIgnoreCase((String) userTable.elementAt(i).elementAt(0))) {
    //Find the user in database
    checkUser = true;
    //Check user's password
    if(pwd.equals((String)userTable.elementAt(i).elementAt(1))) {
    //Check for initial default password. The user is requested
    //to change his password
    if(pwd.equals((String) "dime")) {
    statusTextArea.setText("You are requested to change your " +
    "initial assigned password. Click 'Change password' please.");
    else {
    //Set UserConnection Panel to invisible
    setVisible(false);
    dispose();
    //Get connection to the table
    if(userTable.elementAt(i).elementAt(2).equals("0")) {
    //Get connection to non-editable table
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    PVRackReportNonEdit rackReport = new PVRackReportNonEdit();
    rackReport.createAndShowDialog();
    else {
    if(userTable.elementAt(i).elementAt(2).equals("1")) {
    //Get connection to editable table
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    PVRackReport rackReport = new PVRackReport(user);
    rackReport.createAndShowDialog();
    //PVRackReport rackReport = new PVRackReport();
    else statusTextArea.setText("You do not get approval for viewing data. " +
    "Please contact the administrator for details.");
    else {
    passwordField.setText("");
    statusTextArea.setText("Please enter corrected password or" +
    "the administrator for details.");
    i++;
    if(!checkUser) {
    passwordField.setText("");
    statusTextArea.setText("Not find such user's name." +
    "contact the admistrator for details.");
    private void submitButtonMouseClicked(java.awt.event.MouseEvent evt) {                                         
    // TODO add your handling code here:
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new UserConnection().setVisible(true);
    public String getUser() {
    return userTextField.getText();
    public String getPwd() {
    return passwordField.getText();
    // Variables declaration - do not modify
    private javax.swing.JButton changePwdButton;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPasswordField passwordField;
    private javax.swing.JLabel pwdLabel;
    private javax.swing.JLabel statusLabel;
    private javax.swing.JTextArea statusTextArea;
    private javax.swing.JButton submitButton;
    private javax.swing.JLabel userLabel;
    private javax.swing.JTextField userTextField;
    // End of variables declaration
    Here is my JDBCAdapter
    package rackdemo2;
    * This is an adaptor which transforms the JDBC interface
    * to the PVRackTableDialogue
    import java.util.Vector;
    import java.sql.*;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.event.TableModelEvent;
    public class JDBCAdapter {
    Connection connection;
    Statement statement;
    ResultSet resultSet;
    Vector<String> columnNames = new Vector<String>();
    Vector<Vector<String>> rows = new Vector<Vector<String>>();
    ResultSetMetaData metaData;
    public JDBCAdapter(String url, String driverName,
    String user, String passwd) {
    try {
    Class.forName(driverName);
    connection = DriverManager.getConnection(url, user, passwd);
    statement = connection.createStatement();
    catch (ClassNotFoundException ex) {
    System.err.println("Cannot find the database driver classes.");
    System.err.println(ex);
    catch (SQLException ex) {
    System.err.println("Cannot connect to this database.");
    System.err.println(ex);
    public void executeQuery(String query) {
    if (connection == null || statement == null) {
    System.err.println("There is no database to execute the query.");
    return;
    try {
    resultSet = statement.executeQuery(query);
    metaData = resultSet.getMetaData();
    int numberOfColumns = metaData.getColumnCount();
    // Get the column names and cache them.
    // Then we can close the connection.
    for(int column = 0; column < numberOfColumns; column++) {
    columnNames.addElement(metaData.getColumnLabel(column+1));
    // Get all rows.
    while (resultSet.next()) {
    Vector<String> newRow = new Vector<String>();
    for (int i = 1; i <= columnNames.size(); i++) {
    String tempString = resultSet.getString(i);
    if(!tempString.equals("null")) {
    newRow.addElement(tempString);
    else {
    newRow.addElement("");
    rows.addElement(newRow);
    //Modify dataTable to add empty row to separate chassis
    if(numberOfColumns>1) {
    int nRow = rows.size();
    Vector<String> row = new Vector<String>();
    for(int i=0; i<numberOfColumns; i++){
    row.add("");
    if(nRow>0 || numberOfColumns>0) {
    //Adding blank row to separate chassis
    int i = 0;
    while(i<nRow) {
    if(!rows.elementAt(i).elementAt(0).equals("")) {
    if(i>0) {
    rows.add(i, row);
    i++;
    nRow = rows.size();
    i++;
    close();
    catch (SQLException ex) {
    System.err.println(ex);
    public void close() throws SQLException {
    resultSet.close();
    statement.close();
    connection.close();
    // MetaData
    public Vector<String> getColumnNames() {
    return columnNames;
    public Vector<Vector<String>> getDataTable() {
    return rows;
    public int getColumnCount() {
    return columnNames.size();
    // Data methods
    public int getRowCount() {
    return rows.size();
    }

    Thank you for your answer.
    I'm very new to mySql as server. When I was assigned
    to write the application, the administrator has set
    up mySql database in the company web server for my
    application. My program runs very when using my
    workplace desktop with java web start or with java
    web start in netbeans (all paths should be link to my
    desktop hard disk, i.e. users/application/). I can
    not run the application at home because I can not
    access to the company intranet server (for security
    purpose). The problem happens when I post the
    application in the company web page (I have to modify
    all paths in jnlp file to the company web address).
    The program then runs without exception except it
    seems that it gets no data from the database (for
    example, when I type my username, it returns that
    "There is no such user name. contact.." as what I
    code in the application for not correcting user name)
    It happens for not only using my company desktop but
    also for others.
    Please help me.
    Thank you in advance.And all this could have been answered yesterday, in your other thread, when I asked you "Is the DB configured to allow that user to connect to the DB from where that user is attempting to connect from?"
    Seeing as how you get that error, the obvious answer was, "No." At which point we could have continued.
    Configure the needed users into the DB, without forgetting to allow them access from the machines from which they are going to access from.
    Although, I agree with Rene, that you should set up a server of some sort, located on the same machine as the DB, for communicating with the DB.

  • Problems getting data from JMenuBar to JInternalFrame

    I have modified an example to show my problem. I am trying to take text input from the menu bar and print it into a JTextArea. I don't know how to reference the data in my ActionListener.
    The ActionListener is incomplete, but this is basically what I am trying to do:
    import javax.swing.JInternalFrame;
    import javax.swing.JDesktopPane;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JMenuBar;
    import javax.swing.JFrame;
    import javax.swing.KeyStroke;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    * InternalFrameDemo.java is a 1.4 application that requires:
    *   MyInternalFrame.java
    public class InternalFrameDemo extends JFrame
                                   implements ActionListener {
        JDesktopPane desktop;
        JTextField memAddrBox;
        JTextArea menuText;
        JTextArea frame;
        String textFieldString = " Input Text: ";
        ActionListener al;
        public InternalFrameDemo() {
            super("InternalFrameDemo");
            //Make the big window be indented 50 pixels from each edge
            //of the screen.
            int inset = 50;
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds(inset, inset,
                      screenSize.width  - inset*2,
                      screenSize.height - inset*2);
            //Set up the GUI.
            desktop = new JDesktopPane(); //a specialized layered pane
            frame = createFrame(); //create first "window"
            setContentPane(desktop);
            setJMenuBar(createMenuBar());
            //Make dragging a little faster but perhaps uglier.
            desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        protected JMenuBar createMenuBar() {
            JMenuBar menuBar = new JMenuBar();
            JLabel memAddrLabel = new JLabel(textFieldString);
            memAddrLabel.setLabelFor(memAddrBox);
            menuBar.add(memAddrLabel);
            JTextField memAddrBox = new JTextField();
            memAddrBox.addActionListener(this);
            memAddrBox.setActionCommand("chMemAddr");
            menuBar.add(memAddrBox);
            return menuBar;
        //React to menu selections.
        public void actionPerformed(ActionEvent e) {
            if ("chMemAddr".equals(e.getActionCommand())) 
                JMenuBar bar = getJMenuBar();
    //            JTextField memAddrBox = bar.getParent();
                String memStartString = memAddrBox.getText();
                update(memStartString);
        public void update(String temp)
            frame.setText(temp);
        //Create a new internal frame.
        protected JTextArea createFrame() {
            JInternalFrame frame = new JInternalFrame("Memory",true,true,true,true);      
            frame.setSize(650, 500);
            frame.setVisible(true);
            frame.setLocation(200, 0);
            desktop.add(frame);  
            JTextArea textArea = new JTextArea();
            frame.getContentPane().add("Center", textArea);
            textArea.setFont(new Font("SansSerif", Font.PLAIN, 12));
            textArea.setVisible(true);
            textArea.setText("Initial Text");
            return textArea;
        //Quit the application.
        protected void quit() {
            System.exit(0);
        public static void main(String[] args) {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            InternalFrameDemo frame = new InternalFrameDemo();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Display the window.
            frame.setVisible(true);
    class MyInternalFrame extends JInternalFrame {
        static int openFrameCount = 0;
        static final int xOffset = 30, yOffset = 30;
        public MyInternalFrame() {
            super("Document #" + (++openFrameCount),
                  true, //resizable
                  true, //closable
                  true, //maximizable
                  true);//iconifiable
            //...Create the GUI and put it in the window...
            //...Then set the window size or call pack...
            setSize(300,300);
            //Set the window's location.
            setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
    }I want to take the input from the "memAddrBox" and put it into the "frame" using the update() method. Probably a simple solution, but I have not found a similar problem in the Forums.

    I knew it had to be something simple, here is the fix I found:
    import javax.swing.JInternalFrame;
    import javax.swing.JDesktopPane;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JMenuBar;
    import javax.swing.JFrame;
    import javax.swing.KeyStroke;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    * InternalFrameDemo.java is a 1.4 application that requires:
    *   MyInternalFrame.java
    public class InternalFrameDemo extends JFrame
                                   implements ActionListener {
        JDesktopPane desktop;
        JTextField memAddrBox;
        JTextArea menuText;
        JTextArea frame;
        String textFieldString = " Input Text: ";
        ActionListener al;
        public InternalFrameDemo() {
            super("InternalFrameDemo");
            //Make the big window be indented 50 pixels from each edge
            //of the screen.
            int inset = 50;
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds(inset, inset,
                      screenSize.width  - inset*2,
                      screenSize.height - inset*2);
            //Set up the GUI.
            desktop = new JDesktopPane(); //a specialized layered pane
            frame = createFrame(); //create first "window"
            setContentPane(desktop);
            setJMenuBar(createMenuBar());
            //Make dragging a little faster but perhaps uglier.
            desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        protected JMenuBar createMenuBar() {
            JMenuBar menuBar = new JMenuBar();
            JLabel memAddrLabel = new JLabel(textFieldString);
            memAddrLabel.setLabelFor(memAddrBox);
            menuBar.add(memAddrLabel);
            JTextField memAddrBox = new JTextField();
            memAddrBox.addActionListener(this);
            memAddrBox.setActionCommand("chMemAddr");
            menuBar.add(memAddrBox);
            return menuBar;
        //React to menu selections.
        public void actionPerformed(ActionEvent e) {
            if ("chMemAddr".equals(e.getActionCommand())) 
               JTextField textField =
                 (JTextField)e.getSource();
                String memStartString = textField.getText();
                update(memStartString);
        public void update(String temp)
            frame.setText(temp);
        //Create a new internal frame.
        protected JTextArea createFrame() {
            JInternalFrame frame = new JInternalFrame("Memory",true,true,true,true);      
            frame.setSize(650, 500);
            frame.setVisible(true);
            frame.setLocation(200, 0);
            desktop.add(frame);  
            JTextArea textArea = new JTextArea();
            frame.getContentPane().add("Center", textArea);
            textArea.setFont(new Font("SansSerif", Font.PLAIN, 12));
            textArea.setVisible(true);
            textArea.setText("Initial Text");
            return textArea;
        //Quit the application.
        protected void quit() {
            System.exit(0);
        public static void main(String[] args) {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            InternalFrameDemo frame = new InternalFrameDemo();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Display the window.
            frame.setVisible(true);
    class MyInternalFrame extends JInternalFrame {
        static int openFrameCount = 0;
        static final int xOffset = 30, yOffset = 30;
        public MyInternalFrame() {
            super("Document #" + (++openFrameCount),
                  true, //resizable
                  true, //closable
                  true, //maximizable
                  true);//iconifiable
            //...Create the GUI and put it in the window...
            //...Then set the window size or call pack...
            setSize(300,300);
            //Set the window's location.
            setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
    }Note the e.getSource() change in the ActionListener.

  • When I place Ps and Ai files into Id it gets pixelated. How do I fix this?

    I'm making some brochures for a church and I created the text and designs in Ai. When I go to place the Ai file in Id the text and images appear all pixelated! I have tried to do the same thing with Ps files and the text gets pixelated their too. Am I doing something wrong? I have heard that saving the files as a PDF and then using that PDF should help the problem but that has not worked for me either.
    I'm using Adobe CC for all the programs and I'm running Windows 7.

    Sorry for the incredibly late response. We hit the busy season and just have not had to cope with the print results.
    Equipment:
    Canon C5030 Buisness printer.
    Win 7 64 bit
    Adobe CC (all programs are updated to newest CC versions)
    In InDesign Display Performance is set to High Quality Display
    If I am working on and 11in X 17in Indesign document and I bring in some custom logos from Photoshop (the Ps file is 11in X 17in 300ppi)
    no scaling or anything size changes are done it is a simple drag and drop onto the document..
    The Ps file looks rough around the edges and when printed it is "fuzzy" around the edges of the Ps Image. all text created in Indesign looks crisp and perfect.

  • Read pixel from text file

    Hi, is it possible to retrieve an image just by reading some parameters or its pixel from a text file? If yes, could anyone give me some ideas on how to do that? How do you also retrieve a specific line or value from a text file?
    Thanks.

    Hi Fred,
    it seems you started a new thread for that very same topic - again...
    Why can't you keep things in one place? Why do we have to hop between several threads of yours to get all relevant information?
    "if I want to read line 13 of my text file"
    Same question as in the other thread: Where do you start to count? 0 or 1?
    Have you tried to wire a "13" to the ReadLine function?
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How to get pixel colour?

    Is there any way to get pixel colour from specified point? Example: colour = image.getPixel(x, y);
    J2ME/MIDP 1.0
    Thanks!

    {color:#800000}*I am happy to compare the two pixels of same image using this code in Java:*
    {color}
    Image ori, nw;
    public void init()
    { ori = getImage(getDocumentBase(),"flower.jpg");
    int pxl[]= new int [65536];
    PixelGrabber pg = new PixelGrabber(ori,0,0,256,256,pxl,0,256);
    // Image is stored into Array
    try{ pg.grabPixels(); }
    catch(InterruptedException e) {}
    for(int i=0;i<65536;i++)
    { int p = pxl[i];
    int ri = (0xff & (p>>16));
    int gi = (0xff & (p>>8));
    int bi = (0xff & p); // Take the RGB value of each pixel
    for(int j=0;j<255;j++) // Chk. other similar pixel in color range of 0 to 255
    int q = pxl[j];
    int rj = (0xff & (q>>16));
    int gj = (0xff & (q>>8));
    int bj = (0xff & q);
    if ( (ri==rj)&&(gi==gj)&&(bi==bj)&&(!(i==j)))
    { ri+=70;//if (ri<0) ri = 0;
    gi+=70;//if (gi<0) gi = 0;
    bi+=70;//if (bi<0) bi = 0;
    pxl[i] = ( 0xff000000|ri<<16|gi<<8|bi); // Change value
    else
    pxl[i] = ( 0xff000000|ri<<16|gi<<8|bi);// Keep as it is
    Email : [email protected], Profile: www.aribas.edu.in/Mr.Brijesh_Jajal.htm

  • Lightroom not fix hot pixels from my Nikon D7100

    Hi there.
    I have a problem with my cam D7100: there are tons of hot/dead pixels on the sensor.
    I am going to bring this cam to the service center.
    But I have a lot of images captured with this cam, and need to remove hot pixels from them.
    One my friend say about auto-removing in Lightroom.
    So I try Lightroom 4.4, 5.0, 5.2. No one can remove hot pixels.
    (sample images are here:
    http://www.ex.ua/get/327247286713/74274705
    http://www.ex.ua/get/327247286713/74274765
    http://www.ex.ua/get/327247286713/74274845
    http://www.ex.ua/get/327247286713/74274919
    iso 100-200-400-800, shutter 1/250)
    Is this operation going automatically, or I need to chose some tools or options in Lightroom?
    Please, help me somebody, cause thouthands of images are flaking!!!
    Thanks a lot!

    Nikon-User-D7100 wrote:
    I understand, that I have camera's sensor issue, but I can't understand why Lightroom not "repair" that images?
    LR actually does more than find and repair 100% level "stuck pixels," it also finds and corrects low-level hot pixels and higher-level "random" hot pixels. The problem is that you have "many" higher level hot pixels and LR's processing algorithm thinks they're image data. A different raw processor may work better or worse. Feel free to "trial" any of them and report back here what you find. Even with my 600D set +2EV higher in exposure (ISO 100, 1/30 sec. versus ISO 200, 1/250) your noise levels are much higher. IMHO you've got a defective camera!
    (Click on image to see full-size)
       Nikon D7100  ISO 200, 1/250 sec.      Canon 600D ISO 100, 1/30 sec.

  • Read Pixels From Application

    Hi. I'm working on a project for fun in which I need the values associated with pixels at certain locations on a window of an application, which may or may not be changing.
    I've been looking around, but have only been able to find support for reading in pixels from a saved image. One bad way to do it would be to write a script that takes a screen shot and accesses the pixel from the saved image. However, I was hoping for a more direct way to do this because I will want to run this script many times and at a very rapid rate (the higher frequency, the better). The way I suggested would waste both processing time and memory. Is there a way to just have a script pull off the pixel value corresponding to an (x,y) coordinate relative to the entire screen?
    Any other suggestions?
    Thanks,
    Steve

    Hi Steve--
    This thread is a mess, because of all the formatting problems I was having -- not to mention that I somehow got the wrong idea of what you were after. Perhaps you could post your question again as a new thread, with whatever clarification you feel might help?
    In the meantime, I've been trying to figure out exactly what you're up to and my guess is that it might be (probably is?) dynamic image editing for various animation effects. I can see that the code I posted might be useful for size animation, so I tried this with an open Preview window
    (hope there are no formatting issues here):
    set TargetWinName to "MyPicture.jpg"
    -- you must enter the name of your window, or get script to enter it
    set Wins_ to windows of application "Preview" -- you must enter relevant application
    repeat with w_ from 1 to count items of Wins_
    set WinName to name of item w_ of Wins_
    if WinName contains " — " then set WinName to do shell script "echo " & quoted form of WinName & " | sed -e 's/(same note as before)*$//' -e 's/ — //'"
    if WinName is TargetWinName then
    repeat 100 times
    set WinBounds to bounds of item w_ of Wins_
    set bounds of item w_ of Wins_ to {item 1 of WinBounds, item 2 of WinBounds, (0.95 * (item 3 of WinBounds)), (0.95 * (item 4 of WinBounds))}
    end repeat
    exit repeat
    end if
    end repeat
    For me, this essentially makes the image vanish into its upper left corner, but there are all kinds of things you might do. I'm a bit surprised that it works as well as it does, as Preview has limited scriptability.
    I'm assuming (but may be wrong) that you want to do something like this with pixel color -- I don't know how to do that offhand, but I'm thinking about it. New post?
    Message was edited by: osimp

Maybe you are looking for

  • JSF 2.0: Parameterizable Converter

    Hey there, I have implemented a custom converter for type String that checks the user input for forbidden characters. Additionally I 'm looking for a possibility to set a type parameter to change the list of forbidden characters depending on the inpu

  • O.T. Have Your Photograph Taken For Free At Wal-Mart

    'Wal-Mart employee charged with taking woman's picture with cell phone Police say employee told them he was attracted to shopper, took snapshot of her bottom.' http://www.statesman.com/news/content/news/stories/local/10/25/1025photog.html

  • I'm having an issue. if anyone can help please respond.

    I have a WRT400N router, I have my ps3 and my desktop computer hooked up wired to this router. As far as I know the wired connections randomly disconnect and reconnect. My ps3 and desktop disconnect from the internet and moments after reconnects by i

  • Kernel patch level upgrade

    our kernel patch level is 221 now i want upgrade patch latest non unicode 64bit kernel for DB2 database E:\usr\sap\QAS\SYS\exe\nuc\NTAMD64 E:\usr\sap\QAS\DVEBMGS00\exe which one correct directory..

  • MacBook Pro won't turn o n

    Battery charge ran out on my MacBook Pro so I plugged it into a power source. Now it won't start and the white power lite on the front just flashes and beeps.