Swing/AWT/SWT :: Change The Blue Color?
Apr 6, 2014When I click a JButton, it will become blue momentarily. Is it possible to change the blue color? If yes, how?
View RepliesWhen I click a JButton, it will become blue momentarily. Is it possible to change the blue color? If yes, how?
View RepliesNo 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] ....
refer to this code~
import java.awt.GridLayout;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.Color;
import javax.swing.JButton;
[Code] ....
Program 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'm dealing with, change the content pane color of jFilechooser. Color has been changed but the problem is when I open the subdirectory leads errors; Note : It also trigger error when I set default directory; like chooser.setCurrentDirectory(file);
The following error is the result:
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at javax.swing.plaf.metal.MetalFileChooserUI$IndentIcon.getIconWidth(MetalFileChooserUI.java:912)
at javax.swing.SwingUtilities.layoutCompoundLabelImpl(SwingUtilities.java:961)
at javax.swing.SwingUtilities.layoutCompoundLabel(SwingUtilities.java:888)
at javax.swing.plaf.basic.BasicLabelUI.layoutCL(BasicLabelUI.java:94)
at javax.swing.plaf.basic.BasicLabelUI.getPreferredSize(BasicLabelUI.java:239)
[Code]...
Following is the code base
import javax.swing.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
[Code]...
I'm working on a spreadsheet-like table and I was able to set it so that it would highlight the first cell in the relevant row(titled 1,2,3.. etc) when a cell is clicked. (Just like in MS Excel - preview attached) Now I want to do the same to the column header(i.e. A,B,C,D....etc) . How can I do it?
private void formWindowOpened(java.awt.event.WindowEvent evt) {
setLocationRelativeTo(null);
int rowNum = sheet.getRowCount();
for(int i=0; i<rowNum; i++){
sheet.setValueAt(i+1, i, 0);
[Code] .....
Untitled.jpg
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.
I'm programming in school using Netbeans and we've just started with graphical programming (i.e JPanel, JClass, JFrame). This is my first assignment and the purpose of this program is that when you press the mouse you will fill 4 circles with diffrent colors. I've managed to draw 4 circles with diffrent colors but I want my cursor to change color simultaneously. Here's my code so far ....
//Java klass "Klick"
public class Klick {
//Medlemsvariabler.
private int x = 0;
private int y = 0;
private int r = 1;
public int antal = Rityta.antalKlick;
[Code]...
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 java a project with java draw golf course and currently working on 2 combo boxes to change shape of the flag on the post and fill color as well on combo box item change. I have below code. as am new to java what to do next.
import java.awt.*;
import java.awt.event.ItemEvent;
import javax.swing.*;
public class GulfCourse extends JPanel{
public void paintComponent( Graphics g){
super.paintComponents(g);
//draw green oval
[Code]...
I'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 am creating a JSP page with a html table to display employee directory. This is scriptlet :
<%
List<Employee> list = new ArrayList<Employee>();
PhoneListController controller = new PhoneListController();
list = controller.getAllContacts();
for (Employee eachEmp : list) {
%>
and then i display the table rows and columns for each employee object(PS: I know scriptlets are bad and obsolete but this is my first individual project.)
I would like to change the background color of certain rows based on value of one particular value(based on eachEmp.getManagerCode).
How can i achieve that by using javascript? I tried to call a js function by calling onload event on . But as I need to check for each row that is not the possible solution. I have not tried jquery yet as I am very new to jquery and I didnt quite understand how to do it in jquery.
I am having problem with the JRadio Buttons to change the font color in my code. What needs to be done? Also if I were to connect this GUI to another GUI and save font colors, how would I go about that?
package SystemandDesign.RISK;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JFrame;
import javax.swing.ButtonGroup;
[code]....
I'm working on a spreadsheet-like table and I was able to set it so that it would highlight the first cell in the relevant row(titled 1,2,3.. etc) when a cell is clicked. (Just like in MS Excel - preview attached) Now I want to do the same to the column header(i.e. A,B,C,D....etc) . How can I do it?
private void formWindowOpened(java.awt.event.WindowEvent evt) {
setLocationRelativeTo(null);
int rowNum = sheet.getRowCount();
for(int i=0; i<rowNum; i++){
sheet.setValueAt(i+1, i, 0);
[Code] ......
is possibile to change the color of the sorting arrow that appears in the columns of the Table View by css? My attempts have failed and I have not found any documentation, nor is there any reference in the Modena css.
View Replies View RelatedWhat I'm trying to do is basically draw a Rectangle outline through left-click and then dragging the mouse to the size one wants.
After one has created this rectangle, the user can change the color of the rectangle through clicking the 3 sliders found on the top in the program. Upon the change in color, the rectangle should change from "g.drawRect" to "g.fillRect" and use the desired color.
I have the basic outline of the program done, but working with the last part (the color and changing of the Rectangle type after changing the color)
Is there like a "then" command in Java? Like: after you've done x, do y. That would make this heaps easier.
import java.awt.event.*;
import java.awt.*;
import java.applet.*;
//Diese Applikation offnet ein Fenster,
//in welchem durch einen gehaltenen linken Mouse Klick
//ein Reckteck gezeichnet wird
public class WhatIsTheProblem006 extends Applet
implements AdjustmentListener {
[Code] ....
The following class is part of a homework assignment:
package event;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import model.Model;
import shapes.Rectangle;
import shapes.Shape;
[Code] .....
I have to implement the methods for what is happening if on some panel the action selected are Remove/Move/Change/Resize (Draw is already implemented).
The Applet in question draws ovals or rectangles on the screen and you can change the fill-color and outline-color of the shape. All this works already. I have dabbled with the move-method, but am not going anywhere.
Color only changes, when resizng frame with mouse, not when clicking.
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class SimpleGui1 implements ActionListener {
JFrame frame;
MyDrawnPanel drawnPanel;
[Code] .....
I'm working on a standalone GUI under Windows using JAVA SWT and eclipse. I have a colour scheme based on six colours inplemented as:
RGB rgb01=new RGB(233, 150, 122);
final Color color01=new Color(Display.getCurrent(),rgb01);
RGB rgb02=new RGB(250, 128, 114);
final Color color02=new Color(Display.getCurrent(),rgb02);
RGB rgb03=new RGB(255, 160, 122);
final Color color03=new Color(Display.getCurrent(),rgb03);
RGB rgb04=new RGB(255, 165, 0);
final Color color04=new Color(Display.getCurrent(),rgb04);
RGB rgb05=new RGB(255, 140, 0);
final Color color05=new Color(Display.getCurrent(),rgb05);
RGB rgb06=new RGB(255, 127, 80);
final Color color06=new Color(Display.getCurrent(),rgb06);
I have 8 sets of six colours prepared. I'd like to let the user choose a colour scheme and even change it while they use the application.
As can be seen the Color s are with final as if they are not the code below gives an error.
if (script_deletion_flag[x]!=null && script_deletion_flag[x]) {
itemDBAB1.setForeground(color04);
}
else
{
itemDBAB1.setForeground(color03);
}
I'm trying to build a program which sets a fill color for a rectangle. Each time the mouse is clicked the fill color changes according to the position of the mouse's X and Y. I succeeded to create a JFrame with a changing background according to the Mouse's position, but I can't seem to change the color of the rectangle (defined in MyPanel class).
This is the current code,
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.SwingUtilities;
import javax.swing.JFrame;
[Code]...
is there a good way to change the color of a JList item that isn't selected? I'm throwing my hand at building a client/server chat app and on the client side, I need to highlight the name of the person (which is in a JList) who has sent a message to the client GUI.
View Replies View RelatedI 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 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.
My code is
Double qty = 0.0;
for ( int i = 0; i < ingTable.getRowCount(); i++){
qty = (Double) ingTable.getValueAt(i,2);
if( qty < 30.0){
ingTable.setBackground(Color.red);
} else {
ingTable.setBackground(Color.white);
}
}
I have a ComboBox I'm using for a cellEditor. The list of items in the comboBox might have colors behind them, which I've managed to render. What I haven't figured out is a good way to keep the color in the cell after the item is selected.I don't' want to have a persistent comboBox in the cell, i only want to see it when editing that cell.
public TableCellEditor getCellEditor(int row, int col)
{
if (row==theRow && col==theCol)
{
JComboBox<?> combo = new JComboBox<Object>(getPickListEntries());
combo.setRenderer(new PickListRenderer(combo));
combo.setBorder(BorderFactory.createEmptyBorder());
}
[code]....
No 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.