NetBeans IDE - Setting Background Color
Sep 28, 2013In NetBeans IDE >> Palette Window >> JFrame properties, I set the background color to (for example) blue but when I run with F6 key, the appearing window is always at gray color. Why?
View RepliesIn NetBeans IDE >> Palette Window >> JFrame properties, I set the background color to (for example) blue but when I run with F6 key, the appearing window is always at gray color. Why?
View RepliesNo problem setting background color for layouts, e.g. bdrPn.setBackground(new Background((new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY))));
But neither of the following are working for me, running JavaFX 8 on latest OS-X
scene = new Scene(bdrPn, winW, winH, Color.BLACK);
scene.setFill(Color.BLACK);
scene.setFill() worked fine for previous versions of JavaFX.
I've just started working on a program and i'm already having difficulties with the program. I can't get the background color to change from the basic gray color. Maybe you can tell me what i'm doing wrong.
import javax.swing.JFrame;
import javax.swing.WindowConstants;
import java.awt.*;
import java.lang.Object;
import java.awt.Color;
public class FrameDemo{
public static void main(String args[]){
Toolkit toolkit = Toolkit.getDefaultToolkit ();
[Code]...
also if theres any way to shorten up what I have there, that would be great.
My program's tree:
JFrame{
JPanel(That MenuBar at the top)
JPanel(That panel at center with table){
JScrollPane{
JTable
}
}
}
I want to add my custom image to that grey space right there. I guess it is a JScrollPane, because I added that orange background on JPanel that contains it. But when I add this code to my custom class of JScrollPane:
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if(background == null){
background = new ImageIcon(ClassLoader.getSystemResource("tableBg.png")).getImage();
}
g.drawImage(background, 0, 0, null);
}
The result is the same, no changes.
Then I read some documentation. I found this method:
scrollPane.getViewport().setBackground(Color c);
It works, but it accepts only color and I want to add image. Is there any way to do that? Do I need to subclass JViewport and use paintComponent ? If yes, then how to make getViewport() method return my custom subclassed version?
This is my code and it works! But how/where do I set a background image for it to appear as the background of my calculator? The code I have for it is this -
window.setContentPane(new JLabel(new ImageIcon("C:UsersComputerDownloadschristm as1.jpg")));
My code is below.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* Program using SWING components to create a Christmas themed Calculator.
*/
public class ChristmasCalculator implements ActionListener
[code]....
I want to set a background image in Java but nothing is working...
Java Code:
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.FlowLayout;
class Background extends JPanel{
[Code] ....
Everything works fine except the picture, it's not showing. The b.png file is in the folder where the java file is. What should I do?
I want to set different colors for different columns in the table. I use JLabel for setting the background color. Here is the code
private Color colorGreen= new Color( 44, 222, 74);
private Color colorYellow= new Color(255, 255, 0);
..
...
...
if(column == 0)
setBorder(new EmptyBorder(1, 1, 1, 0));
[Code] .....
But the color of the columns stays white, doesn't change.
the program runs fine with exception of color background change.. dont laugh at code.
package chapter7;
import java.awt.*;
import java.awt.event.*;
[Code].....
I would like to change the color of the rows of my TableView. But the instruction setTextFill doesn't work. Is it normal ?
tableView.setRowFactory(new Callback<TableView<Person>, TableRow<Person>>() {
@Override
public TableRow<Person> call(TableView<Person> param) {
final TableRow<Person> row = new TableRow<Person>() {
@Override
protected void updateItem(Person person, boolean empty) {
super.updateItem(person, empty);
setTextFill(Color.RED);
}
};
return row;
}
});
I have a Jpanel with JButtons on the panel is it possible to change the background color of the pannel but leave the JButtons thr default color
View Replies View RelatedI'm using eclipse to run my java program.
I want to be able to change the background color of the console when the user types in a particular command..
e.g User types: color blue
Then the background color of the console should turn blue
Is this possible and how would I go about doing it?
I've just started working on a program and I'm already having difficulties with the program. I can't get the background color to change from the basic gray color.
Java Code:
import javax.swing.JFrame;
import javax.swing.WindowConstants;
import java.awt.*;
import java.lang.Object;
import java.awt.Color;
public class FrameDemo{
[Code] .....
I am trying to go about making this applet a bit different then normal. The issue I am having is it is drawing an applet but, not the right dimensions, it's able to be resized, lastly the background color is not being set. I mean, I suppose I could call paint() and just draw it out but, I read that I could make the applet pop out to the dimensions I would like. None of this is working sadly.
package com.powder.game;
import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.util.*;
import java.io.IOException;
import java.lang.Math;
[code]...
my exact question is can I rewrite the applet to make a pop out window and should I just call paint()?
how can we set the background colour of jframe in java
View Replies View RelatedProgram is not working. I want to use buttonPanel object in ColorAction class and the process is unknown to me .
package button;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ButtonFrame extends JFrame
{
public JPanel buttonPanel;
[Code]...
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 Relatedwhen i set a certain menuitem background color, the highlight is losed. What should i do?
View Replies View RelatedI'm displaying a table with several read-only pieces of data, and a checkbox field that toggles the row color. The background color for the checkbox is not toggling correctly. I put together a SSCCE:
import java.awt.Color;
import java.awt.Component;
import java.util.ArrayList;
import java.util.List;
[code]....
If I comment out the Nimbus look and feel, it works as expected. I googled this problem and found one possible solution on Stack Overflow. Their suggestion is:It's a bug in the synth-installed renderer, quick hack is to force the rendering checkbox opacity to true: ((JComponent) table. get Default Renderer(Boolean.class)).setOpaque(true);
I tried using this line and setting the opacity to true, but it renders the background white. I'm using Java 1.7.0_25.
No matter what I did, and searching for every piece of setBackground, The background color of the JTabbedPane is light blue.
public final class MainFrame extends javax.swing.JFrame implements Runnable, WindowListener,
WindowFocusListener,
WindowStateListener {
Container mainPanel;
JPanel bluePanel = new JPanel();
CloseButtonTabbedPane tabbedPane;
[Code] ....
I'm new in Java. I try to create a menu with items like "Font size", "Font color" type of "font" how to create a menu with that options.
Java.jpg
If I want to read from file the word "red" And then the following is not the right way like in the code ,, How to set the Color name
File inputFile = new File ("C:\input.txt");
Scanner scan = new Scanner (inputFile);
String RedColor=scan.nextLine();
Color backColor = new Color(redColor);
I am trying to align the core/middle side color of a cube, index 4, with the bottom middle color of the same side, index 7. (Each side has values 0-8 where 0 - is the top left corner, 1 is the top mid corner, 2 is the top right corner, 3 is the middle left corner, etc).
In addition to lining up those two colors, I am also making sure that the neighbor color of index 7(the color that it is attached), in this case the bottom color, matches with the top core/middle color. I will attach some pictures and a print out to show what I am talking about...
However, in my code when I am trying to align all of these up together, it does not go into the while loop. Each of the loops essentially is trying to get a match of same color with index 4 and 7, as well as making sure that index 7's neighbor color (the bottom color, in this case) matches with the top color.
Here is what I have tried:
private void alignSideColor(){//make the bottom colors neighbor match with a middle side value and rotate it to the top, for the top cross
if(cube.bottom.square[1].charAt(0) == topColor){
while(cube.front.square[7].charAt(0) != frontColor && cube.bottom.square[1].charAt(0) != topColor){
rotateBottomClockwise(1);
System.out.println("Trying to align side color...");
[Code] .....
The print out of the ELSE IF is:
alignment is: W-G and tops: R-R
NOW ITS ALIGNED
even though the sides, index 4 and 7, are NOT aligned with each other
I have also tried the same thing but with out the 2nd condition in each while loop, and although is DOES enter the while loop, it does not perform correctly -- index 4 and 7 WILL have matches colors, but it does not check to see if index 7's neighbor matches with the top color.
Here is how it prints out
** ** ** G7 B6 Y1 ** ** **//this portion is the back of the cube
** ** ** R6 W5 O4 ** ** **
** ** ** R3 W2 O1 ** ** **
B3 G4 Y9 W9 O8 Y7 W3 B4 G9//this portion is the left, top, and right of the cube
B2 G5 R8 W4 R5 Y6 O2 B5 G8
O7 W8 R9 B7 B8 B9 R1 R4 R7
** ** ** O3 O6 O9 ** ** **//this portion is the front of the cube
** ** ** Y2 Y5 Y8 ** ** **
** ** ** B1 G6 W7 ** ** **
** ** ** Y3 Y4 G1 ** ** **//this portion is the bottom the cube
** ** ** R2 O5 G2 ** ** **
** ** ** W1 W6 G3 ** ** **
Here is the cube showing the top, left and front side
Here is the left and bottom side. As you can see index 4, G5 -- yes that is a 5 lol -- does not have the same color as index 7, W8.
I need to rotate the bottom until W8 is aligned with a middle white value. An examples of a neighbor is: W8-R2
I have been learning java and studying Swing but now i have a problem, i want to set x and y coordinates for this
Java Code:
JLabel jlbWorld = new JLabel("You have spawned"); mh_sh_highlight_all('java');
But how (I have searched internet for answers but all of them have JPanel)
Here are two codes that I am using but I have one that just doesn't work for some reason and the other does. Encode doesn't work. I don't need the Character.isAlphabetic for encode but not sure what I can use with 'if' to set the String encodedString.
Java Code:
private String prepareString(String plainText)
{
String preparedString = "";
for(int i = 0 ; i < plainText.length();i++)
if(Character.isAlphabetic(plainText.charAt(i)))
{
preparedString = preparedString+Character.toUpperCase(plainText.charAt(i));
[code]....
I have been playing around with a snippet I wrote to get the Label on a drive (below). It works fine for me (though I will take any constructive criticism). My question is whether the is a way to set the drive label, purely with Java. I know I could call command line, or even resort to using the Windows API
import java.util.List;
import java.io.File;
import java.util.Arrays;
[Code]....
I'm using a jSpinner Number model:
Here's my code:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int qty2, total, payment, change;
String title;
[code]....
I tried using this since the jSpinner's minimum value is 1.. (I want it to reset the jSpinner after updating the database):
jSpinner1.setValue(new Integer(1));
But gives me an error:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Vector.elementData(Vector.java:730)
at java.util.Vector.elementAt(Vector.java:473)
at javax.swing.table.DefaultTableModel.getValueAt(DefaultTableModel.java:649)
at shop.jSpinner1StateChanged(shop.java:267)
at shop.access$100(shop.java:22)
at shop$3.stateChanged(shop.java:145)
at javax.swing.JSpinner.fireStateChanged(JSpinner.java:457)