Component.CENTER not working for Tablelayout (specifically using CODENAMEONE)

I’ve been struggling with this problem for awhile and can’t seem to find an answer. In the demo code on the codename one website, to center an object, the code used is

horizontalAlign(Component.CENTER),

however, when I try to use this in IntelliJ, Component.CENTER isn’t even an option. There IS something called CENTER_ALIGNMENT, but when I input that, I get an error message saying “float” cannot be input into a requirement of “int”. Does anyone know what the code is to center objects in tablelayout in codenameone? I have already checked and updated all my software.

My program keeps crashing on emulator

i’m sorry bad english
Im new to android studio and java
This one maybe basic. but none of the answer from other same questions solve my problem.
it’s says that my main activity and other activity is not an abstrack method and does not override the abstrack method on .OnNavigationItemSelectedListener.
so i found some sollutions that fix the problem by changing those activity to abstrack or implement the method.
but, the program crash and stopped when being initialized on emulator. i cant find any sollution, i’ve read the log cat and can’t figure what’s wrong with my code

any help ?

here is my main activity

package com.example.andik.inibudi;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Gallery;

public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toogle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(toogle);
        toogle.syncState();

        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);

    }

    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.nav_drawer, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public boolean onNavigationsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.gallery) {
            Intent searchIntent = new Intent(MainActivity.this, com.example.andik.inibudi.Gallery.class);
            startActivity(searchIntent);
            overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);
        } else if (id == R.id.fileimport) {
            Intent searchIntent = new Intent(MainActivity.this, FileImport.class);
            startActivity(searchIntent);
            overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);
        } else if (id == R.id.slideshow) {
            Intent searchIntent = new Intent(MainActivity.this, SlideShow.class);
            startActivity(searchIntent);
            overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);
        }
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }


}

and this is my log cat

11-01 05:22:41.367 6008-6008/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 Process: com.example.andik.inibudi, PID: 6008
                                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.andik.inibudi/com.example.andik.inibudi.MainActivity}: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class RelativeLayoutLayout
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
                                                     at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
                                                     at android.os.Handler.dispatchMessage(Handler.java:105)
                                                     at android.os.Looper.loop(Looper.java:164)
                                                     at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
                                                  Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class RelativeLayoutLayout
                                                  Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class RelativeLayoutLayout
                                                  Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.RelativeLayoutLayout" on path: DexPathList[[zip file "/data/app/com.example.andik.inibudi-9Kf2k2xmP7LCW9vSmyH9Lg==/base.apk", zip file "/data/app/com.example.andik.inibudi-9Kf2k2xmP7LCW9vSmyH9Lg==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.andik.inibudi-9Kf2k2xmP7LCW9vSmyH9Lg==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.andik.inibudi-9Kf2k2xmP7LCW9vSmyH9Lg==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.andik.inibudi-9Kf2k2xmP7LCW9vSmyH9Lg==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.andik.inibudi-9Kf2k2xmP7LCW9vSmyH9Lg==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.andik.inibudi-9Kf2k2xmP7LCW9vSmyH9Lg==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.andik.inibudi-9Kf2k2xmP7LCW9vSmyH9Lg==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.andik.inibudi-9Kf2k2xmP7LCW9vSmyH9Lg==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.andik.inibudi-9Kf2k2xmP7LCW9vSmyH9Lg==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.andik.inibudi-9Kf2k2xmP7LCW9vSmyH9Lg==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.andik.inibudi-9Kf2k2xmP7LCW9vSmyH9Lg==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.andik.inibudi-9Kf2k2xmP7LCW9vSmyH9Lg==/lib/x86, /system/lib, /system/vendor/lib]]
                                                     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                     at android.view.LayoutInflater.createView(LayoutInflater.java:606)
                                                     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:703)
                                                     at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68)
                                                     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
                                                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
                                                     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:965)
                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
                                                     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
                                                     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:995)
                                                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
                                                     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                                                     at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
                                                     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)

Can someone show me what the code would look like for this MineSweeper Pr

[1] In this milestone, implement the bodies of the following methods within the MineSweeper class.

This is what I have so far, but I am not sure what to do next?

 public static int placeMines(boolean[][] mines, Random randGen) {
        int a;
        int b;
        int num;
        randGen = new Random();

        for (a = 0; a < map.length - 1; a++) {
            for (b = 0; b < map.length - 1; b++) {
            num = randGen.nextInt(10);
            if (num > )
            }

The following are methods that should be used:

public static int placeMines(boolean[][] mines, Random randGen)
public static int numNearbyMines( boolean [][]mines, int row, int col)
public static void showMines(char[][] map, boolean[][] mines)
public static boolean allSafeLocationsSwept(char[][] map,
boolean[][] mines)
  1. The algorithm for the main method should change to call these new methods.

a. Create one instance of Random that is used for all games. Set the seed to be the SEED
constant found in Config.java for reproducible results which are useful for testing and grading.

b. Create a 2 dimensional boolean array, the same size as the map, that will store whether there is
a mine at each location. A true value at a location indicates that location has a mine.

c. Create a game loop that continues until the player either wins or loses.

i. Output the number of mines in the map

ii. After getting a location to sweep, if there is a mine

  1. Then update the map with SWEPT_MINE.

  2. Call showMines to show all the mines on the map.

  3. Print out the simple map and the “Sorry…” message.

iii. Otherwise, no mine in the location then

  1. Determine how many nearby mines there are.
  2. Display that number as a char in the map.
  3. If allSafeLocationsSwept then show, print out the simple map and the “You Win!”
    message.

log4j2 with two rollingfile appenders not zipping one of them

Using log4j2 version 2.9.1 with the following log4j2.xml on Tomcat 7.0.41.

The config file is specified to the Tomcat service using the -Dlog4j.configurationFile= construct. The two appenders are used by two different webapps that instantiate with:

Logger loggwe = Logger.getLogger("RollingFile 'name' here");

Problem: The “dislog” appender rolls but never zips.

The “applog” appender zips as expected. Other portions of the dislog config, such as the Pattern, are used correctly so each webapp does use its section accordingly. One just won’t zip.

<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="60" status="INFO">
    <Appenders>
        <RollingFile name="dislog" fileName="D:/DocVue/apache-tomcat/webapps/DIS/WEB-INF/logs/dis.log" filePattern="D:/DocVue/apache-tomcat/webapps/DIS/WEB-INF/logs/dis-%d{MM-dd-yy}.%i.log.zip" append="true">
            <PatternLayout>
                <Pattern>D %-5p %d{MM/dd/yyyy HH:mm:ss.SSS} %m [%t]:%C.%M:%L%n</Pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1" modulate="true" />
                <SizeBasedTriggeringPolicy size="10 MB" />
            </Policies>
            <DefaultRolloverStrategy max="9" fileIndex="max">
                <Delete basePath="D:/DocVue/apache-tomcat/webapps/DIS/WEB-INF/logs">
                    <IfAny>
                        <IfLastModified age="30d" />
                        <IfAccumulatedFileSize exceeds="100 MB" />
                    </IfAny>
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>
        <RollingFile name="applog" fileName="D:/DocVue/docvue/WEB-INF/log/docvue.log" filePattern="D:/DocVue/docvue/WEB-INF/log/docvue-%d{MM-dd-yy}.%i.log.zip" append="true">
            <PatternLayout>
                <Pattern>%-5p %d{MM/dd/yyyy HH:mm:ss.SSS} %m [%t]:%C.%M:%L%n</Pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1" modulate="true" />
                <SizeBasedTriggeringPolicy size="10 MB" />
            </Policies>
            <DefaultRolloverStrategy max="9" fileIndex="max">
                <Delete basePath="D:/DocVue/docvue/WEB-INF/log">
                    <IfAny>
                        <IfLastModified age="30d" />
                        <IfAccumulatedFileSize exceeds="100 MB" />
                    </IfAny>
                </Delete>
            </DefaultRolloverStrategy>
        </RollingFile>
        <Console name="console" target="SYSTEM_OUT">
            <PatternLayout pattern="%-5p %d{MM/dd/yyyy HH:mm:ss.SSS} %m [%t]:%C.%M:%L%n" />
        </Console>
    </Appenders>
    <Loggers>
        <Logger name="applog" level="info">
            <AppenderRef ref="applog"/>
        </Logger>
        <Logger name="dislog" level="info">
            <AppenderRef ref="dislog"/>
        </Logger>
        <Root level="info">
            <AppenderRef ref="console"/>
        </Root>
    </Loggers>
</Configuration>

How to find the sum of TreeNode at n depth with a helper function?

So, I’m given these intructions.

/* Takes a depth n and a ReduceFunction f
and returns the “combined value” of all elements in the tree at depth n, where depth=0 is the root. “combined” means the result of
starting with f.initialValue and “concatentation or combination” each
element using f.combine Requirement: must use a loop*/

I have two functions, a main and a helper.
The main function is:

public OutT combineValuesAtDepth(int depth, ReduceFunction<T,OutT> f)

Helper:

 private T combineValuesHelper(int depth, TreeNode<T> node, ReduceFunction<T,T> f, T sum)

Can someone conceptually walk me through the process of this? I’m a newbie in Java so any tips would help thanks.

Components not showing in second JPanel

So, I have this problem where when I add the components to the second JPanel, they are not showing.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

public class TestSeleccionJugadores2 extends JPanel {
 JPanel jpJugador1 = new JPanel();
 JPanel jpJugador2 = new JPanel();

 TitledBorder titledBorder1 = new TitledBorder("Jugador 1");
 TitledBorder titledBorder2 = new TitledBorder("Jugador 2");

 Font font1 = new Font("Microsoft JhengHei UI Light", Font.PLAIN + Font.BOLD, 14);
 Font font2 = new Font("Microsoft JhengHei UI Light", Font.PLAIN, 13);

 JLabel jlJ1 = new JLabel("Es un(a)");
 JLabel jlJ2 = new JLabel("Es un(a)");
 JLabel jlJ1Nombre = new JLabel("llamada(o)");
 JLabel jlJ2Nombre = new JLabel("llamada(o)");

 JComboBox<String> opciones1 = new JComboBox<>(new String[] {"Hombre", "Mujer", "Otro"});
 JComboBox<String> opciones2 = new JComboBox<>(new String[] {"Hombre", "Mujer", "Otro"});

JTextField nombreJ1 = new JTextField("Jugador 1", 5);
JTextField nombreJ2 = new JTextField("Jugador 2", 5);

public TestSeleccionJugadores2() {

 jpJugador1.setLayout(null);
 jpJugador2.setLayout(null);
 setLayout(null);

 jpJugador1.setBounds(10, 25, 200, 100);
 jpJugador2.setBounds(10, 120, 200, 100);
 setBounds(0,0,300, 300);

 titledBorder1.setTitleFont(font1);
 titledBorder2.setTitleFont(font1);

 jpJugador1.setBorder(titledBorder1);
 jpJugador2.setBorder(titledBorder2);

 opciones1.setSelectedItem("Otro");
 opciones2.setSelectedItem("Otro");

 jlJ1.setBounds(10, 30, 80, 20);
 opciones1.setBounds(95, 30, 80, 20);
 jlJ1Nombre.setBounds(10, 55, 80, 20);
 nombreJ1.setBounds(95, 55, 80, 20);

 //These are showing in both JPanels.
 jlJ2.setBounds(10, 125, 80, 20);
 opciones2.setBounds(95, 125, 80, 20);
 jlJ2Nombre.setBounds(10, 155, 80, 20);
 nombreJ2.setBounds(95, 155, 80, 20);

 //Second components.
 jpJugador2.add(jlJ2);
 jpJugador2.add(opciones2);
 jpJugador2.add(jlJ2Nombre);
 jpJugador2.add(nombreJ2);

 jpJugador1.add(jlJ1);
 jpJugador1.add(opciones2);
 jpJugador1.add(jlJ1Nombre);
 jpJugador1.add(nombreJ1);

 add(jpJugador2);
 add(jpJugador1);

}

}

The seconds components are not showing in any JPanel. I have added them to the first JPanel and I’ve got the same problem.
In other class, with the main method, I add the principal JPanel to the frame.