|
|
Check the mysql documentation to see if there is another way to specify the file.
|
|
|
|
|
Hello, i'm new to Java and i'm trying to learn the basics. Problem is i want to make this buttons top to bottom, Tried some but kinda confused here. Please help
Here is my code
JPanel mainPannel = new JPanel();
JButton jbt1 = new JButton("Шинээр үүсгэх");
JButton jbt2 = new JButton("Хугацаа сунгах");
JButton jbt3 = new JButton("Данс хаах");
JButton jbt4 = new JButton("Архив");
JButton jbt5 = new JButton("Прогрaмыг хаах");
mainPannel.add(jbt1);
mainPannel.add(jbt2);
mainPannel.add(jbt3);
mainPannel.add(jbt4);
mainPannel.add(jbt5);
mainPannel.setBorder(new TitledBorder("Үндсэн Цэс"));
//Create font and a line border
Font largeFont = new Font("ArialMon", Font.BOLD, 20);
Border lineBorder = new LineBorder(Color.BLACK, 2);
//Add panel to mainFrame
JPanel listPane = new JPanel();
listPane.setLayout(new BoxLayout(listPane, BoxLayout.Y_AXIS));
listPane.add(mainPannel);
modified 4-Apr-16 5:22am.
|
|
|
|
|
You forgot to tell us what the problem is.
|
|
|
|
|
I know how to do a JButton, but the thing is, I don't want that to say Play, Quit, etc.. I want to customise it, like say in Minecraft, where the Singleplayer button is on a stone; or in Papers, please, the button for Story Mode is underlined with dots. You know what I mean.
I've tried searching around the internet, but all they show is the JButton code, not how to customise.
|
|
|
|
|
Already posted in QA
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
not the label fullscreen*
private void formWindowOpened(java.awt.event.WindowEvent evt) {
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension screenSize = tk.getScreenSize();
this.setSize(screenSize);
int Ewidth=tk.getScreenSize().width;
int Eheight=tk.getScreenSize().height;
jLabel1.setBounds(0, 0, Ewidth, Eheight);
jLabel1.setSize(screenSize);
jLabel1.setSize(100, 500);
jLabel1.setPreferredSize(new Dimension(Ewidth, Eheight));
jLabel1.setMaximumSize(new Dimension(100, 500));
}
|
|
|
|
|
How to connecte multiclient (only number port and adress IP) to one server with number client online? who can help me!!plz
|
|
|
|
|
Google for "java sockets", and you will find many samples.
|
|
|
|
|
have you tried to use a Java.net.Socket in a Runnable ?
So you can launch several thread to the same server.
|
|
|
|
|
Write a program that follows a binary tree in
postorder. Binary Tree will read from a file whose
name will be given as command line parameter. result
browsing will be added at the end of the same file
how can i do this in java
|
|
|
|
|
|
Member 12069256 wrote: how can i do this in java I fear you will have to work and learn java too.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
rely my problem just with read tree element from file and write post:order to the same file
|
|
|
|
|
If you follow that link that I gave you you will find samples on all the issues in your question.
|
|
|
|
|
Your homework is set to test what you know, not what a random bunch of people on the Internet know.
Try it yourself, and you'll probably find it's not as difficult as you think.
If you genuinely don't know where to start, then talk to your teacher.
You should also assume that your teacher is monitoring these forums. Even if you managed to persuade someone to do your homework for you, you'd immediately be penalised for cheating.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I want to handle 404 page not found exception in my Spring MVC web app, I'm using SPRING 4.2.5.RELEASE, I had read several question regarding this topic but the similar questions are using a different spring java configuration.
I have a Global Exception Handler Controller class that have all my Exceptions, this class works fine but I can't handle a 404 page not found exception.
This is the approach that I take following a tutorial
1) I created a class named ResourceNotFoundException that extends from RuntimeException and I putted this annotation over the class definition
@ResponseStatus(HttpStatus.NOT_FOUND)
like this:
@ResponseStatus(HttpStatus.NOT_FOUND)
public class ResourceNotFoundException extends RuntimeException {
}
2) I created this method in my exception's controller class
@ExceptionHandler(ResourceNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public String handleResourceNotFoundException() {
return "notFoundJSPPage";
}
But still when I put a URL that doesn't exist I get this error "No mapping found for HTTP request with URI"
The questions that I had read said that I need to enable to true an option for the Dispatcher but since my configuration it's different from the other questions and I don't have a Web.xml I couldn't apply that.
Here it's my Config.java
@EnableWebMvc
@Configuration
@ComponentScan({"config", "controllers"})
public class ConfigMVC extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/WEB-INF/resources/");
}
@Bean
public UrlBasedViewResolver setupViewResolver() {
UrlBasedViewResolver resolver = new UrlBasedViewResolver();
resolver.setPrefix("/WEB-INF/jsp/");
resolver.setSuffix(".jsp");
resolver.setViewClass(JstlView.class);
return resolver;
}
}
Here is my WebInitializer
public class WebInicializar implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(ConfigMVC.class);
ctx.setServletContext(servletContext);
Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
servlet.addMapping("/");
servlet.setLoadOnStartup(1);
}
}
Here is my Global Exception Handler Controller
@ControllerAdvice
public class GlobalExceptionHandlerController {
@ExceptionHandler(value = NullPointerException.class)
public String handleNullPointerException(Exception e) {
System.out.println("A null pointer exception ocurred " + e);
return "nullpointerExceptionPage";
}
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(value = Exception.class)
public String handleAllException(Exception e) {
System.out.println("A unknow Exception Ocurred: " + e);
return "unknowExceptionPage";
}
@ExceptionHandler(ResourceNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public String handleResourceNotFoundException() {
return "notFoundJSPPage";
}
}
And the class I created that extends Runtime Exception
@ResponseStatus(HttpStatus.NOT_FOUND)
public class ResourceNotFoundException extends RuntimeException{
}
|
|
|
|
|
hi everyone
i am new to this site. i am presently doing a practice java program to find reverse numbers, smallest and largest number out of the set of numbers enter and odd and even numbers
my problem is the smallest and largest. the odd and even numbers working okay, the reversed numbers working okay also
i am getting this arrayoutofbound index at line 41 and have been trying to figure out to fix it. can someone help. thanks in advance. here it the codes
another problems also it is repeating and i am not even getting the odd and even numbers to output.
int arr[]= new int[10];
int i=0;
int largest=0, smallest = 0,num;
for(i=0; i<=9; i++)
{
System.out.println("please enter a number");
arr[i] = userinput.nextInt();
}
for(i=9; i>=0; i--)
{
System.out.println(arr[i]+"\t");
}
for(i=0; i<=arr.length; i++)
{
if(i==0)
{
smallest = arr[i];
}
else if(arr[i] < smallest)
{
smallest = arr[i];
}
else if(arr[i]> largest)
{
largest = arr[i];
}
System.out.println("the smallest number is "+smallest);
System.out.println("the largest number is "+ largest);
}
for(i=1; i<=9; i++)
{
if(arr[i]%2==0)
{
System.out.println(arr[i]+" even number");
}
else if(arr[i]%2!=0)
{
System.out.println(arr[i]+" odd number");
}
}
|
|
|
|
|
for(i=0; i<=arr.length; i++)
Your loop should repeat only as long as i < arr.length . The array is 10 items long so index values go from 0 to 9, not 0 to 10.
|
|
|
|
|
thank you very much, I fix but i have one more thing, i need it just to pick out the smallest number and the largest numbers how do i get it to just pick out the smallest number and the largest number instead of this.
the largest number is 205
the smallest number is 0
the largest number is 205
the smallest number is 0
the largest number is 205
the smallest number is 0
the largest number is 205
the smallest number is 0
the largest number is 205
|
|
|
|
|
Put the print statements outside the loop.
|
|
|
|
|
thank you richard got it fix thank much
|
|
|
|
|
A simplified version of your code. And this version don't fail if largest value is the first one.
smallest = arr[0];
largest = arr[0];
for(i=1; i<=arr.length; i++)
{
if(arr[i] < smallest)
{
smallest = arr[i];
}
else if(arr[i]> largest)
{
largest = arr[i];
}
}
System.out.println("the smallest number is "+smallest);
System.out.println("the largest number is "+ largest);
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
thank you so much. got it to work. i never think about that version but thanks all the same.
|
|
|
|
|
Hi everybody,
I am fresh in Java, I would like to be a Java Programmer, so Please advice me what is the required skills, recommended books, latest java technology.
Regards,
|
|
|
|