In carrying out my little game I made a panel "Winner" in which I have two JButton plus I would like to add a blinking text to indicate the victory of the player("You win!"). Currently this text is static, designed by the function drawImage. How can I make it "flashing" maybe alternating the vision of the text (which I present in two different colors)?
I have a program that reads lines of text, but some of the lines of text aren't applicable and break the program. I'd like to put a letter in front of the lines in the .txt file I want to use, such as a #.
I need to make an if loop that'll check for the first letter on the line being #, and use the line in the program if true and skip if false. I'm guessing a boolean variable would be useful here to be true or false depending on the presence of #, but I don't know how to only read the first letter of each line, how can I do this?
I am currently in the progress of making a GUI for a project. I am trying to make a maze and I need it displayed in a GUI. So, I thought I would be able to do that with a text file that I created. The code I have for it so far runs and compiles but it is not displaying my text file as a GUI, even though it reads the file. All I get are a bunch of green rectangles. I am using Netbeans to code this
package rectangles; import java.awt.Color; import java.awt.Graphics;//this will draw the maze import java.awt.Graphics2D;// import java.io.BufferedReader; import java.io.FileNotFoundException;//handles file
There is no error shown in the code. but, when i run my program for start, the page before cannot proceed and yet, i cannot proceed to this page and the application stop unexpectedly. below is the error that i gain in logcat.
11-22 06:59:57.664: D/dalvikvm(290): GC_EXPLICIT freed 1505 objects / 106560 bytes in 184ms 11-22 07:00:39.174: D/dalvikvm(320): GC_FOR_MALLOC freed 2489 objects / 160496 bytes in 109ms 11-22 07:00:39.534: E/MENU PAKEJ A(320): Total Price: RM 0.0 11-22 07:00:39.544: D/AndroidRuntime(320): Shutting down VM
i can't make the [JfileChooser] save text file instead of opening files.that [ComboBox] always don't show me the items that i have inserted in eclipse.
I am working on a game project. Whenever we are starting our game application in production, it works perfectly around 3 days after 3 days, CPU utilization is increasing upto around 95% to 99% and application stops to respond. Before 6 days, I started application again and we doubled our Perm Gen memory size. The same problem happened but it happened after 6 days.
Now, i am not able to relate CUP utilization to Perm Gen memory. Is Perm Gen memory effect CPU utilization?
for (int w=0;w<bi.getWidth();w++) { for (int h=0;h<bi.getHeight();h++) { int color = bi.getRGB(w, h); color = color << 5; bi.setRGB(w, h, color); } }
I am using a solid green image so
11111111000000001111111100000000
I just wanted to see how it looked so bumped it over 5 places (obviously changing the color). To my surprise, there was no added transparency. I mean moving it to the left would make the alpha:
11100000
I am thinking that setRGB() doesn't effect alpha. Is this accurate?Tested it and in fact setRGB has no effect on the alpha bits. So now the question is how can I gain access to them. I am going to look into the writable Raster API. Perhaps, I can also use a modified awt to access directly OS data.
I have one jsp page in which I have listed some service records fetched from Database. I have made one of the column, for eg. Service ID to be link, which should display all the details of that service when clicked. I want those details to be displayed in lightbox. I tried doing it but when any service ID link is clicked, it displays same(First Service in record) service details.How do I pass reference of that current service to lighbox effect.
This isn't solely related to java.awt.Color, it's more of a question on how to store methods or redirections to use methods on any value passed in. To explain my question I'll describe a scenario:
ClassA is an instanstiatable class
ClassA has an instance of ClassB called cB
ClassA has methods of affecting cB
ClassD is also an instanstiatable class
ClassD has an Array[x][y] of instances of ClassA
I want to create a ClassE which I would initiate it with references to ClassA's methods or their actual methods and then I can use ClassE to easily transform ClassD's instances of ClassA by the same methods.
What I'm actually doing:
I made a class called GameColor, it has methods like changeHue, setRed, setHue, changeBrightness, setSaturation etc, these methods affect an instance of java.awt.Color in the GameColor class instances, so like they can change the hue or set it with changeHue or setHue etc...
Now I want to do something like perform a single method on a whole BufferedImage, on each of it's pixels RGB. So, I'm thinking of creating a GameColorEffects class which I store references or actual methods of GameColor like changeHue, and then I use GameColorEffects somehow to change a whole BufferedImage more efficiently, what's the most efficient way I can store methods or their reference of GameColor and then later apply them on each pixel of a BufferedImage using GameColorEffects. So all I do is initiate GameColorEffects with methods or reference from GameColor, and then I can apply it to easily transform each pixel.
I have a UI widget, like a table view for example, displaying real-time data. This table can be configured - so it has many properties. The way I would like to do so, is to have a small 'configure button', once clicked, would rotate the entire table along its y axis, and display another panel with checkboxes etc... So effectively, the hidden properties panel is revealed by rotation.
I am trying to understand the effect of calling real business logic from the test class. If I have a test class that call the service method which make update to DB. Is DB really changes through test class?
e.g.
Java Code: @Test public void testUpdate() { MyDto myDto = new MyDto(paramters to create new myDto object); //creating new dto object myService.updateMyData(myDto); //passing new dto object for update (DB record really changed??) MyDto testDto = myRepo.find(myDto.getKey()); //get record for the corresponding key assert testDto.getSomeProp() == myDto.getSomeProp(); //what testDto.getSomeProp() return? new value send on myDto or old value from DB? } mh_sh_highlight_all('java');
This is the code that I wrote but I have two problem with two buttons one of them ... I want to delete the selected text inside the text Area which represented as b[8] and the other button that I want to select parts of the texts which represented as b[0]....
01. pickup the selected text file and read the line by line and output the text in to visual text pane.
what i did:.
01. I wrote code that read the text file and output in to jave console/ also some of the interface.
the code read txt file:
Java Code:
String fileName = "C:/Users/lakshan/Desktop/lawyer.txt"; File textFile = new File(fileName); Scanner in = new Scanner (textFile); while(in.hasNextLine()){
[code]....
so it will read any text file dynamically and output to the text pane in interface. I think scanner code must be execute after the select the file from the browser and set the scanned result in to variable. then later out put the var as string in some jswing component?
We are making a tic tac toe game for my CS120 class and I am having trouble figuring out how to make our X's and O's. Is there a way to make shapes besides making two lines for an X and an oval with a white smaller oval inside to make an O? We have only learned the basics so far in class (i.e. events, inheritance, client-supplier, etc.)
These are our instructions:
Write a controller that controls the game. There is one human player (the X player) and the computer player (the O player). The name of the class must be TicTacToeController. In a sense, the controller is the game since the controller will 1) create a TicTacToeModel 2) create a TicTacToeView and 3) create a TicTacToeButton (you must write this class following the design pattern covered in class lectures), a label, and text field such that when the button is pushed, the player moves into the cell selected by the text field. After every player move, the computer moves into a randomly selected empty cell. When the game is over, a text message must be displayed somewhere on the screen the gives the status of the game. While you are free to change the appearance of the controller, the basic elements must be provided (a view of the game, a button, and a text field to enter the cell). A sample screenshot is displayed below.And this is the code i have thus far:
[import java.awt.*; import javax.swing.JFrame; public class TicTacToeView extends Rectangle public TicTacToeView(int x, int y, int w, int h) { super(50,60,w,h); this.setBackground(Color.red); JFrame win = new JFrame("Tic Tac Toe"); win.setBounds(10,10,w+100, h+100); win.setLayout(null); win.setVisible(true); win.setBackground(Color.gray);
I'm supposed to write a GUI application letting the user enter a file on the text field and display its hex representation in a text area and vice versa.
Here's my code:
/* * 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 hexconvertor; import java.util.*; import java.io.*; public class HexConvertor extends javax.swing.JFrame {
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?
Write a program that reads in a line of text and then outputs that line of text first in all uppercase letters and then in all lowercase letters.
INPUT and PROMPTS. The program prompts for a line of text as follows: "Enter the text: " and then reads in an entire line of text as a String .
OUTPUT . There are four lines of output . The first line is "The text in all upper case is: ". The second line is the line that was read in, displayed in all uppercase. The third line is "The text in all lower case is: " and the fourth line is the original line that was read in, displayed in all lowercase.
CLASS NAMES. Your program class should be called ShoutAndWhisper.
This is what I have so far:
import java.util.Scanner; public class ShoutAndWhisper { public static void main(String[] args) { Scanner scannerObject = new Scanner (System.in); System.out.println("Enter the text: "); scannerObject.next(); System.out.println("The text in all upper case is: ");
I'm using JBoss 7.1.1.Final. I'm writing a Spring 3.1.1.RELEASE web application and have a massive amount (~5MB) of text output to send to the browser. I would like the browser to display the output as it is generated, but right now, the browser only displays everything after the servlet's doGet method completes. Here's my method …
I am working on a personal project and want to create a text editor to write my code. I am wondering how could I read the last input from the user and if say it was an open curly brace {, then like netbean's my editor will supply the closing curly brace. My java experience is limited but I have tried to read key board input and a few other options that did not work.
I'm working on a simple text editor, and I'm currently saving the contents of my JTextPane in a file using an HTMLEditorKit (text is a JTextPane):
private void save() throws IOException { int returnVal = fc.showSaveDialog(window); if (returnVal == JFileChooser.APPROVE_OPTION) { StyledDocument doc = (StyledDocument)text.getDocument(); HTMLEditorKit kit = new HTMLEditorKit(); BufferedOutputStream out;
[Code] ....
The problem I'm having is that after opening a file that I saved, it does not display (if I disable text/html, it displays the entire html code, but when I re-enable it, nothing displays at all.) Am I loading it wrong, or am I setting the JTextPane's text incorrectly? Or is it, perhaps, another error that I didn't catch?
I am trying to read a text file into Java and split the text into tokens. Eventually I want to be able to count the number of instances of a specific word. However, at this point, when I run the file, all I get is the location of the file rather than the text in the file.
import java.util.*; import java.io.*; public class textTest3 { /** * Prints the number of words in a given file * * @param args * @throws IOException */
I am building a chat server/client and would like to have it so when a user sends a message, the message pops up in the main chat area beside their name, which I would like to be in bold font. Something like "Alan: Hello, how are you?". I can't find a way to do this with a text area or on a string. Do any swing components suitable for use as text areas support bolding of certain sections of the string that you will set to it?