imageicon

Creating custom JButton from images containing transparent pixels

匆匆过客 提交于 2019-11-27 09:30:30
Read edit 2 for what I'm actually missing to make it work I'm currently trying to create some custom JButtons using images created in photoshop that have an alpha parameter. So far, overriding the paint() method to draw the image has worked in the sense that the button is drawn showing the correct image. I'd like to improve it, though, by making its shape (clickable area) the same as the visible pixels on the image (right now if I draw the button's border, it's a square). Is there an easy way to do that or do I have to parse the image and find the alpha pixels to make a custom border? Which

Displaying an image in Java Swing

跟風遠走 提交于 2019-11-27 08:55:58
public class MinesweeperMenu extends MinesweeperPanel{ private JPanel picture = new JPanel(); private JButton play = new JButton("Play"); private JButton highScores = new JButton("High Score and \nStatistics"); private JButton changeMap = new JButton("Create Custom \nor Change Map"); private JButton difficulty = new JButton("Custom or\nChange Difficulty"); private JButton user = new JButton("Change User"); Image img; public MinesweeperMenu() { // Set Layout for the menu LayoutManager menuLayout = new BoxLayout(menu, BoxLayout.Y_AXIS); menu.setLayout(menuLayout); // Set Layout for the window

Java: Add Background image to frame [duplicate]

十年热恋 提交于 2019-11-27 08:52:15
问题 Possible Duplicate: java swing background image drawing your own buffered image on frame I am trying to add a back ground image to my frame, but nothing that I have done works. I designed a slot machine consisting of several panels added to the container. Now, I am trying to add a nice background to the frame. I tried using the paint method. But, since I am already using the paint method to paint the reel images, it is not working on the background. I also tried adding a JLabel, but when I do

Can't add image using ImageIcon to jTable cell

好久不见. 提交于 2019-11-27 08:38:16
问题 I trying to add image using ImageIcon class to jTable cell , but i get in the cell sun.awt.image.ToolkitImage@196a4632 where it supposed to display image in the cell the code i tried : JTable jTable; String[] columns={"Page No","Chapter","Image"}; Object[][] rows={{1,4,null},{2,7,null}}} public Tab_ImgIcn(){ ImageIcon icon=new ImageIcon(getClass().getResource("exit.png")); jTable= new JTable(rows, columns); jTable.setValueAt(icon.getImage(), 0,3); JScrollPane jps = new JScrollPane(jTable);

putting marks on ImageIcon in JLabel

僤鯓⒐⒋嵵緔 提交于 2019-11-27 08:18:47
问题 So I'm trying to find a way to modify an image in Java. In other words, if user clicks on the image, a mark will be put at the point where the user just clicked. I have an ImageIcon which I put in a JLabel. So far, the approach I took was to use JLayeredPanel to put another JPanel on top of the JLabel and draw on this JPanel: //... ImageIcon icon = new ImageIcon("foo.jpg"); JLabel lb = new JLabel(icon); JPanel glass = new JPanel(); lb.setBounds(0, 0, 100, 100); glass.setBounds(0, 0, 100, 100)

How to add an ImageIcon to a JFrame?

心已入冬 提交于 2019-11-27 07:10:27
问题 I'm trying to add an image to one frame but it seems it does not working. The image created by an ImageIcon from the specified file. The image file is in the seam directory the java file exist. import java.awt.BorderLayout; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; public class image { public static void main(String args[]) { TimeFrame frame = new TimeFrame(); } } class TimeFrame extends JFrame { //Image icon = Toolkit.getDefaultToolkit().getImage("me

How to get Icon from JTable

不羁的心 提交于 2019-11-27 05:38:21
I have changed the cell render in JTable to show image instead of text using the following code: base_table.getColumnModel().getColumn(3).setCellRenderer(new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable jtable, Object value, boolean bln, boolean bln1, int i, int i1) { JLabel lbl = new JLabel(); lbl.setIcon((ImageIcon) value); return lbl; } }); Now, I'd like to be able to get the image for each row in the JTable in order to save it in database. How could I do that? I can't resist just example for that import java.awt.BorderLayout; import java.awt

Mirroring animated gif on load in Java - ImageIcon

青春壹個敷衍的年華 提交于 2019-11-27 05:33:21
So I have an animated gif that I load into an ImageIcon like this: Image image = new ImageIcon("image.gif").getImage(); and I can draw it using this: g.drawImage(image, x, y, null); I know that I can mirror it on the fly using AffineTransform, but I need to be able to mirror it horizontally after loading, so that I can draw the mirrored one instead if needed without the overhead of transforming it every time it gets redrawn. Is there a way to do this using swing/awt? A library that could do this would also be a huge help. MadProgrammer The problem is, as you have pointed out, is the fact the

C# console application icon

喜夏-厌秋 提交于 2019-11-27 05:23:57
Does anyone know how to set a C# console application's icon in the code (not using project properties in Visual Studio)? You can't specify an executable's icon in code - it's part of the binary file itself. From the command line you'd use /win32icon:<file> if that's any help, but you can't specify it within the code of the application. Don't forget that most of the time the application's icon is displayed, your app isn't running at all! That's assuming you mean the icon for the file itself in explorer. If you mean the icon of the application while it's running if you just double-click the file

Rendering BufferedImage in JTable cell

a 夏天 提交于 2019-11-26 23:43:08
问题 I need to display a BufferedImage in one JTable column. I overwrote JTable method @Override public Class<?> getColumnClass(int column) { if (column == 1){ return BufferedImage.class; } return super.getColumnClass(column); } But I am still obtaining String representation of the object instead of image itself.Does anyone have idea what I am missing? 回答1: I'd populate the column that needs to show an image with ImageIcons and have the getColumnClass() method return Icon.class, and then render it