I am adding JLabels to my JPanel, and the last one always does not show up. For example if I add 3 JLabels, the 3rd will not show up. If i change it to add 4, the 4th will not show up, but the 3rd will now. Here is a snipit of what my code looks like:
A workaround that I DO NOT want to keep doing is to put an extra fake JLabel at the end of the for loop, that way everything I want to show up does, but the fake one does not.
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;
I am trying to move a JLabel in a JPanel, but can't seem to make it work. I can't provide a compiling code, but a few fragments. I have a JLabel [] array. i want to move with the mouse elements of this array. Let's say i want to move JLabel[i]. I implemented this:
Java Code:
static int labelY; static Point labelX; static Boolean flag = false; jLabel[i].addMouseListener(new MouseAdapter(){ public void mousePressed(MouseEvent evt){ labelY=evt.getY();
[Code]...
I used the bool flag because i can't make changes to the label when it is inside an anonymous class. I also tried using setLocation but that did not work also. I don't get any errors when compiling. But when i run it and try to drag the JLabel[i] i get a long list of errors:
Java Code:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at puzzle.hw$1$2.mouseDragged(hw.java:276) at java.awt.Component.processMouseMotionEvent(Unknown Source) at javax.swing.JComponent.processMouseMotionEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source)
I read many posts online and watched tutorials on YouTube. I can't seem to get this work. Notice I am not using any drawing/graphics capabilities - I'd like to keep it this way as we have not gotten that far yet in my studies.The image is in a source folder titled Images under/in my project.
Java Code:
private JPanel jpImage = new JPanel(); private JLabel lblImage; private ImageIcon image; private Image img; // All those above defined prior to method // Within method (relevant to code above) ...
I am trying to make movingLabel move to a different JPanel each time the JButton is clicked. I can see that the random integer is changing each time the button is clicked, but the movingLabel wasn't doing anything. I noticed that if I click the button and then resize the JFrame with my mouse, it shows in the correct panel. Is there something I am missing, or is there a way to make it automatically display in the correct panel without having to manually resize the JFrame each time? I was thinking that I could add something that resizes the window slightly each time the button is clicked to show it, but I don't think that is probably the "right" way to do it.
import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.Random; public class JMovingFrame extends JFrame implements ActionListener
I have a JPanel that's using a simple GridBagLayout.
JPanel panel = new JPanel(); GridBagLayout qPanelLayout = new GridBagLayout(); qPanelLayout.columnWidths = new int[] { 0 }; qPanelLayout.rowHeights = new int[] { 0 }; qPanelLayout.columnWeights = new double[] { Double.MIN_VALUE }; qPanelLayout.rowWeights = new double[] { 0.0 }; panel.setLayout(qPanelLayout); componentCount = 0;
Based on user input I am adding sub-panels to the panel. These sub-panels may vary in height. They take up the full width of the Panel.
public void add(Component comp) { GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(2,2,2,2); gbc.gridx = 0; gbc.gridy = componentCount++; panel.add(comp, gbc_questionPane1); }
The odd behaviour I'm seeing is that if the height of the new sub-panel I'm adding is less than the height of the largest sub-panel currently displayed then the main panel does not repaint. If its height is equal or greater then the Panel does repaint, and any sub-panels that were added but not visible before are now painted. What have I missed?
I'm trying to open an image within a JFrame but the image doesn't show. The directory path is correct. The JFrame opens perfectly but no image is showing.
JFrame frame = new JFrame("IMAGE"); frame.setSize(500,500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ImageIcon image = new ImageIcon("images/main.jpg"); JLabel label = new JLabel("", image, JLabel.CENTER); JPanel panel = new JPanel(new BorderLayout()); panel.add( label, BorderLayout.CENTER ); frame.setVisible(true);
i have very critical problem in my collage project i have try many code but still i cant solve this problem, i want to display image on jlabel or jpanel with respect of components size without use of drawimage method
I'm working on an applet for my class. I decided to use AWT even though it's really old.
I'm having trouble with the labels on my program. They don't show up until I click another tab in the browser and then go back to it each time after I click on a button. I tried to use repaint() but it doesn't seem to work. What can I do?
I want my program to show 1st panel and when a person press image label 2nd panel showup which will have 2 tabs "oneway" and "round trip". But rightnow I only see 2nd panel with only 1 tab and don't see 1st panel at all.
class A { List<StringBuilder> list; public void output(List<StringBuilder> objectToOutput){ try(BufferedWriter bw = new BufferedWriter(new FileWriter("temp.txt"))){ for(StringBuilder row:objectToOutput) bw.write(row.toString()); }catch(IOException e){}
[code]....
Why don't the a's show up on the console? I put them in as part of the debugging process and now I don't understand why they don't show up in both places.
I am making a game in java and i want to make a title screen. What I am trying to do is make a jpanel and load another jpanel when a button is pressed in one of the japenls. Here is the code for the runner
import java.awt.BorderLayout; import javax.swing.JFrame; public class Runner extends JFrame { // Have these set up so they can be seen everywhere public static final int GAMEWIDTH = 540; public static final int GAMEHEIGHT = 710; static boolean loading = false;
[Code] ....
here is the code for the jpanel that loads the other jpanel
I have a Main() class that extends JPanel and I'm trying to add Card() that also extends JPanel.When I add a Card() or Main() object to the JFrame directly, it works fine. The problem arises when I try to add a Card() object to the Main() object.
I edited the code a little bit to make it easier to read so hopefully it's fine.
Main() code: public class Main extends JPanel implements Runnable { // HARDCODED OPTIONS public static final int WIN_WIDTH = 1200; public static final int WIN_HEIGHT = 800;
public static final int GRID_X = 9; public static final int GRID_Y = 5;
I am creating a .jar for a game I made. I'm not using any dev tools, just a DOS console call to java: %~dp0....javajdkinjar.exe -cfmv TheSwarm.jar manifest.txt *
My manifext.txt contains:
Main-Class: Game
But when I compile the jar, its manifest contains:
And I get an error about it not finding the main class. Shouldn't my Main-Class setting be added to the jar? I can manually rename it to .zip and edit the Manifest.MF but that is a huge pain when I'm testing the .jar file and regenerating it often.
I have the following code. how can items be added to that list?
private List<IComponentNode> comp; interface IAAAView { // returns component with given code or null IComponentNode findComp(String a); // returns component with given renderer or null
I am trying to create a form where my customer can add some other fields(like: label,textbox), and he need to use that added fields for the next time he open the application...
I would like to know whether it is possible to save dynamically created controls and reuse it again...
I have a ace:dataTable which contains a variable number of columns. For this I use the c:forEach tag. All generated in the c:forEach are not displayed. In the sample, only columnLibelle and columnSum are displayed.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
I'm just a java beginner. I've spent a lot of time installing and configuring software. I'm using Netbeans 7.3 on Windows 7, 64 bit. Recently, I downloaded opencsv from sourceforge.
With no previous experience adding libraries, I read a blog post on adding the library. I think that I then:
Start a new project.
Right click on libraries
Add jar/folder
Gave the temporary path to the .jar file
After, I read the blog post again, and realized I'd missed it. This time I did:
Right click library, Add library, Create library
However, I kept getting a message that the same library already existed. If I do the first process above, I will find the same library.
However, I see no way in Netbeans to remove it. I've deleted the test projects. And started a new one. But the library now exists for all projects it seems.
I've grepped all the files under the Netbean directory, searching for "opencsv", but found nothing. The only things in the Windows registry were locations of files.
How can I delete this library permanently from Netbeans? Short of, uninstall, then reinstall? Is there a way to list all the libraries that Netbeans has?
Here is my full program, you can find these lines of code on lines 64 and 70.
Java Code:
import java.util.Scanner; public class StockTransaction { public static void main(String[] args) { // TODO Auto-generated method stub //Variable Declaration Section
My panel named panelIncomeInfo are not showing the components that I have added.
public class PayrollGUI { private JPanel panelIncomeInfo = new JPanel (); private JPanel panel = new JPanel (); private JPanel panelPayCheckInfo = new JPanel (); private JButton close = new JButton ("Close");
The following alert returns an added string instead of adding the var together to give me a total?
var tvHours = prompt('How many hours of Tv do you watch last week?'); var webHours = prompt('How many hours of internet surfing did you do last week?'); var gameHours = prompt('How many hours of video games did you play last week?'); alert(tvHours + webHours + gameHours);
Also can you store a var in an alert? e.g ( var time = alert(tvHours + webHours + gameHours); ???
I have a .jar that is installed in other computer(outside netbeans). Everything works fine except with report. I am sure the libraries needed for iReport is added in my lib folder but I receive this error message when I to load the report using the program.I use command prompt to see the error:
Java Code:
java -jar projCosting.jar mh_sh_highlight_all('java'); And here is the error message: Java Code: net.sf.jasperreports.engine.JRException: Error compiling report java source files : [b]D:CostingRptCosting_1288072391310_955208.java[/b] at net.sf.jasperreports.engine.design.JRJavacCompiler.compileClasses
[code]....
I have included the library in lib folder but do you think I have to install the iReport application?