Substitute one color with another on an image


Hi!

I need to substitute one color with white on an image. I've read about IndexColorMmodel, ColorModel and RGBImageFilter, but I don't understand how they work.

The color I want to substitute is: R: 113 G: 75 B: 96

And of course, white is 255,255,255.

I've read several examples, but can't grasp all the concepts. I'm new working with images.

How can I do it
Posted On: Thursday 27th of September 2012 11:00:59 PM Total Views:  90
View Complete with Replies

RELATED TOPICS OF Swing / AWT / SWT PROGRAMMING LANGUAGE




Transfer Focus From JTable To Other Component

How I transfer focus from jtable to other component usiing tab or shift tab keys.
VIEWS ON THIS POST

69

Posted on:

Monday 24th September 2012
View Replies!

Tab order on swing components

, friends I have one doubt related to tab order. I have written a class that implements FocusTraversalPolicy. Now when my focus moves over the disabled component then getComponentAfter method of the FocusTraversalPolicy class is not getting called and hence next components doesnt receive any focus neither by pressing TAB nor by pressing SHIFT+TAB once the focus is on disabled component. In case of enabled components everything works perfectly fine. I need to move the tab/focus on the disabled components too. Can anyone please help me in this regards Is it possible to set focus on disabled component although it doesnt makes sense to focus on disabled components Waiting for your suggestions
VIEWS ON THIS POST

121

Posted on:

Tuesday 25th September 2012
View Replies!

How do I cycle through an array of strings and display them one at a time when JButton is clicked

all, I am a 42 year old computer science major but only two years in so I still have much to learn. I have pulled some strings from a text file and loaded them into an array. What is the best way to have each string displayed every time the next question button is pushed I am displaying it into a Text Field box, is this what would normally be used or is there a box better suited for this purpose I was planning on doing basically the same thing in the program with a file full of jpg's, but was hoping to make them display in the same window each time a new question was brought up. Any thoughts, suggestions, or flat out help would be appreciated,
VIEWS ON THIS POST

169

Posted on:

Tuesday 25th September 2012
View Replies!

JButton clicked once, action done twice

Greetings all, Initially, I am not supplying code because I do not think it will help too much, but if anyone wants to see a bit, I can provide it. In short, I have a dialog box with a bunch of fields and a save button. the save button implements an action listener that calls the save(). It reads the fields, creates an instance of another class and calls the methods to have it saved to my database. The problem is, that when I click once on button, the save() is called twice. The only thing I can think of is that I should be using a mouseAdapter or mouseListener instead of an actionListener. Can anyone confirm this
VIEWS ON THIS POST

96

Posted on:

Tuesday 25th September 2012
View Replies!

Need to create only one object

all, Please have a look at the following set of codes MyPhoneBookMain.java import javax.swing.*; public class MyPhoneBookMain { public static void main(String[]args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); new MainView(); } catch(Exception e) { JOptionPane.showMessageDialog(null, "GUI Error"); e.printStackTrace(); } } }
VIEWS ON THIS POST

97

Posted on:

Tuesday 25th September 2012
View Replies!

Component movement from one (x,y)location to another (x,y)location within given time

HI , I have a requirement where in a JComponent like JButton, JLabel, JTextArea, etc., should me moved from given (x,y) location to another given (x,y) location within a given specific time in milli seconds. Inputs given are: 1. Start (x,y) 2. End (x,y) 3. Time to travel from start (x,y) to end (x,y) Say, if i have given the time as 4000ms, the component should travel from start (x,y) to end (x,y) in 4000ms (4 secs).
VIEWS ON THIS POST

120

Posted on:

Tuesday 25th September 2012
View Replies!

how to calculate cpu/memory utilizing by jcomponents/jpanels/Jframe?

I create 1 Jframe in that 1 big jpanel fitted to that JFrame. In that jpanel i create array of jpanels(small) say n numbers...n=5,6,7,,9...up to...99. size (25,25) Now i want print statement which shows cpu/memory utilized by each panel/component...
VIEWS ON THIS POST

278

Posted on:

Tuesday 25th September 2012
View Replies!

problem in printing swing components?

i have a registration page, and after registration of a student i need to print the tc (transfer certificate), in the (Photo1430.jpg) image format, (in the same format shown in the image). field values are coming from the database.(ie. value of name, value of dob, value of place so on...) i am doing something like this: import java.awt.*; import java.awt.event.*; import java.awt.print.*; import javax.swing.*; public class PrintUIWindow implements Printable, ActionListener { JFrame frameToPrint; JLabel lblStuName, lblBirthPlace, lblDob, lblLastSch, lblLastExam, lblYearOdAdd,lblStudyingStandard; JLabel d, d1, d2, d3, d4; static JPanel panel; Box horiz1, horiz2, horiz3, horiz4, horiz5, horiz6; public PrintUIWindow() { panel = new JPanel(); lblStuName = new JLabel("1.) Name of Student (in Full)"); lblBirthPlace = new JLabel("2.) Place of Birth"); lblDob = new JLabel("3.) Date of Birth, Month and year (in figures)"); lblLastSch = new JLabel("4.) Last School College Attended"); lblLastExam = new JLabel("5.) Last Examination Passed"); d1 = new JLabel(" : ........................................................."); d2 = new JLabel(" : ........................................................."); d3 = new JLabel(" : ........................................................."); d4 = new JLabel(" : ........................................................."); d = new JLabel(" : ........................................................."); horiz1 = Box.createHorizontalBox(); horiz1.add(lblStuName); horiz1.add(d); horiz2 = Box.createHorizontalBox(); horiz2.add(lblBirthPlace); horiz2.add(d1); horiz3 = Box.createHorizontalBox(); horiz3.add(lblDob); horiz3.add(d2); horiz4 = Box.createHorizontalBox(); horiz4.add(lblLastSch); horiz4.add(d3); horiz5 = Box.createHorizontalBox(); horiz5.add(lblLastExam); horiz5.add(d4); Box vert = Box.createVerticalBox(); vert.add(Box.createVerticalStrut(100)); vert.add(horiz1); vert.add(Box.createVerticalStrut(30)); vert.add(horiz2); vert.add(Box.createVerticalStrut(30)); vert.add(horiz3); vert.add(Box.createVerticalStrut(30)); vert.add(horiz4); vert.add(Box.createVerticalStrut(30)); vert.add(horiz5); panel.add(vert); } public int print(Graphics g, PageFormat pf, int page) throws PrinterException { if (page > 0) { /* We have only one page, and 'page' is zero-based */ return NO_SUCH_PAGE; } /* * User (0,0) is typically outside the imageable area, so we must translate * by the X and Y values in the PageFormat to avoid clipping */ Graphics2D g2d = (Graphics2D) g; g2d.translate(pf.getImageableX(), pf.getImageableY()); /* Now print the window and its visible contents */ frameToPrint.print(g); /* tell the caller that this page is part of the printed document */ return PAGE_EXISTS; } public void actionPerformed(ActionEvent e) { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(this); boolean ok = job.printDialog(); if (ok) { try { job.print(); } catch (PrinterException ex) { /* The job did not successfully complete */ } } } public static void main(String args[]) { JFrame f = new JFrame("Print TC"); JButton printButton = new JButton("Print TC"); printButton.addActionListener(new PrintUIWindow()); panel.add("South", printButton); f.add(panel); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); } }
VIEWS ON THIS POST

505

Posted on:

Tuesday 25th September 2012
View Replies!

How To Stop Flicking JPanel Component?

The code below flickers when I update. I've heard about double buffering but no idea how it works/how I would implement that. import javax.swing.JPanel; import java.awt.Graphics; import java.awt.Graphics2D; public class VisualFrame extends JPanel { public static RuntimeConverter x = new Converter(); public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; x = new Converter(); //Draw it display.draw(g2); } public Converter getConverter() { return x; } }
VIEWS ON THIS POST

52

Posted on:

Tuesday 25th September 2012
View Replies!

display data from a JComboBox from one JFrame to another

, I have two windows, one where the user selected an element in a JComboBox and the other where I want to retrieve the value of this JComboBox and display it in a label. The problem is: how to retrieve the value of the text in the JComboBox and send it to my second window I have two class in the same package : fenetre1.java public JLabel labelR ; . . . fenetre1(){ . . String g=comboBox1.getSelectedItem().toString(); String a=comboBox2.getSelectedItem().toString(); String v=comboBox3.getSelectedItem().toString(); labelR1.setText(g); . . . }
VIEWS ON THIS POST

201

Posted on:

Wednesday 26th September 2012
View Replies!

3 JComboBox dependent of one another

, I have 3 ComboBox that depends on the other one depends on the 2nd and 3rd 1st 2nd depends. the problem that the elements of 2nd ComboBox there has one element that appears (the first element) I do not know how to correct it. another problem just how empty a ComboBox from an index I tried removeItemAt (anIndex); event on the first ComboBox: if (selectedIndexc1 == 1) { ... comboBoxc2.removeItems(); try { Statement m = s.getConn().createStatement(); rs1 = m.executeQuery(rq); while (rs1.next()) { String A1= rs1.getString("...."); comboBoxc2.addItem(A1); nbp++; } } catch (SQLException e1) { e1.printStackTrace(); } }
VIEWS ON THIS POST

85

Posted on:

Wednesday 26th September 2012
View Replies!

SWT Table - sum one column and save all content in MySQL table.

!!! I want to do two things: 1. Get the sum of the column "Price". 2. Save all table's content in a MySQL table. (almost done but wrong way) For the second issue I try this: for(int row = 0; row < vista.tdetalle.getItemCount(); row++) { //product = item.getText(0); //price = item.getText(1); product = item.getText(row); // How can I set the first column here\t price = item.getText(row);// How can I set the second column here\t facade.RegistrarBitacora(product,price);//Here save on DB }
VIEWS ON THIS POST

121

Posted on:

Wednesday 26th September 2012
View Replies!

Swing has Swung -- a substitute for my buttons?

I've been using Netbeans for about three years in developing a GUI project. Now, as of version 7.0 they will no longer support my buttons and JFrames and such. Is there a product of GUI buttons, checkboxes and such which is an upgrade of swing, or must I rework the whole >blank, blank< GUI interface again
VIEWS ON THIS POST

94

Posted on:

Wednesday 26th September 2012
View Replies!

AWT Component Loading Issue After Accessing it for a while

I've a AWT Java application which is accessible by a JSP page. JSP pages are deployed in a web application and AWT classes are inside a Java application. Both web and Java is bundled in an ear file which is installed on an IBM websphere application server 7. AWT application is launched by a JSP login page. There are different buttons in that AWT app to access different functionalities of the application. They all makes database call (simple CRUD operation) to save/update database record. When multiple user (5 user) log in to the system with their credentials, after sometime, AWT application stops responding. Application starts hanging/freezing after sometime. When you click on one functionality, the child frame does not paint correctly and due to this, input form fields of child frame does not load. You have to close the AWT main window and then re-login to access the AWT application. We're not able to replicate this with single user. We've then tested it with 4 user and there was no issue. When we've increased user to 5 i.e., 5 users concurrently accessing AWT application, then we have got this screen freezing problem (child frame components not loading correctly after sometime of access). Does anyone have faced this issue in AWT Any idea how to approach and find the root cause for this.
VIEWS ON THIS POST

66

Posted on:

Wednesday 26th September 2012
View Replies!

Can anyone help me to spot a mistake in the method.

Can anyone help me to spot a mistake in the method. In previous post method now works but the problem with that is it labels a JLabel in JPanel but I want now to place an image in JPanel itself. what I am doing wrong\t. Cheers in advance public void openFavorite(File fileToOpen){ try { BufferedImage bi = ImageIO.read(fileToOpen); Graphics g = bi.getGraphics(); Graphics2D g2d =(Graphics2D)g; g2d.drawImage(bi, null, 0,0); // this is a JPanel this.repaint(); this.revalidate(); } catch(Exception exception) { System.out.println("Problem occour when to open the file"); } }
VIEWS ON THIS POST

315

Posted on:

Wednesday 26th September 2012
View Replies!

JTabbedPane.getTabComponentAt(int) is not working

Hallo, I'm trying to iterate over all tabs in a JTabbedPane but somehow getTabComponentAt always resturns null. I suppose I made a mistake but I can't find it. here an example : public class TabbedPaneDemo { public static void main(String[] args) { JFrame f = new JFrame("TabbedPane demo"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel l1 = new JLabel("Label 1"); JLabel l2 = new JLabel("Label 2"); JLabel l3 = new JLabel("Label 3"); // create the JTabbedPane JTabbedPane tabbedPane = new JTabbedPane(); // add the 3 JLabels tabbedPane.addTab("Tab 1", l1); tabbedPane.addTab("Tab 2", l2); tabbedPane.addTab("Tab 3", l3); // iterate over the Tabs int tabcount = tabbedPane.getTabCount(); System.out.println("tabcount: " + tabcount); for (int i=0; i
VIEWS ON THIS POST

164

Posted on:

Wednesday 26th September 2012
View Replies!

Paste SWT Controls from one shell to another Shell

Hi all, How to paste SWT controls from one shell to another shell and from one compsoite to another composite withour creating the controls again. For eg. I have SWT Text in a CompositeA in ShellA. I need to copy the control and paste it in ShellB. Pelase help me or give your useful suggestions.
VIEWS ON THIS POST

67

Posted on:

Wednesday 26th September 2012
View Replies!

SWT Print selective components

I want to print selected components of my JFace ApplicationWindow. I have multiple components like TextBox,TableViewer,TreeViewer and Listbox. I want to print only the TableViewer and TextBox. Can anyone please help me
VIEWS ON THIS POST

73

Posted on:

Wednesday 26th September 2012
View Replies!

Components brought infront of Glass Panel

I wanted to make my own sort of message boxes for a program I'm working on for both stylistic reasons and later some functional ones. First I have it create a black JPanel and make it the glass panel so that it may be slightly transparent as well as in-front of everything. After that, I add a custom JPanel in front of that, that serves as the actual message. The problem is, when I add an object to the center of it, the object underneath it comes to the front; and by underneath, I man under the glass panel. If I add something to the top, where there's nothing under it, it has not effect. Also, I'm using BorderLayout if that makes a difference.
VIEWS ON THIS POST

35

Posted on:

Wednesday 26th September 2012
View Replies!

How many times painComponent(g) is called?

If I the method painComponent(g) is called is it called once or multiple times if I don't use repaint\t=/
VIEWS ON THIS POST

98

Posted on:

Thursday 27th September 2012
View Replies!