If you know the problem of using java to create image watermarks, please give me some advice.
I want to add a transparent icon to a picture (.jpg). The icon file is .tif. I tested it with a program and it had no effect. For those experts who have experience in this area, please give me some advice. The procedure is as follows: package com.soft.test; //package net.wayne.images; import java.awt.*; import java.awt.image.*; import java.io.*; import javax.swing.*; import com.sun.image.codec.jpeg.*; public class WaterMark2 { //Add watermark, filePath source image path, watermark watermark image path public static boolean createMark(String filePath, String watermark) { ImageIcon imgIcon = new ImageIcon(filePath); Image theImg = imgIcon.getImage(); ImageIcon waterIcon = new ImageIcon(watermark); Image waterImg = waterIcon.getImage(); int width = theImg.getWidth(null); int height = theImg.getHeight(null); BufferedImage bimage = new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB); Graphics2D g = bimage.createGraphics(); g.setColor(Color.red); g.setBackground(Color.white); g.drawImage(theImg, 0, 0, null); g.drawImage(waterImg,100,100,null); g.drawString(“www.lighting86.com.cn”, 10, 10); //Add text g.dispose(); try { FileOutputStream out = new FileOutputStream(filePath); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bimage); param.setQuality(50f, true); encoder.encode(bimage, param); out.close(); } catch (Exception e) { return false; } return true; } public static void main(String[] args) { WaterMark2 test = new WaterMark2(); test.createMark(“I:\\pageMark\\yueji.jpg”,”I:\\pageMark\\water.tif”); } } 7 solutions #1 After testing, there is no problem. Is the poster’s “I:\\pageMark\\yueji.jpg” read-only? Print out the exception and take a look catch (Exception…
My first JAVA program, please give me some advice
Problem description: An addition operation programming idea for a two-dimensional array: find the sum of the non-diagonal elements of the two-dimensional array (the number of rows and columns must be equal), that is, find the sum of the non-diagonal elements outside the two diagonals The sum of the elements. package hu;public class TestMatrix { /** * @param args */ public static void main( String[] args) { // TODO Auto-generated method stub int[][] a={{1,1,1,1},{1,2,2,1} ,{1,2,2,1},{1,1,1,1}};//Initialize the array such as 4*4 printMatrix(a);//Output the array in two dimensions int sum=addMatrix(a); System.out.println(“Sum of off-diagonal elements of a two-dimensional array (the number of rows and columns must be equal):”+sum); } static void printMatrix(int[][] a){ for(int i=0;i { for(int j=0;j if(j==3) { System.out.print(a[i][j]); System.out.println(); } else { System.out.print(a [i][j]); } } } static int addMatrix(int[][] a){ int s=0,t=0,f=0 ; for(int i=0;i { for(int j=0;j s=s+a[i][j]; t=t+a[i][i] +a[i][3-i]; } f=s-t; return f; }} Run results: 1111122112211111The sum of the off-diagonal elements of the two-dimensional array (the number of rows and columns must be equal): 8
A female man wants to change his career to Java development, please give me some advice, TKS!
I am currently working in a clerical field, working five days and eight hours, and the actual working time is no more than three hours a day. The rest of the time is basically spent on soy sauce. There is no sense of accomplishment in the work, and I feel quite bored every day. By chance, I feel that I quite like Java. Now I watch Java videos when I have nothing to do, so I want to switch to Java development work. I would like to ask you about the current development prospects of Java. How about it (I searched online and found a lot of negative information), what is the general salary after working in Java for one or two years (in first-tier cities)? Is it easy for girls to find jobs in Java development? Currently, I want to change my career through training. Yesterday I went to Shenzhen to check out Danai. I felt that the learning atmosphere is not bad, but the tuition is quite expensive (15800). Is there any training place where I can go? How is the training there? 25 solutions #1 Yes With so much time, it would be great to study on…
I have been working in java for one and a half years, please give me some advice.
I started as an intern at the beginning of last year and have been working as a full-time employee now. I have been involved in Java development for more than a year and a half. I have been working in the same company. This company is mainly engaged in credit card issuance. The main core business and logic are all in the IBM mainframe. That is the (COBEL) language we often hear. A very few people understand the language. Compared with the mainframe, Java is mainly responsible for the interaction between the mainframe and peripheral systems in the company, which is actually the conversion of some encodings and formats and the transmission of files. I am mainly responsible for the interaction of some dynamic information and the short message notification system. Simply put, it is to convert every request sent by the host to Java into ASCII and convert it into the format agreed with the customer, and then Send the request to the customer as well as the SMS operator. The main interfaces used are HTTP/HTTPS and TCP/IP, and XML format messages are used in the request conversion process. In addition, I have come into contact with some file…
Servlet provides initialization database connection parameters and Javabeans and JSP confusion, please give me some advice.
That’s it, I put the database connection parameters in web.xml, and then read the parameters through the init of the mapped servlet (iniConn.java), The confusion is: 1. How do I get the parameters obtained in servle in the encapsulated database connection javabean (conn.java)? 2. Is it possible for a javabean to operate the database and then obtain the object from the database connection javabean (data.java), operate the database and return the result set to the JSP page or other javabean? ? 3. This javabean (conn.java) that operates the database will often be called by other javabeans or jsps or servlets, so can it be implemented? How exactly does it work? I mean servlet (iniConn.java) is not initialized when the client requests it, right? I have other servlets. How can I send a request to (iniConn.java)? How to fill in here? ? Such as source code: web.xml <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”> initServlet com.initServlet DRIVER com.mysql.jdbc.Driver …
A female man wants to change his career to Java development, please give me some advice, TKS!
I am currently working in a clerical field, working five days and eight hours, and the actual working time is no more than three hours a day. The rest of the time is basically spent on soy sauce. There is no sense of accomplishment in the work, and I feel quite bored every day. By chance, I feel that I quite like Java. Now I watch Java videos when I have nothing to do, so I want to switch to Java development work. I would like to ask you about the current development prospects of Java. How about it (I searched online and found a lot of negative information), what is the general salary after working in Java for one or two years (in first-tier cities)? Is it easy for girls to find jobs in Java development? Currently, I want to change my career through training. Yesterday I went to Shenzhen to check out Dane. I felt that the learning atmosphere is not bad, but the tuition is quite expensive (15800). Is there any place where I can go for training? How is the training there? 25 solutions #1 Yes So much time, so good for self-study. No other comments…
I have been working in java for one and a half years, please give me some advice.
I started as an intern at the beginning of last year and have been working as a full-time employee now. I have been involved in Java development for more than a year and a half. I have been working in the same company. This company is mainly engaged in credit card issuance. The main core business and logic are all in the IBM mainframe. That is the (COBEL) language we often hear. A language that few people understand. Compared with the mainframe, Java is mainly responsible for the interaction between the mainframe and peripheral systems in the company, which is actually the conversion of some encodings and formats and the transmission of files. I am mainly responsible for the interaction of some dynamic information and the short message notification system. Simply put, it is to convert every request sent by the host to Java into ASCII and convert it into the format agreed with the customer, and then Send the request to the customer as well as the SMS operator. The main interfaces used are HTTP/HTTPS and TCP/IP, and XML format messages are used in the request conversion process. In addition, I have come into contact with some file transfer…
Java button monitoring is invalid_JAVA calculator framework, there is no monitoring, the button is invalid, please give me some advice. . .
This floor is suspected of violating the rules and has been folded by the system. Hide this floor to view this floor mi_paste.setMnemonic(KeyEvent.VK_V); mi_paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent. VK_V, KeyEvent.CTRL_MASK)); menu_check.setMnemonic(KeyEvent.VK_V); mi_standard.setMnemonic(KeyEvent.VK_T); mi_science.setMnemonic (KeyEvent.VK_S); mi_Packet.setMnemonic(KeyEvent.VK_I); menu_help.setMnemonic(KeyEvent.VK_H); mi_theme.setMnemonic(KeyEvent.VK_H); mi_about.setMnemonic(KeyEvent.VK_A); /******************************** Set key** ******************************/ pan_mc.setSize(50, 180); pan_mc.setLocation(5, 38); pan_mc.setLayout(new GridLayout(5, 1, 5, 5)); contenPane.add(pan_mc) ; JButton jbu_null, jbu_mc, jbu_mr, jbu_ms, jbu_m; jbu_mc = new JButton(“MC”); //Border border = null; jbu_null = new JButton(); jbu_null.setForeground(Color.red); jbu_null.setBorder( BorderFactory.createLoweredBevelBorder()); jbu_null.setBorder(BorderFactory.createLineBorder(Color.RED));//Add a red border to the text jbu_mc.setForeground(Color.red) ; jbu_mr = new JButton(“MR”); jbu_mr.setForeground(Color.red); jbu_ms = new JButton(“MS”); jbu_ms.setForeground(Color.red); jbu_m = new JButton(“M+”); jbu_m.setForeground(Color.red); pan_mc.add(jbu_null); pan_mc.add(jbu_mc); pan_mc.add (jbu_mr); pan_mc.add(jbu_ms); pan_mc.add(jbu_m); /************ ********************** Set number buttons****************************** *******/ pan_number.setLayout(new GridLayout(4, 5, 5, 5)); JButton[] jbu_num = new JButton[ 20]; for (int i = 0; i <20; i++) { jbu_num[i] = new JButton(); pan_number.add(jbu_num[i]); if (i <20) { jbu_num[i].setBorder(BorderFactory .createBevelBorder(BevelBorder.RAISED)); } } jbu_num[0].setText(“7”); jbu_num[0].setForeground (Color.blue); jbu_num[1].setText(“8”); jbu_num[1].setForeground(Color.blue); jbu_num[2].setText (“9”); jbu_num[2].setForeground(Color.blue); jbu_num[3].setText(“/”); jbu_num[3].setForeground(Color.red); jbu_num[4].setText(“sqrt”); jbu_num[4].setForeground(Color.blue); jbu_num[5].setText(“4”); jbu_num [5].setForeground(Color.blue); jbu_num[6].setText(“5”); jbu_num[6].setForeground(Color.blue); jbu_num [7].setText(“6”); jbu_num[7].setForeground(Color.blue); jbu_num[8].setText(“*”); jbu_num[8].setForeground(Color .red); jbu_num[9].setText(“%”); jbu_num[9].setForeground(Color.blue); jbu_num[10].setText(” 1″); jbu_num[10].setForeground(Color.blue); jbu_num[11].setText(“2”); jbu_num[11].setForeground(Color.blue); jbu_num[12].setText(“3”); jbu_num[12].setForeground(Color.blue); jbu_num[13].setText(“-“); jbu_num[13 ].setForeground(Color.red); jbu_num[14].setText(“1/x”); jbu_num[14].setForeground(Color.blue); jbu_num [15].setText(“0”); jbu_num[15].setForeground(Color.blue); jbu_num[16].setText(“+/-“); jbu_num[16 ].setForeground(Color.blue); jbu_num[17].setText(“.”); jbu_num[17].setForeground(Color.blue); jbu_num[18 ].setText(“+”); jbu_num[18].setForeground(Color.red); jbu_num[19].setText(“=”); jbu_num[19] .setForeground(Color.red); pan_number.setSize(220, 150); pan_number.setLocation(60, 70); contenPane.add (pan_number); this.setJMenuBar(menubar); } public static…
Questions about reading streams in java, please give me some advice
The following is a piece of code that can be executed normally. There is a problem in it that I don’t quite understand. See the comments inside 12345 6789101112131415 16 /** * Get the byte array from the input stream * @param inputStream * @return * @throws IOException */ private static byte[] _readInputStream(InputStream inputStream) throws IOException { byte [] buffer = new byte[1024]; int len = 0; ByteArrayOutputStream bos = new ByteArrayOutputStream(); while((len = inputStream .read(buffer)) != -1) { //! The question is here, is this reading 1024 bytes each time? Then if the read stream does not have 1024 bytes at all in the end, doesn’t the read fail here? Wouldn’t it mean that all the files being read will be missing a part? bos.write(buffer, 0, len); (); }
java tree easyui, how to create easyUI tree, please give me some advice
How to create easyUI tree? Please advise This is my JS code. I visited my controller here – but the controller returned a page. -. -I obviously just want to return a list collection of trees contentType=”text/html; charset=UTF-8″%> $(function() { $('#layout_west_tree').tree({ url : '${pageContext.request.contextPath}/mc/more. do', parentField : 'pid', lines : true, }); }); data-options=”isonCls:'icon-save',tools: [ { iconCls: 'icon- reload', handler : function() { $('#layout_west_tree').tree('reload'); } }, { iconCls : 'icon-redo', handler : function() { var node = $('#layout_west_tree').tree('getSelected'); if (node) { $('#layout_west_tree').tree('expandAll', node.target); } else { $('#layout_west_tree').tree('expandAll'); } } }, { iconCls : 'icon-undo', handler : function() { var node = ; $('#layout_west_tree').tree('getSelected'); if (node) { $(' ;#layout_west_tree').tree('collapseAll', node.target); } else { $('#layout_west_tree&# 39;).tree('collapseAll'); } } } ]”> package contro; import java.util.ArrayList; import java.util.List; import model.person; import org.springframework.stereotype. Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; & #64;Controller @RequestMapping(“/mc”) public class MenuContro{ @RequestMapping(“/more” ) public List more(){ person p=new person(1, “name_1”, 0); person p1= new person(2, “name_1.1”, 1); person p2=new person(3, “name_1.2”, 1); List list&# 61;new ArrayList(); list.add(p); list.add(p1); list.add(p2); if(list!=null){ System.out.print(“yes”); return list; } return null; } public static void main(String arg[]){ MenuContro m= ;new MenuContro(); System.out.print(m.more()); } } – —–Solution idea———————- Your request must be in json format, okay,you Give me…