I would like to implement a custom Logging strategy for my Java project.I have implemented 3 appenders : one console-log, one file-log (errors only) and another (custom) file-log (with the custom parameters).The custom parameters are : loggerName, logPathDir, logFileLevel and layoutPattern.
I have not managed yet to implement a custom layoutPattern strategy for the custom file-log.When I launch my tests : test1 (default logging setting) and test2 (custom logging setting), I have only managed to get a sucessfull status if I switch the custom layoutPattern strategy to the default one for the test2. My implementation extract :
Im trying to create a checkerboard pattern with 2 nested for loops . I need to output asterisk characters. Im supposed o use an n int so I dont know if im limited to that 1 int. Im only getting 1 line of asterisk.
* * * * * * * * * * * * * * * * * * * * package checkerboard; public class Checkerboard { public static void main(String[] args) { for (int row = 1; row < 6; row++){ System.out.print("* "); for (int col = 6; col < col; col++) {
I would like to create a custom tag which works similar to <c:forEach/> tag i.e
<c:forEach var = "movie" items = "${collection}> ${movie} </c:forEach>
I would want to create the similar behaviour(as above) in my own custom Tag.Morever I would like to use the doStartTag() and doEndTag() and doAfterBody() methods while creating custom Tag.
I'm trying to create a table where the Header is a custom object.
The custom object would be something along the lines of
public MyColumnObject { String myLabel; ArrayList dataForDropdowns; int defaultColumnIndex; int modifiedColumnIndex; String tooltip; }
This is simpler then what I want to do, but it's the basic concept. I want the column header to render the myLabel for the visual (at least at first). I want this render to be applied to however many columns I have, which will differ from table to table, but I always want the column header of each column to be of type myColumnObject.
I thought somethinglike this would work, but I'm getting java.lang.ClassCastException: java.lang.String cannot be cast to myColumnObject which makes sense, but I thought that I would be getting back my object.
p.s. I re-labeled all my code from my actual project, so if something looks off, it was probably just the re labeling.
public NewTestTable(MyColumnObjects[] fields) { setModel(new TestObjectTableModel( new Object [][] { }, fields ) { private static final long serialVersionUID = 1L; public boolean isCellEditable(int rowIndex, int columnIndex) {
I am using netbeans 7.2, glassfish 3.1.2, JSF 2.1 and Primefaces 3.2. When I add more than three menu tabs, I get this error ui layout initialization error the center-pane element does not exist the center-pane is a required element. This is my template.xhtml code:
<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui">
I'm making a Pacman look-a-like game, now I'm making the map out of an 2D array (as a grid). I already initialized the 2d array spots with "0" and "1". I managed to do this but now I'm stuck.
I want to use the "0" and "1" to print the map. For example the "0" are grass and the "1" are walls. The map should be printed within a JFrame. And I would like to make the width and height 32x32 pixels.
I searched on the internet and i found a couple of example codes but non of it seems to work properly. This is the code I'm using to make the 2D array and initialize the spots.:
public class Level1 extends javax.swing.JFrame{ final int ROWS = 17; final int COLS = 17; int[][] field = new int[ROWS][COLS]; public Level1() { initComponents(); setLocationRelativeTo(null);
So I'm doing a basic MVC layout for a pretty basic game that I am making in order to understand the whole MVC layout. The game requires the user to move up/down/left/right via JButtons on the GUI. Since I'm using an MVC layout and my buttons are in a different class than the ActionListeners, I was wondering what the best way to add the action listeners are?
Method 1:
View Class ActionListener method: Java Code: public void addMovementListeners(ActionListener u, ActionListener d, ActionListener l, ActionListener r){ moveUp.addActionListener(u); moveDown.addActionListener(d); moveLeft.addActionListener(l); moveRight.addActionListener(r);
[Code] ....
Which method is better? Is there another method that is even better than these two? Trying to get this MVC thing down.
I am making a basic calculator using SWING.I want my JTextField to stretch across the top, above my buttons. All I can seem to get is it be the same size as one of my buttons.
How to implement GridLayout. In my applet, I want to make a grid of 2 rows and 2 columns. In each grid I want to add a Label and a TextField. I want the background to be red.
So my code would be?
import java.awt.*; import java.applet.*; import java.awt.event.*; public class GridLayoutApplet extends Applet implements ActionListener{ // construct components Label fNameLabel = new Label("First Name"); TextField fNameField = new TextField(20);
[Code] .....
I have read about panels and frames but, it is all confusing to me. How can you add a label and a TextField to one square of the grid?
I'm just trying to do a simple JFrame class, with standard menubars, labels, buttons, etc. So far, it looks really bad. The only way I can get it to look somewhat decent is if I pack it, but then the GUI is too thin. When I resize it manually, I can get the correct position by sizing it to something specific, but it obviously changes when resized again, and I don't want to set dimensions, if my users are just going to resize it, and mess it up. I want the labels on the left, textboxes neatly to the right of them, and the button somewhere on the bottom.
I also want to dynamically create a new label, textbox and button when they click on "Write File" from the menu bar - I assume this is just done with action listener, but I have enough problems as it is with formatting my layout, that I don't even want to start on it!
Below is my assignment and as you can see there is lots of empty space and it looks a bit ugly. Im currently using
content.setLayout(new GridLayout(5,1));
as follows:
Welcome Label and four buttons in the top JPanel, "Employee count" and JTextField in the second JPanel, "Employees in System: ", and empty JList in the third JPanel, Delete employee and Edit Employee buttons in the fourth JPanel Exit button in last JPanel.
When I set the size any smaller, the buttons sort of shrink into each other so Im looking for a way to have the panels take up less space? At the moment it seems like each of the panels are set to the same size for some reason, regardless of the content.how can I give the frame less vertical height without ruining the content.
I want to make a calculator program as my first ever program and I've been working on the layout and I think I have it close to where I want it but will probably tweak it in the future after I get it to work. My problem is I'm trying to add a MenuBar to it but it is not showing up. I tried having it all over my code but whereever I put it the MenuBar doesn't show up.
I am able to get Cpu speed using my GetProcessorSpeed method and It returns this output 1796. How can apply this pattern "#.##". I am trying something like this.
Format formatter=new DecimalFormat("#.##"); formatter.format(MainClass.GetProcessorSpeed()); label2.setText(formatter.toString());
I am in an intro programming class and we got assigned a problem for creating a super class with about a dozen sub classes for generating a random word(via WordGetter class) and then comparing that word to a variety of different patterns(like: does the word contain "re"). We were given the super class which looks like this...
public class Pattern { public boolean matches(String text) { return true; } public String toString() { return "(TRUE)";
[code]...
and from this class, we have to write subclasses that override those three methods. I am struggling to understand inheritance and I am not really sure where to even start. Here is the instructions for the first sub class we need to write...
"CONTAINS" SUBCLASS Constructor: The constructor accepts a String named ‘letters’.
Matches: This pattern matches any text that contains at least one occurrence of each ‘letter’. toString: produces the text “(CONTAINS <LETTERS>)” where <LETTERS> is the ‘letters’ string. getLetters(): this method must return letters. equals(Object): careful on this one. Two Contains are equal if they have the same letters (order is not relevant). (Example):
Pattern p = new Contains(“re”); boolean f1 = p.matches(“renew”); // f1 is true boolean f2 = p.matches(“zoo”); // f2 is false String s = p.toString(); // s is “(CONTAINS re)” boolean f3 = p.equals(new Contains(“er”)); // f3 is true.. really..