Swing/AWT/SWT :: Creating New Window Or Call Existing One
Oct 13, 2014
Will the code below just create a new blank window rather than call the one I have? I want to call the one I have from my main method ideally.
JMenuItem menuDelete = new JMenuItem("Delete");
menuDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DeleteEnvironmentWindow deleteEnv = new DeleteEnvironmentWindow();
deleteEnv.setVisible(true);
}
View Replies
ADVERTISEMENT
Aug 20, 2014
I want to develop an application, which shows a circular window with close, maximize buttons.
I want to create something like this: [URL]
View Replies
View Related
Aug 7, 2014
What best API or whatever you call for browser automation? I mean clicking links, filling forms, gathering sources and other info. I already tried selenium WebDriver. It have all needed functions but there is no feature like attaching code into already opened browser so even doing google search it opens new browser window (opening takes ~5-10secs). Also I believe that there is no way that I could embed that browser into GUI.
Also tried WebSpecs and old Watij but also didnt found any way to attach or embed browser into my GUI.
So what I need is that I could create GUI with embeded browser and bunch of buttons. I click buttons then embeded browser clicks links, gets info etc.
View Replies
View Related
Jun 3, 2014
i wanna to call youtubeviewer from a window by actionlistener and i have tried N times....
Java Code:
public class YouTubeViewer {
public YouTubeViewer(){
NativeInterface.open();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame("YouTube Viewer");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.getContentPane().add(getBrowserPanel(), BorderLayout.CENTER);
[Code]...
note:necessary library for youtubeviewer is DJ Native Swing. if i call directly by main function,it will work.but if i call from actionlistener cant work (maybe crash).
View Replies
View Related
May 17, 2014
I am relatively new to java, and i am trying to create a window inside of a 2d char array, and eventually i will have to draw other shapes in this window. so for example
* * * * * * * * *
* *
* *
* *
* *
* *
* *
* *
* * * * * * * * *
The problem is my window is not drawing correctly too the border, but a couple extra chars on the x columns. Here is code. The dimensions of the window will eventually be passed through scanner in main, if i ever work out how to even draw it.Also, in class we never learnt to use the Graphics class, so im pretty sure we are not supposed to use it.
public class Window
{ //default values
private int xRow;
private int yCol;
private char ch;
public char[][] windowz = new char[30][20]; //30,20 (yx)flat values cuz doesnt work
[code]....
View Replies
View Related
Aug 15, 2014
The requirements are as follows:Design and implement the class Day that implements the day of the week in a program. The class Day should store the day, such as Sun for Sunday. The program should be able to perform the following operations on an object of type Day:
A. Set the day.
B. Print the day.
C. Return the day.
D. Return the next day.
E. Return the previous day.
F. Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add four days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday.
G. Add the appropriate constructors.
H. Write the definitions of the methods to implement the operations for the class Day, as defined in A through G.
I. Write a program to test various operations on the class Day.Should I break down my day.java into several separate classes, one for each of the sections (previous, next, etc)?
import java.util.*;
public class MyDay
{
static Scanner readinput = new Scanner(System.in);
String day;
public MyDay(String day)
{
day = "Sunday";
[code]....
Ideally I would like to create a Gui that would have someone type in the day, and then press a button to return the next day, prior day, or have a text input to test for adding X number of days.
View Replies
View Related
Sep 18, 2014
Its written that every constructor calls its super class constructor. And we know, constructors are called to create an object. Does it mean that if I am creating an object of a class, I am actually creating objects of all its super class???
View Replies
View Related
Oct 9, 2014
I want to embed an existing JAVA applet in to my swing application which is a standalone application. The applet is used in some other application which is not developed by me or my company. The application is open source application (So I have the source code). The entire existing application is basically one of the parts of my new application.
View Replies
View Related
Feb 5, 2014
Is it possible to display an AWT Window only(just 'cause feel like doing it)? Or, is the simplest window possible to display a JFrame?
View Replies
View Related
Jan 31, 2014
That's my third day working in Java using Swing and the IntelliJ Idea IDE.I'm trying to do something as simple as displaying a PNG in a window, and I'm doing this:
public class AboutRapide {
public JPanel mainPanel;
private void createUIComponents() {
mainPanel = new ImagePanel();
[cod]....
the problem is that, in the paintComponent method, the Image is never found when I run my app from the IDE, but it is when I run it from Finder in my Mac. Same application. I think it relates to how the application is launched so I guess what's a proper way to refer to a resource file with an image so it can be displayed no matter how the application is launched?Also if I generate a Jar for the application, as the resource gets into the Jar compressed file, it can't also be loaded.
View Replies
View Related
Dec 20, 2014
I am trying to create a gambling POS system and having problems with a method trying to get a value right after it was set. A jbutton sets another jframe visible which contains buttons. Upon action of the button, a value is set and the jframe is disposed.
private void btnPrizeActionPerformed(java.awt.event.ActionEvent evt) {
PrizeSelling prize = new PrizeSelling();
prize.setVisible(true);//create prize selection window
bin = getButton(); //gets what button is selected to load the correct prizes for correct game
prize.DBconnect(bin);//sends bin number to prize loading method
[Code] ....
As soon as btnPrize is clicked it gets the total value of the prizes selected which of course is 0 because it is ran before it is set. How can I make it wait until the window is closed before continuing?
View Replies
View Related
Oct 29, 2014
I am trying to drag the window down wards and screen has alignment issues. I tried to use WindowListeners, Component Listeners, MouseListeners ect…
But still this problem persists as only I release the mouse after drag down it appears fine that we have handled ComponentResized() method. So how to restrict component size while keep dragging down?
View Replies
View Related
Mar 23, 2014
sale s = new sale();
jDesktopPane1.add(s);
s.show();
says not a suitable method?
View Replies
View Related
Oct 14, 2014
We are creating a quiz as a school program, we are using netbeans and we have a little problem. The problem is that our JButton opens a new JFrame in a new window and we want it to stay in the same window. The code we are using is:
private void PlayButtonActionPerformed(java.awt.event.ActionEve nt evt) {
Question1 s = new Question1 ();
s.setVisible(true);
}
Is it possible to make it stay in the same window?
View Replies
View Related
Feb 17, 2014
I need that when my application is minimized notify you when something happens, like the messenger (MSN) remember? The window notifying a new message, the minimized window blink in orange, orange need not be ok? I do not even know where to start.
View Replies
View Related
Oct 14, 2014
I have added a windowListener to my JFrame but for some reason it is not being called when I click X to close the window. I need to send a message to a server to notify it that the client window is closed. Some code snippets below (some lines excluded for brevity):
public class ChatGUI extends javax.swing.JFrame {
....
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); // I have all the window constants here but has no effect other than closing the window without calling the listener...
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosed(java.awt.event.WindowEvent evt) {
formWindowClosed(evt);
}
});
....
private void formWindowClosed(java.awt.event.WindowEvent evt) {
[code]....
This is resolved, needed to use...
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
... instead.
View Replies
View Related
Jan 19, 2014
I'm using a jpanel with an 8 by 8 grid layout of jlabels to which I'm adding images to represent a chess board. At first, I was using the ImageIcon class to initialize my icons, but as soon as I added these icons to the labels, the labels no longer changed size with the window (which I want to happen). URL...
So I copied in the class, and initialized a different set of icons using the stretch icon class (specifically, the method that allows you to initialize a stretch icon from a filename), however, when I use these stretch icons, the result is the same. Is something wrong with the class, or with my implimentation of it, and how would I fix this?
View Replies
View Related
Jan 16, 2014
I'm using a jpanel with an 8 by 8 grid layout of jlabels to which I'm adding images to represent a chess board. At first, I was using the ImageIcon class to initialize my icons, but as soon as I added these icons to the labels, the labels no longer changed size with the window (which I want to happen). Someone suggested to me to use this custom stretch icon class, found here:
[URL] ....
So I copied in the class, and initialized a different set of icons using the stretch icon class (specifically, the method that allows you to initialize a stretch icon from a filename), however, when I use these stretch icons, the result is the same. Is something wrong with the class, or with my implementation of it, and how would I fix this?
View Replies
View Related
Nov 7, 2014
How can I make a call to paintComponent within the JPanel-class, from another Class?
In class TestClass:
public class TestClass {
public TestClass() {
JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.setSize(500,500);
initComponents();
[Code] .....
View Replies
View Related
Nov 16, 2014
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?
Here is the full code
import java.awt.BorderLayout;
import java.awt.ComponentOrientation;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
[Code] ...
View Replies
View Related
Feb 20, 2014
I'm trying to create a chess program in java swing, and for the board I'm using an 8 by 8 array of jlabels stuck inside a jpanel with a grid layout. I would like the board to change size when the window changes size, and the grid layout accomplishes this succesfully, until I add the actual icons to the jlabels. Then the board just stays a fixed size. Someone suggested I use their "Stretch Icon" class, found here:[URL] ...., so I tried initializing the icons using one of the constructors in the class (the one that takes an image name and a boolean value for whether or not you want the resisizing to be proportionate (to maintain the aspect ratio)). However, the same thing happened. The board appears, but it does not resisize. To attempt to fix this problem, I tried simplifying my code, reducing the program to two jlabels within the jpanel, for which I then tried to set the image in the same way. Here is my simplified code:
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;
[Code] ....
I'm misusing the stretch icon class, or just generally what's going wrong/how to fix it?
View Replies
View Related
Jan 26, 2014
I am making a java swing program. I have a main window that opens a JForm window when the user clicks a menu option. Then I have a button on the JForm that closes the window on click. However, I would also somehow like to make the JForm return values to the main window (according to the states of the selector components) when it is closed. How would I go about this? Currently my jForm is a seperate class called "NewGame", and inside the menu item mouse clicked method, I have the following code:
//open new game jform window
NewGame newGameWindow = new NewGame();
newGameWindow.setVisible(true);
newGameWindow.setLocationRelativeTo(null); //center window
Is there something I can add here to get the object's values upon the window's close? Or is there a way I can add that into the button clicked method on the actual jForm?
View Replies
View Related
Feb 12, 2014
I have a JFrame where some elements (one, for now) have to be centered manually on the contentPane when resizing the window or changing the window state. Resizing event (componentResized) works fine but the windowStateChanged event is causing problems because it doesn't seem to "update" the contentPane's new size properly - it keeps the previous value although the window's size is obviously changed. This can be seen by simply printing the result of getSize called on contentPane.
Centering is done by programmatically changing the constraint of the component (using putConstraint, SpringLayout). The issue is that getWidth used in that method returns "wrong" values which results in an uncentered component. Maybe another listener is needed here?
Additional info: Eclipse with WindowBuilder, Linux Mint 15, Java 1.7
I know about SSCCE guidelines but I cannot make this particular example both ready to compile and short.For unknown reasons, I am unable to post the code example. I keep getting this - "Post denied. New posts are limited by number of URLs it may contain and checked if it doesn't contain forbidden words."
addWindowStateListener(new WindowStateListener()
{
// no "@Override" was generated but it is the same with it
public void windowStateChanged(WindowEvent e)
{
System.out.println("EVENT: " + contentPane.getSize() + ", "
+ getExtendedState() + ", " + e.getOldState()); // amusingly, states are actually correct - interchanging between 0 (Frame.NORMAL) and 6 (Frame.MAXIMIZED_BOTH) when I maximize and "unmaximize"
tfArrayPanelCenter();
[code]....
View Replies
View Related
Apr 6, 2015
I am new to javafx I start using it instead of swing i used the scene builder for my forms the problem i faced i don't know how to have main screen with menu bar at top and depending the select from the menu it will open other windows and those window must be inside my window just like for example netbeans.
I don't need to open new window in separate i need all windows inside my main window and controlling over them minimize maximize perhaps.
View Replies
View Related
Sep 28, 2014
I am trying to make a JTree. I have used this guide :[URL]
Now when I call my Class with
TreeMainMenu tree = new TreeMainMenu();
JScrollPane MainMenu = new JScrollPane(tree);
I get only the default JTree..
I need to understand how I should build my code to call the class as JTree.
This is my code:
public class TreeMainMenu extends JTree {
private DefaultMutableTreeNode top = new DefaultMutableTreeNode("TOP");
JTree tree;
public JTree TreeMainMenu() {
APNode();
tree = new JTree(top);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
return tree;
[code]....
View Replies
View Related
Mar 25, 2015
I am trying to make a 2d graphical animation using the java swing classes in order to make a frame. I had a basic version working when all of the code was under the main method, but when I moved some into another method it broke it. With y understanding of java my code should work as I create a variable of the method containing the code and then assign the size and exit button. However this causes many problems such as my BeaconFrame method informing me that it is unused when I have used it. Here is my code:
import javax.swing.*;
import java.awt.*;
public class BelishaBeacon {
public void BeaconFrame() {
JFrame frame = new JFrame();
JPanel panel1 = new JPanel();
[code]....
View Replies
View Related