i 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
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.
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 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()); }
I was working on this project, and I have everything working, except that it doesn't change the colors of the shapes in the other window. Here's the code to see what I'm doing wrong:
Java Code:
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class JDemo { //Global Variables static Color color0 = Color.blue; //sets the value in the color0 variable to the method Color.blue . static Color color1 = Color.red; //Sets the value in the color1 variable to the method Color.red .
[Code] ....
The button0 is supposed to switch the color in window1, and button1 is supposed to switch the color in window0.
I have noticed a strange behavior of Combobox element. The number of visible rows is not the same established by setVisibleRowCount() method. It happens when changing the items list dynamically. The following example reproduces it. I think it is Javafx 8 bug. I have tried unsuccessfully to trigger some event indirectly to refresh the combobox drop down.
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ComboBox; import javafx.scene.layout.HBox; import javafx.stage.Stage; public class TestComboBox extends Application { private int count;
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;
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?
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);
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)
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.
What 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.
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);
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.
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
why am I not getting a proper shape of "Leftarrow"? The result should look like the following (the system draws the arrow abnormally, so the beginning should a real ARROW:
*
* *
* *
* * * * * * * * *
* *
* *
*
here is the class:
Java Code: public class LeftArrow extends ShapeBase { private int lengthOfTail; private int widthOfArrowHead;
class shape{ public static void main(String [] args){ for(int x =0 ; x<=6;x++){ for(int y =0 ; x > y ; y++){ System.out.print(x); } System.out.print(" "); } } }
I'm making a program that prints arrows of varying tail length, head width, and displacement.The shape algorithms are working properly, but the displacement isn't working. The first arrow has zero displacement, and the second one is supposed to be bigger and start the print at 10 spaces right and 5 spaces down from the default, but it's not working. I tried changing the displacement settings of the first arrow, and no changes happened, so I know that the positions aren't registering properly in general. How to pass the xAdj and yAdj (displacement) values? I think I have the empty space formula set up, but it's still not running.
Driver: public class Driver { //default values public static final int Arrow_Default_xAdj = 0; public static final int Arrow_Default_yAdj = 0; public static final int Arrow_Default_tail = 5; public static final int Arrow_Default_width = 5;