Swing/AWT/SWT :: Using Image As Button - Remove Border?
Oct 10, 2014
I tried a few things and I was unsuccessful at removing the border around my image button. It seemed simple enough when reading on StackOverflow but I'm still getting errors : s
ImageIcon cardIcon_1_1 = new ImageIcon("../images/empty.png");
JLabel cardImg_1_1 = new JLabel(cardIcon_1_1);
cardImg_1_1.setBorder(BorderFactory.createEmptyBorder());
cardImg_1_1.setContentAreaFilled(false);
Errors:
Multiple markers at this line
- Syntax error on token ";", @ expected
- Syntax error on token ".", @ expected after this token
Multiple markers at this line
- Syntax error, insert "Identifier (" to complete
MethodHeaderName
- Syntax error, insert "SimpleName" to complete
QualifiedName
- Syntax error, insert ")" to complete MethodDeclaration
I'm using an applet it had to be in the initialize part of my program...
View Replies
ADVERTISEMENT
Apr 26, 2015
How can I remove the light blue border? I tried everything that I know [URL]
View Replies
View Related
Mar 22, 2014
I have been reading some java guides here [URL] .... and was trying to put a bit of what I have learnt into practice but am having some difficulty. Basically, using netbeans IDE I have created a new jFrameform so that I can place swing components in design mode. What I want to create isnt overly complicated but I just cant seem to get it. In design I have simply added a panel and a button. When I press the button I want to display an image I have located at:
/resources/images/numbers/1.png.
This is my code so far (most of it has been automatically generated from me adding things via design mode:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package test;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
[Code] ....
I assume I need something like below somewhere , do i need to create a draw method? if so how do I call it as it is expecting graphics2d as a parameter, what would I pass into it?
BufferedImage img = null;
try {
img = ImageIO.read(new File("/resources/images/numbers/1.png"));
} catch (IOException e) {
}
View Replies
View Related
Oct 21, 2014
I've recently decided to learn Java on my own using internet material such as forums, blogs and you tube. Ive never programed before but through some research I concluded that Java is going to be on the mid spectrum of difficulty as far as verbiage goes. I ma in no way implying that Java is easy but instead closer to spoken English that c++ if my research is correct. So here is my attempt at a basic program where I click a button and it will make an image appear. Not sure where Im falling short
package clicktoimage;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Clicktoimage extends JFrame {
private JLabel label;
private ImageIcon image;
[Code]...
View Replies
View Related
Jul 11, 2014
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class image implements ActionListener
{
JFrame frmobj= new JFrame("image");
JPanel panel= new JPanel();
JButton b1= new JButton("image");
[Code] ....
View Replies
View Related
Jan 6, 2014
I'm trying to use netbeans GUI creator to create a chessprogram. However, the default "freeflow" layout is very difficult to work with. However, when I switch the layout to gridbag or border layout, I can't figure out really how to do anything. I don't know how to resize or position elements. Any good set of tutorials for using netbeans GUI creator with non standard layouts?
(I originally used absolute layout, which I can easily add and position elements in, but which I abandoned because i want the chessboard squares to resize when the window changes size).
View Replies
View Related
Sep 14, 2014
I am working on a project (assignment) and i want to be able to click on jlabel and the select border will show (as shown in the image attached) and i used it to resize the jlabel. I tried
@Override
public void componentResized(ComponentEvent e) {
super.componentResized(e);
setPreferredSize(getSize());
}
});`
yet is not working. I tried some other code that are not working.
View Replies
View Related
Mar 26, 2014
I am struggling to make a double border which has rounded corners. The border should be 2 parallel lines.
I made something which looks almost good, but if you look closer there are a few wrong things.To achieve this, I made 2 paths, then painted them in 2 different colours.
The main problem is painting with AA, because the colours overlap and are affected.
I think it would be smoother to paint a single path using 2 colours.
For the first problem, I think some kind of a stroke would be enough. But, if I build a stroke, it's almost same thing like drawing the path twice, like I did before. Anyway i think that would fix AA problem. But still, maybe I can achieve a smoother effect for the corners.
Question:Maybe something with a 2x1 Texture ? It's possible to achieve this ? I know I tried this before and when a curve was encountered the direction of the texture was wrong and looked messy.
PS: Ignore the blueish thing, it's a dragged component to activate the highlight border.
View Replies
View Related
Sep 25, 2014
I am unable to clear disappear the background of .png image added in a translucent JPanel. I have tried it using JLabel but the image added is with white background. How can i get rid of this white background...
import javax.swing.*;
import java.util.*;
import java.awt.*;
public class HomePage
{
JFrame frame;
JPanel pnl1, pnl2, pnl3;
JLabel lbl;
[Code] .....
View Replies
View Related
Apr 7, 2014
Sir, I'am new to Swing Programming. I have to create an application where an image is displayed on one Label. The same image has to be split in parts and stored in database pert wise. Later the user has to retrieve the entire image by viewing a small part of the image. I have already displayed the full image on the Label, now i don't know how to split the image and store it part wise in the database.
View Replies
View Related
Apr 9, 2014
I am trying to add an image to this button.
button3 = new JButton();
button3.setIcon(new Image("C:\Users\Owner\Desktop\AUSE.jpg"));
button3.setEnabled(true);
panel.add(button3);
add(panel);
Error I am getting?
BackgroundImageHelper.java:77: error: Image is abstract; cannot be instantiated
button3.setIcon(new Image("C:\Users\Owner\Desktop\AUSE.jpg"));
^
1 error
[Code] ....
View Replies
View Related
Jun 1, 2014
I want to add only one button in a JFrame by using Mig Layout, dock south as BorderLayout.South does . Is it possible?
View Replies
View Related
Nov 28, 2014
Is there something special about this? I would think not, however all of the buttons in my application work except those with images.Here's an example of one:
Java Code: // Class #1
// All components defined as private initially, used in initComponents() later to build GUI
private JButton btnRock = new JButton();
/** Create the frame. **/
public GameView() {
initComponents(); // Initialize components
} // End of GameView Method
public void initComponents() {
// ROCK BUTTON
btnRock = (JButton) mainController.createIcon("rock");
btnRock.setForeground(new Color(0, 0, 0));
btnRock.setBounds(12, 34, 97, 67);
[code]....
View Replies
View Related
Nov 29, 2014
I am creating a mad libs type program. This section of code is for the user to be able to make their own mad lib template (that people will be able to fill out later). The normal blanks in a mad lib are for verb, noun, adjective, adverb, etc. I cam up with 13 or so of these buttons, but it would be nice that if the user wants to add a button that they think we missed, such as 'Person in the Room' or 'Silly Location'...that the user would be able to do this. I sort of pictured there being a button that says 'add button' or something like that. Is there a ways to do this with the way I've set things up?
public class MadLibs {
public static void main(String[] args) throws IOException {
////////////////////
//TEXT PANE WINDOW//
////////////////////
//Set up a JTextPane object : The JTextPane is a specialized form of the JEditorPane
//designed especially for the editing (and display) of styled text.
final JTextPane pane = new JTextPane();
[Code] ....
View Replies
View Related
Sep 2, 2014
I have a client server application. The UI for the server contains a JTable and in each row, details of the connected client are shown. Say if I have 5 connections and the 3rd connection disconnects, I need the 4th and 5th connection details to be displayed in 3rd and 4th row respectively. Can this be done?
View Replies
View Related
Mar 10, 2014
How can i add a background image for this code without disappearing the button and label? I want a frame that has a background and still shows the buttons and label that I place. and how can I insert Buffered Reader in this code, this is a file organizer, but it only shows first line of a text file. I want to show the whole text file. And is it possible to also show path of the file?
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JTextField;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Scanner;
[code]....
View Replies
View Related
Feb 11, 2015
I have added a background image to this JFrame (see image attached) as I want the buttons and field to just be on top of the image, how to remove the colored part of the JFrame that is left?
View Replies
View Related
Dec 9, 2014
There are 8 JCheckboxes, which are already added to panel and aligned in group layout. From which, I have selected one JCheckbox. Then the resultant GUI should contain only remaining 7 JCheckboxes and selected one should temporarily removed or hide from GUI . Is it possible? If so, how?
View Replies
View Related
Jan 28, 2014
I have a textField in which I have text in. The text is enter customer name. I would like for this text to disappear whenever the user clicks on the textField to enter a customer name. I am using the automated swing gui builder in NetBeans. Is their some sort of feature for this under properties of the text field? If not then what are my other options?
View Replies
View Related
Sep 27, 2014
I want to write simple game. Why if I press button UP and RIGHT it not move diogonally, may be it have special code. And how I need to write correctly border and gravity?
public class Main {
public static void main(String args[]) {
JFrame frame = new JFrame("Stickman");
Ground ground = new Ground();
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.setSize(710, 480);
[code]....
View Replies
View Related
Apr 8, 2014
I'd like open a second GUI when I press a button that's on the first GUI, like a link in a website.
What I want to do is:
1- Open GUI_1;
2- Press a button on GUI_1; this button close GUI_1 and open another GUI (GUI_2).
How can I do it?
View Replies
View Related
Jan 26, 2015
I have a program I wrote long ago. I change colors of buttons at times. Here is the code:
for(int Player=0; Player < 8; Player++){
//make them all background
dealerLabels[Player].setBackground(new java.awt.Color(212,208,200));
}
//Now make the new dealer green
dealerLabels[dl].setBackground(new java.awt.Color(51, 255, 0));
The color of the buttons has always changed under XP but when I run the program on Windows 8 only the edges of the buttons change.
View Replies
View Related
Sep 19, 2014
How to save in array or arraylist when i click the jbutton
View Replies
View Related
Feb 17, 2014
I installed Netbeans 7.0.1 but I couldn't find border option's more fonts and color palette as being 7.4.
I would like to download.
I want to change Panel's border color and font but when I click there is few fonts and color options.
View Replies
View Related
Jul 3, 2014
I am trying to add buttons in a loop to my but when i compile my program i can`t see my buttons. I can see other stuff that added to jpanel ...
static JButton blocks[][];
for (int i = 0; i < block.length; i++) {
for (int j = 0; j < block[i].length; j++) {
block[i][j] = new Block(i, j);
blocks[i][j] = new JButton(i+"");
blocks[i][j].setLayout(new GridLayout((i+1) * 10, (i+1) * 10, 10, 10));
pageAxisPanel.add(blocks[i][j]);
}
}
View Replies
View Related
Mar 5, 2014
For the following code.When I run it ,I am getting the image and Login written along with it , but not getting the preselected radio button
import javax.swing.*;
public class MyJFrameWithJRadioButton extends JFrame
{
JRadioButton rdButton;
public MyJFrameWithJRadioButton()
{
setTitle("This is a JFrame");
setBounds(0, 0, 200, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
rdButton =new JRadioButton("Login",new ImageIcon(ClassLoader.getSystemResource("Login.png")),true);
add(rdButton);
setVisible(true);
[code]....
View Replies
View Related