I am trying to to insert time onto my jFrame (Netbeans) by using textfields. this is the code i've tried to put into the textfield so whenever i run the program it automatically shows the time.
I am trying to develop a GUI through hard coding. I encountered a challenge:
I created a Jframe and onto this I added a JPanel. I assigned thge flow layout manager of the frame to null(because i want to do the positioning of my components manually)
The program is running perfect except when i click the maximise button of the frame, the JPanel does not change its size.
With Netbeans IDE - i found that the propert is Horizontal Resizable propert. I have tried to look for the method but in vain.
I am trying to develop identical things from hard coding and in drag and drop environment. so with drag and drop its easy but in hard coding how do I work it out?
Here is the code :
public class JPanelDemo { JFrame frame; JPanel panel; JPanelDemo(){ createFrame();
public class Frame extends JFrame{ private final static int WIDTH=400, HEIGHT=400; public Frame(){ super(); super.setSize(WIDTH,HEIGHT); super.setVisible(true);
[Code] ....
In my main class I am just creating the frame and the panel then adding the panel to the frame.
As said, running the jar file instead of exe file the splash screen is displayed.
I printed some logs into splash screen class: when I run the app from the jar this logs are printed, instead when I run the app from .exe file these logs are not present.
there is a main JPanel in my application in that main JPanel i want to add two JPanels with a seperator in between . Though i have added the seperator but its taking some extra space and when i am changing its size , there is no effect . how can i remove/reduce this extra space taken by JSeperator? below is view logic ,
mainPanel = new JPanel(new GridLayout()); jp = new JPanel(new GridLayout(8, 2, 5, 5)); jp2 = new JPanel(new GridLayout(8, 1, 5, 5)); jText = new JTextField(10); jText2 = new JTextField(10); jText3 = new JTextField(10);
I'am new to java, this question may have been asked earlier but I'm not getting the exact answer.I want to add data from database into at and display it through jsp. But empty or null values is shown i.e no data is being displayed and when I execute the same sql query which is used in code in sql server then required output is displayed. My java code is:
Java Code:
public List < Alarm_Bean > get_Count(String system_Name) { if (system_Name.equals("MPS")) { try { con = getConnection(); stmt = con.createStatement();
So for a test i have a small array set as a jlist which is the contents of my jscrollpane, and it appears as if nothing is there until i adjust the window size by dragging it out or in... whats going on?
I made a web app to test the ServletContextListener in tomcat according to the book head first servlets and jsps and used the code
out.println("test context attributes set by listener<br>"); Dog dog = (Dog) getServletContext().getAttribute("dog"); out.println("Dog's breed is: "+dog.getBreed());
in the listener class.But the output is showing the first line only and the second println() is not showing any output whereas my Dog class compiled successfully and I didn't see any NullPointerException as expected in the book but somehow it seems like the problem is in the 2nd line of code only but I don't know what.
I also tried to add a 4th line at the end with println() only but with a simple text even that is not running but when I put that same line after the 1st line, the output is shown.I am unable to see what has gone wrong in the 2nd line of code.
I am working on an assignment that I can't seem to figure out the final part to. The program takes in course data such as the time the class starts and how long it lasts. The time is in military time (0000 - 2400)
I need the output time to be the time the class started, plus the length of the class, and displayed in military time.
I can't for the life of me figure out how to do this. I have gotten a program that works for this time and minutes, and displays the correct 1020. But when I change the information to say
Start time: 0700 Length = 90 minutes
I get:
Endtime = 90
90 is technically correct, the way the formula is setup, but I need it to display 0900 not 90.
Here is the code that I have. Be easy, I'm still learning, and this is just the file I created to get the formula to work. Also, the verbose in here is just for my own debugging to make sure values should be what I'm expecting them to be.
public class calc { public static void main(String[] args) { double hours, minutes, length; double temp; int time = 2400; hours = time / 100; System.out.println("Hours are: " + hours);
I have two classes. time_runner is used for testing my code.
This is what I'm using to test my code:
class time_runner { public static void main(String str[]) throws IOException { Time time1 = new Time(14, 56); System.out.println("time1: " + time1); System.out.println("convert time1 to standard time: " + time1.convert()); System.out.println("time1: " + time1); System.out.print("increment time1 five times: "); time1.increment();
[code]....
The two constructors are "Time()", which is the default constructor that sets the time to 1200, and "Time(int h, int m)" Which says If h is between 1 and 23 inclusive, set the hour to h. Otherwise, set the hour to 0. If m is between 0 and 59 inclusive, set the minutes to m. Otherwise, set the minutes to 0. Those are my two constructors that I pretty much have down. The three methods however I'm having trouble with. The "String toString()" Returns the time as a String of length 4. The "String convert()" Returns the time as a String converted from military time to standard time. The "void increment()" Advances the time by one minute.
public class Time { private int hour; private int minute; public Time(int h, int m) { if(h > 1 && h < 23) hour = h;
/* * 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 tables; import java.util.Date; import javax.swing.table.DefaultTableModel; import javax.swing.JOptionPane; import javax.swing.RowFilter; import javax.swing.table.TableRowSorter;
how to use JFrames and button and so on in Java. I found this video on youtube and followed it along, however even though my program is virtually identical to his, I'm still getting errors.
Here's the video I was watching: Video
And here's my code:
import javax.swing.*; //Imports JFrame and JButton for use import javax.swing.JFrame; import javax.swing.JPanel; import javax.*; import java.awt.*; import java.awt.event.*; public class swing
[code]....
The reason why I'm importing some many things is I'm trying everything to try fix my problem.
He's the error messages I'm getting:
frame2.add(panel); ^ C:UsersWindows 8Documentsswing.java:42: error: illegal start of expression frame2.add(panel);
[code]....
I used to make the button just create another frame without additional labels but I changed it to be even more similar to his program just to rule everything out. Also initially my program varied quite a bit, I've changed everything to be like his. Even without the ";" error I got, I kept telling me I was not allowed have my class as static, even though the guy in the video has it set to static. Also I don't think my "setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);" is working as it doesn't change color.
I think the problem is with my panel, it isn't adding to the frame for some reason.I'm using TextPad7 and I'm using Win8.
C:UsersWindows 8Documentsswing.java:42: error: '(' or '[' expected frame2.add(panel); ^ C:UsersWindows 8Documentsswing.java:42: error: illegal start of expression frame2.add(panel);
[code]....
I would also like to point out that some of the comments are out of date and are referencing the way the program was before I made it just like his. For example I know my second class isn't inheriting the first class.
how to build GUI's with JFrame and I was firstly very confused as to when and what is always needed for any GUI in Java. How do I know everything I need for a GUI? Are there certain things every GUI will need by default?
Additionally below I have a code snippet of when this person used the "this" as an argument to a JButton and Im just really confused for when I can use it and when I can't.
public UIStuff(){ super("Multiple Button Events"); init(); } // end multi-button
i am creating a desktop application. In this application, firstly there is a log in form. Now, i want to display the another form on the same window i.e by removing log in form a new form..
So I've been getting back into Java and downloaded eclipse back onto my laptop. However when I go to make a simple rectangle into a JFrame, the frame will pop up but no rectangle will be shown. Here is my main class, which sets up the JFrame...
mport javax.swing.JFrame; public class Frame{ public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("I hope this fucking works"); frame.setSize(400,400); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Is there a way to simply slap a rectangle into a JPanel (make it appear) with out creating an inner Class or helper Method, all within "Main"? And if not, why?
Making a JFrame is easy.
Adding a JPanel is a snap.
import java.awt.Color; import javax.swing.JFrame; import javax.swing.JPanel; public class TheJFrame { public static void main(String[] args) { // TODO Auto-generated method stub