Syntax Highlighting In Editor?

Jun 11, 2014

Here is the original code I found on StackOverFlow. It highlights some specific words in a JTextPane.

import javax.swing.*;
import java.awt.*;
import javax.swing.text.*; 
public class ColorChangeWhileTyping extends JFrame{
private int findLastNonWordChar (String text, int index) {
while (--index >= 0) {
if (String.valueOf(text.charAt(index)).matches("W")) {

[code]....

I dont know for some reason it doesnt work correctly. The colour goes away after I press Space to write the next word.

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: JTextField Automatically Highlighting Current Values

Mar 10, 2014

I want to have JTextField automatically highlighting the current values for overwriting when the box is selected. Is there a way to do this? It seems like something that might occur in an action listener.

View Replies View Related

JSF :: WYSIWYG Editor In ModalPanel

Mar 25, 2015

I've tried a few different editors, like CKEditor and TinyMCE, but I seem to run into the same problem with every one. The text area seems to be disabled in a modalPanel. Everything looks like it displays properly, but the blinking cursor doesn't show up and you can't enter any text. Below is an example of the a4j:form that I use in the modalPanel with TinyMCE. why I wouldn't be able to enter any text into the editor? Is there a different editor that will work better?

<a4j:form id="commentpanelform">
<htm:table border="0" id="woverify" width="500px">
<htm:tr><htm:td height="20px" valign="top" colspan="2">
<rich:messages styleClass="errorMessage" style="text-align:center;"/>
</htm:td></htm:tr>

[code]....

View Replies View Related

Is There Any Java GUI Editor For Linux

Jul 29, 2014

Not a Java editor with a GUI, but and editor for editing Java GUI's (Graphically (With JFrame, Swing etc) (Kinda like FrontPage for HTML only for Java/Linux. You just add stuff / drag objects around and then optionally review the code after..

View Replies View Related

Editor Does Not Contain A Main Type

Jul 17, 2014

For some reason when I try to run the program it gives me an "editor does not contain a main type" launch error.

/*
* A program that plays and scores a round of the game Poker Dice. In this game, five dice are rolled. The player is allowed to select a number of those five dice to re-roll. The dice are re-rolled and then scored as if they were a poker hand. The following hands MUST be scored in this assignment:
* * High card
* * One Pair
* * Two Pair
* * Three of a Kind
* * Full House
* * Four of a Kind
* * Five of a Kind
* For extra credit, you may also implement:
* * Straight
*/

import java.util.Scanner;
public class Project10 {
public static void main(String[] args) {
Scanner inScanner = new Scanner(System.in);
int[] dice = new int[5];
resetDice(dice);
System.out.print("Your current dice: + dice");

[code]....

View Replies View Related

Creating A Level Editor GUI

Nov 17, 2014

I am working on a game engine with java. I have come to the final stages of the development of this engine now and need a small hand. For this i am using java's built in libary for graphics. and am strugling to create a nice looking GUi with it, What i need:

The class extends the canvas class and adds it to the jframe, i have set the window up as standard and added a menubar, and net the canvas, what I want to do.

For those of you that have used application such as tiled (shown here [URL] .....) what i am wanting to do is create a gui around the canvas similar to this where the parts on the right are resizable up and down and in and out. i was wondering how i would go about incorporating this.

View Replies View Related

PDF Viewer / Zoom / Editor?

Jun 27, 2014

I am starting a project of a little game for my brother and I wanted to know whether a few things were possible using Java (I know the basics and am currently learning more, but I have about a year to complete this so I have time to learn what is needed).What I need to be able to do:Be able to view a PDF as well as zoom in and pan around itBe able to enter/edit text in said PDF fileBe able to hide some of the text in this PDFBe able to do this on several PDFs in one program (They won't be open at the same time)

Is it possible to do this in Java? If so, how? (As in, what things would I need to learn or what would I need to complete it)If it makes my question easier, what it will be is a London Underground Tube Map (Which is a PDF file)where some station names disappear and the player has to guess which station(s) are missing.

View Replies View Related

Swing Document Editor

Mar 19, 2014

I'm want to write a program to design single page documents. It needs the following features.Drag text and place it anywhere on the page, ideal I would like to add a 'snap to grid' optionDraw boxsAdd simple images (logos)

I plan to do it using Swing, but I've not done anything with this since finishing Uni. how to structure this and what swing components will be best suited for this task?

View Replies View Related

Small Text Editor

Jun 23, 2014

I'm having a problem with a small text editor I'm trying to create. I have implemented a panel of labels, containing line numbers, on the left of a scrollable text area. The panel is designed to size such that it fits the larger numbers whenever they appear. It does that very well, actually, until either one of the scrollbars appear. As soon as one does appear, it immediately shrinks in width. The horizontal scrollbar even blocks the view a little, making it impossible to see what you are writing on the very last line.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Main implements KeyListener {
public static JPanel tab = new JPanel(false);
public static JTextArea text = new JTextArea();
public static JScrollPane scroll, reflex;
public static JPanel lines;

[code]...

Explanation of the code: There is a main panel which embodies a text area and another container filled with labels of line numbers.Both the text area and line number panel have scroll panels attached. They are synchronized, in order to scroll at the same time.

The main class contains a static function "position" which generates a GridBagConstraints, created for the convenience of single-line creation of constraints.It also implements the KeyListener interface, and waits for change in the amount of lines inside the text area. Afterwards, it changes the panel of labels accordingly.

View Replies View Related

Swing/AWT/SWT :: SetFont Of JTable Editor

Mar 18, 2015

I am trying to set the font of the editor as the same for the renderer of JTable. I am just a bit confused on how to do this. I don't want any code but maybe a walkthrough on what to do. Here is my abstract table model ....

public class ProductTableModel extends AbstractTableModel {
private ArrayList <Product> prodList = new ArrayList <Product> ();
private String [] columnNames = {"ID", "Description", "Inventory", "Cost", "Order Quantity"};
public ProductTableModel (ArrayList <Product> productList) {
this.prodList = productList;

[Code] .....

View Replies View Related

JSP :: How To Create HTML Editor - Any Built In API For That

Apr 2, 2015

I want to create a jsp where there is a textbox and the user can change font styles (such as bold, italicized, underline, change color, change font style, highlight align a word/s) inside the textbox just like an MS Word. I'm not looking for a system similar to code ranch's posting of message which displays the tag in a textbox...

View Replies View Related

JavaFX 2.0 :: HTML Editor ValueProperty?

Jun 16, 2014

I'm using  [URL] ....., I'm quite surprise of the fact that there isn't a property for the text value. So you can't bind this component to the model.
 
Why in our opinion there isn't a property to bind (as in other components)?

View Replies View Related

Tile Based Map Editor - Organize Layout

Apr 13, 2014

I'm trying to program a tile-based map editor and most of it is going quite smoothly except trying to organize the layout. Originally I was going to use 2 frames, one for the map, and 1 for the tile set, but after reading about frames I learned that that is bad practice and is also inconvenient because there is no way to have both frames in focus at once (so you need to click an extra time to gain focus when switching windows). So what I'd like to do is create a single frame application that holds 3 panels. One for the map, one for the tile set, and one for tile settings. This is basically what it would look like:

Note that the tile settings panel uses GUI elements (a border, a JLabel (which starts out empty), a JComboBox, and a JTextField) while the other 2 panels are just drawing panels*

Now I have tried multiple things which either did not work visually (panels were inside panels) or did not compile. One thing I tried was using BoxLayout to put the 2 tile panels vertically within a temporary panel which I then tried to add into the frame after the map panel (with FlowLayout), but that made it look like this: I honestly don't know what else I did that I should write here because in retrospect many of the tings I tried were silly or I don't remember exactly what I did. What would be the best layout to doing what I want?

View Replies View Related

Vararg Syntax - Using Three Dots Only?

Aug 15, 2014

why we use only three dots(...) in vararg method???

View Replies View Related

Syntax For Array Of Objects

Apr 10, 2014

I know the first line below creates an object but the second line creates an array of cars, I'm just not sure how it does that. I can see sportsCar is one object in the array but the others are written in a different way. It seems there should a couple names there instead. Please explain the syntax in this code that's highlighted. I don't know how to make sense of it and I've read through the book where I got it where it explained creating objects.

Auto sportsCar = new Auto("Ferrari", 0, 0.0);
Auto [] cars = {new auto("BMW", 100, 15.0), sportsCar, new Auto()};

View Replies View Related

If Statement Syntax Error

Dec 13, 2014

This is what i have so far, I use BlueJay to write this:

import javax.swing.JOptionPane;
public class payroll
{
String again = y;
//
private String name;
private double rate;
private double hours;
static double gross; //gross pay

[code]....

my first problem is that it expects a ")" on this line :"if ((hours <=40)rate *1);"For the assignment itself these are the requirements:

-Create a class called payroll with private variables for rate hours and name

-Create static variables for gross pay, union dues, health coverage (hp in my case), FICA taxes, State taxes, Federal taxes, net pay, all must be initialized to 0

-default constructor that assigns default values

a function called calcPay that will do the following tasks and print it to a pay stub :

- function that checks the hours ( if hours are 40 or less pay rate, if over 40 pay 150% of the rate)
- calculates gross pay before any deductions (using user inputted hours and rate)
- deduct medical coverage and union dues from gross pay and call this adjusted gross pay (also this should have its own line on the paystub)
- A function that deducts State, federal and fica taxes from adjusted gross
- FICA - 7% for any income
-Federal - 2% for $0-$150 / 6% for 150.01 - 300 / 14% for 300.01 - 600 / 18% for 600.01 - unlimited
-State - 1% for 0-150/ 3% 150.01 - 300 / 5% 300.01 - 600/ 8% 600.01 - unlimited
- amount after all deductions is the net pay ( show this amount on its own line)
- Start a loop that asks each time if there are more employees (y/n) y should continue the program and n should end it
-dialog boxes should be created to recieve values for name, hours and rate
- if the rate is entered below $8 dollars a new box should pop up and ask for a higher value
- When there are no more employees, print out a summary of quantities stored in static variable (also had a problem with this)
- End

So I think i completed most of these objectives but am having trouble with the syntax and some of the objectives

View Replies View Related

Syntax Error On Token

May 12, 2014

So my only error in the entire code is on the 9th line of this code sample. It says "Syntax Error on token "new", @ expected" but @ does not belong there, as far as I can tell, since the error does not go away upon adding it.

public class Obstapacalypse implements KeyListener, ActionListener {
private static final String EXIT_ON_CLOSE = null;
private JFrame frame;
private Player player = new Player();
private JPanel contentPane;
private JButton btnStart;

[code]....

View Replies View Related

JSF :: Escape Characters Of Primefaces Editor To Do A Query On Sparql

Sep 25, 2014

How do I escape the characters of a primefaces editor?

I have this in form in a xhtml page

<p:editor value="#{managebeanX.valor}" />

but when I try to save this value through a sparql query it says:

virtuoso.jdbc4.VirtuosoException: SQ074: Line 2: SP030: SPARQL compiler, line 2: syntax error at 'Apple' before '-'

Here is the sparql query

INSERT INTO GRAPH <http://localhost:8890/Asst> {

<http://www.dominio.edu#Q1> rdf:type asst:Question; asst:prompt "adada <span class="Apple-tab-span" style="white-space:pre"></span>"^^xsd:string. }

The Blue text is the value of the p:editor. It' has html characters... So I think I need to scape those characters... but how?

View Replies View Related

Swing/AWT/SWT :: Custom JTable Renderer And Cell Editor

Jul 23, 2014

What I'm trying to do is make an inventory type program that includes a jtable. In the Jtable in the last column there will be 2 buttons and a textfield to register the value of additions or subtractions to the overal stock amount. (See screenshot in attachment).

As of now I am able to increment or decrement the numbers when the buttons are clicked on however the problem is that if I add 2 to the first row, and then go to add 2 to the next row or any other row for that matter, the value of the previous row is added to the next row, and the previous row reverts back to a value of 0. So basically its like there is only one editor that keeps track of one value no matter what row you are editing.

I need getting it so that I can add different values to each different row depending on the stock being used or received. The following is my code:

Main class

JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 155, 643, 233);
IMG.add(scrollPane);
center = new centerJustify();
ts = new tableCellRenderer();
tm = new DefaultTableModel(){

[Code] .....

View Replies View Related

Find Whole Syntax Of API Method Online?

Jul 5, 2014

I was trying to find the complete readLine() method In the online docs but all I can get hold of Is:

readLine
public String readLine()
throws IOException

Reads a line of text. A line is considered to be terminated by any one of a line feed

('
'), a carriage return ('
'),

or a carriage return followed immediately by a linefeed.

Returns:A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reachedThrows:IOException - If an I/O error occursSee Also:Files.readAllLines(java.nio.file.Path, java.nio.charset.Charset)

Is It possible to view the actual method syntax online ?

View Replies View Related

Syntax Error When Testing Code

Jun 4, 2014

My issue is that when I run the code if I enter anything but 1, 2, or 3 the code breaks. I have spent hours trying to find the error. here is my code

import java.util.Scanner;
public class Tester {
public static void main(String[] args) {
/**
* constructor
* pre: none
* post: inherit values of other classes
*/
Car Car = new Car(); //inherits the properties of the Car class
Truck Truck = new Truck(); //inherits the properties of the Truck class

[code]....

View Replies View Related

FilterType Cannot Be Resolved - Syntax Error

Mar 9, 2014

I'm not sure why I'm getting these errors. They only begin to happen after the second if statement, and the subsequent if statements are formatted exactly the same.

The errors are marked by the comments in the code.

Java Code:

import java.util.*;
import java.io.*;
public class GazillionSongs {
public static void main(String[] args) throws FileNotFoundException {
System.out.println("Welcome to Java Song Collection!");
System.out
.println("This program sorts and filters large databases of popular songs.");

[Code] .....

View Replies View Related

If-else Statement Not Working - Syntax Error

Sep 14, 2014

My if else statement is not working...it keeps telling me that the else in the statement is a syntax error and that I should remove it. Whats wrong with it?
 
package Homework2;
import java.util.Scanner;
public class Homework2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Welcome to the Triangle Program.");
 
[Code] ....

View Replies View Related

Complex Numbers - Converting Syntax?

Mar 17, 2015

Convert to following sysntax (from Matlab) having complex nos.

real((413000*atan((T^(1/2)*((4130000*V*1i)/(139*T^(1/2)) + (413000*1i)/T^(1/2)))/413000)*1i)/(139*T^(1/2)))

View Replies View Related

GUI Text Editor With Edit And Format Functions - Scroll Pane

Mar 22, 2014

The program below compiles and functions correctly for the most part. It is supposed to be a simple GUI Text Editor with Edit and Format functions. The content pane is supposed to be a scroll pane, however no matter how much I type into the editor, the scroll bar does not appear. Also, the none of the functions under the "Edit" menu work.

Java Code:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.util.StringTokenizer;
import java.util.regex.Pattern;

/**
* A simple text editor. It creates and displays the GUI Text Editor.
*/
public class TextEditor extends JFrame implements ActionListener

[Code] .....

View Replies View Related

JSP :: Assigning Session Variable In Query Syntax

Jan 9, 2015

In my JSP I need to retrieve some data from MySQL. I need to assign a "email" variable to the "WHERE" clause. The variable is retrieved from the session attribute. So far, I have this code:

<sql:query dataSource="${user}" var="result">
SELECT * from users where email = ${sessionScope.email};
</sql:query>

It doesn't work.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved