Swing/AWT/SWT :: Connect Popup Menu To JFrame
Jan 22, 2015
Is there a way to connect the popupmenu to the right Object (JFrame).
(Something like SwingUtilities.getWindowAncestor(popupmenu)
I've created 2 JFrames each with the same MouseClass. When you click on the RMB a pop menu is shown with a background item. When clicked on the background item only the last created JFrame changes his background.
Below is my simplified code. I'm probably not thinking like a good OO'er.
static JFrame frame;
static JPopupMenu popupMenu;
public static void main(String[] args) {
popupInit();
frame = new JFrame();
frame.setBounds(0, 0, 230, 230);
[Code] .....
View Replies
ADVERTISEMENT
Apr 8, 2015
package newdb;
import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
[code]....
i want to popup menu add in jlist and select file than open and save through context menu. but popup menu show on frame not in list .
View Replies
View Related
May 26, 2008
I need to make a popup menu contains copy and paste in a swing to copy or paste from jlabel or jtextbox , but i dont know how?
View Replies
View Related
Nov 1, 2014
I have a combobox with this PopupMenuListener. All works fine, except that the popupMenuWillBecomeInvisible method does not capture the selection made and neither does it show the selection.
PopupMenuListener pmlMqMessagePurged = new PopupMenuListener() {
@SuppressWarnings("unchecked")
public void popupMenuWillBecomeVisible(PopupMenuEvent arg0) {
try {
JdbcSqlServerDataSource ds = new JdbcSqlServerDataSource(
DbConnectionURL.UToolDbHostName, 0,
[Code] .....
The popupMenuWillBecomeInvisible does fire but the System.out.println() returns 'nul'l as answer to the value i have selected from the combobox.
View Replies
View Related
Dec 7, 2014
Main screen leftsecond screen rightswing portal application is visible on two screens. If you open a context menu (right mouse) on the right screen, the context menu open on the left (Main) screen instead of the right.
View Replies
View Related
Aug 14, 2014
I want to read json file as follow;
{
"M": {
"row": [
{
"col1": "c00"
},
{
"col1": "c10",
"col2": "c11"
},
{
"col1": "c20",
"col2": "c21",
"col3": "c22"
}
]
}
}
Next to reading I need to assign to two dimensional array, but without giving "col1","col2","col3" a lot.
The array is for example, Array[3][] = {{"c00"},{"c10","c11"},{"c20","c21","c22"}};
View Replies
View Related
Aug 17, 2014
I am tasked with creating several JPanels each of which has a title centered at the top. As such I have created parent panel that each panel extends. However, I am uncertain as to whether drawing the string on the panel or using a JLabel is the best solution. The panels might allow dynamic resizing...
View Replies
View Related
Oct 8, 2014
I would like to create a sub menu for every list item in a Jlist. I need the UI like avast interface. If we hover over an list item, its sub menu should be shown. I attempted to put an sub menu but didn't work. Is this possible in Swing?
View Replies
View Related
May 31, 2014
I am trying to make a Connect Four game with java swing, but I am getting an error with my attempt at making an multi D panel maker when I try to run it.
import javax.swing.*;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
[code]...
View Replies
View Related
Apr 13, 2014
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
[code]....
View Replies
View Related
Apr 9, 2014
I have a Jframe and i want to add inside 4 different jpanel.This is easy.
what is difficult is how can i change them dynamically with 4 other new jpanels and 4 other new jpanels?
I have try with BorderLayout but not working.
It's a wizard like but not the same.
I have a jpanel with jbuttons jpanel with a jtable jpanel with textarea and jpanel with jlabels. All this have to change with other 4 jpanels, where to look?
View Replies
View Related
Mar 20, 2014
All I need to do is show in just one JFrame the two combined JFrames. One JFrame namely leftPanel will appear to the left or west and the other namely rightPanel to the right or east using BorderLayout. I already did creating them first as JPanels or as internal classes and subsetted them in one JFrame but that didn't work because it looked messy. And now I've created them as two separate JFrames, compiled separately, and tried to subset them as one in the JFrame. I didn't add any functionality to this program because all I intend to do is to show those two JFrames together in one JFrame. Here's the code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class dirtyIceCream extends JFrame {
leftPanel westPanel;
rightPanel eastPanel;
public dirtyIceCream()
[code].....
What am I missing or did I code anything wrong here? Or should I use NetBeans IDE for anything as complicated as this?
View Replies
View Related
Jul 23, 2014
How to load an image to a swing application?? I want to load it to myframe(JFrame)..
View Replies
View Related
May 26, 2014
I am rather new to Swing, and I am building a game right now in which I need to display a pop-up window as a reminder for what commands exist within the game. I created a class extending JFrame for this and added all the information I need. However, for some reason, no matter how many different ways I try to set the size of this window (setSize(w, h), pack(), using a different layout, adding the compnents to a JPanel first and setting the preffered size of that, then adding the JPanel to the JFrame), it doesn't work. Instead of a window of my requested size, I get a tiny, maybe 100 x 100 pixel window that needs to be resized in order for its contents to be visible.
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
[code]....
View Replies
View Related
Apr 4, 2014
I pick this code from Head first Java
package GUI;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Graphics;
import java.awt.Color;
public class gui5 {
int x=0;
int y=0;
public static void main(String... x) {
[code]...
but just a Jframe is appearing no Jpanel no green color circle?What is wrong with code
View Replies
View Related
Jan 14, 2015
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
[Code].....
View Replies
View Related
Sep 14, 2014
Following is the code on the click of a button, id like to know how do i close the current jframe on which the jButton4 is currently placed. I know how to send it to the next Jframe i.e JobCard. But need to close the current one. I tried using this.setVisible(true); But it does not work.
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.setVisible(false);
JobCard jobCard = new JobCard();
jobCard.setVisible(true);
}
View Replies
View Related
Apr 16, 2014
I need to put a Web Page in my JFrame application , I got a lot codes on the internet and could implement without problems , but the problem is that this code has an ugly page as hell, with colored all wrong and with a very poor quality , one of code I used was this :
* import javax.swing . ;
{ public class SwingWebPage
public static void main ( String args [ ] ) throws Exception {
JEditorPane website = new JEditorPane ( " http://www.google.com/ " ) ;
website.setEditable ( false) ;
[code]...
If you test , you'll see that the page is displayed in the JFrame is horrible.
View Replies
View Related
Mar 27, 2014
I am try to do an application based in multiples JFrames, each one with its particular responsibilities, and use one JPanel as a menu with buttons that connect one JFrame to another, But this menu is instantiated at run in view (layout made by netbeans) the Main Jframe appears with its internal JPanel, but the instantiated JPanel does not appear or does not show it's buttons. (notice only run method in the second class):
JPanel Menu that will be used in all alone JFrames of application:
public class MenuSuperior extends javax.swing.JPanel {
public MenuSuperior() {
initComponents();
} private void initComponents() {
[Code] .....
View Replies
View Related
Feb 7, 2014
I want my jrame should not be resized when clicking on maximize button of window.and for this i have put setResizable(false)in the constructor of class which extends Jframe.
View Replies
View Related
Apr 28, 2015
I want to know know to copy a rectangle on my jframe and paste it in another location on the same jframe.
View Replies
View Related
Sep 24, 2014
I didn't know about right method for correct close operation for JFrame component or kill the object. I found out few, which of them you are using usually???
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(false);
JFrame.DO_NOTHING_ON_CLOSE.
System.exit(0);
View Replies
View Related
Aug 30, 2014
This is right from a book I'm reading but it doesn't work. The problem is to write an application that lets you determine the integer value returned by the InputEvent method getModifiers() when you click your left, right, or middle mouse button on a JFrame.
This is the code copied directly from the book. What is missing:
import java.awt.event.InputEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JFrame;
public class JLeftOrRight {
[Code] ......
View Replies
View Related
Apr 4, 2014
I trying to replace original (and empty) JPanel in JFrame with my own made one, components does no appear right, when I pass the mouse first button appears:
MainViewClass:
...
private void initComponents() {
...
MenujPanel = new MenuSuperior();
MenujPanel.setBorder(
BorderFactory.createTitledBorder("Dados Pessoais"));
[Code] .....
Here is the video:
View Replies
View Related
Jul 2, 2014
I am trying to write a game which needs timer beginning from zero to.... , and show it in my jframe. How can I do that?
View Replies
View Related
Jan 16, 2014
How to display an image on a JFrame. If you can, pany example code.
View Replies
View Related