Swing/AWT/SWT :: How To Use Data From Login Panel In Another Class
Aug 4, 2014
I am getting datas from user and checking it with database (MS SQL ) if it fits it is sweatching to new window. In new window I need to use again my database so I need to add connecting datas again. I would like to get them from login window. How to do that? I know theory but when I am writting code nothing works. Here is working code for login panel :
/*import java.awt.BorderLayout;
import javax.swing.*;
public class Login extends JFrame {
public String url;
public static void main(String[] args) {
Log frameTabel = new Log();
I am getting data from user and checking it with database (MS SQL ) if it fits it is switching to new window. In new window I need to use again my database so I need to add connecting data again. I would like to get them from login window. How to do that? I know theory but when I am writing code nothing works. Here is working code for login panel :
/*import java.awt.BorderLayout; import javax.swing.*; public class Login extends JFrame {
I have this panel in a nested class in the MainPanel class and it does not display, when I launch the applet, or more like, the two menus "LineColor" and "BackColor" from the nested class ColorPanel do not display .
When i click on the button from bottom panel, top panel need to be redrawn. But redrawing is not happening. It happens only when resizing the applet.
public class Graphics_Chart(){ public init(){ JScrollPane topPane = new JScrollPane(new ImagePanel2()); topPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); topPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
I have write a SSO class for Single Sign on But i am getting one issue i am using JSF2 for my web application...here is my SSO class :
public class ApplicationSSO implements SSO { public String authenticateUser(RequestContext request) { UmUsersList user = (UmUsersList) request.getSessionContext().getAttribute("USER"); return user.getUmulEmailId(); }
[Code] .....
As you can see i have write below line
JSFUtils.redirectPage("../login/Login.xhtml");
It mean if User null it will redirect to Login page but it is not working. How to solve the issue i am end up with
An error has occurred.
For detailed error information, please see the HTML source code, and contact the forum Administrator.
Error while executing SSO actions: java.lang.NullPointerException
I have a JPanel class that creates a left panel and a right panel. the left panel and right panel both have one button each. What I’m trying to accomplish is when I click on the button in the left panel that it updates the button in the right panel. I have to do this without changing anything in the right panel.Basically I have to have LeftPanel have a way to keep track of an instance of RightPanel and I would have to do this through the JPanel class. But I have no clue where to begin on even accomplishing this.
I currently have the code set up to iterate through objects and keep track of them but how do I do the same and draw the objects on the panel window? I'm confused on what to do and how to start it.
Here's the code I have so far, the 'Car' which I want to draw extends to another class which extends to GameObject. I currently have a 'draw()' method under the 'Car' class but nothing in the 'draw()' method yet. From what I understand i'm suppose to have a 'draw()' method under 'GameObjects' class also?
public class MapView extends JPanel implements IObserver, ActionListener{ JPanel myPanel; private Timer timer = new Timer(5, this); int x = 0; int moveX = 2; public MapView(){ super.setBorder(BorderFactory.createTitledBorder("Map:"));
[code]....
Mostly I don't understand how to go through the iterator again to paint the objects. Wouldn't I need to put another iterator under 'paintComponent()' or can it be done under 'update()' ?
how to get some shapes from the GameObjects onto my panel.
I've created a chat program, but now I need to show messages in different colors depending if the message is received or sent. I was wondering if I can use jlabel to do this but in this case I need that jlabels to scroll in a jpanel. how to do this or maybe using a rtf ?
My panel named panelIncomeInfo are not showing the components that I have added.
public class PayrollGUI { private JPanel panelIncomeInfo = new JPanel (); private JPanel panel = new JPanel (); private JPanel panelPayCheckInfo = new JPanel (); private JButton close = new JButton ("Close");
Is it possible to make Expand/Collapsable panels in Java without writing huge amounts of code? I want something like this Expand/Collapse How would I go about it?
I have two classes: main (with JFrame) and a panelLogin class with a method returning a panel with all login components..so I create a new panelLogin in main and use the method to get the panel, put it into my JFrame. But here the problem: on the loginPanel the ActionListener for the login-event, if the input is correct,the panel shall disappear and the main panel shall appear.Should I make some kind of top class, which handels the panels?
I have a program with a main panel JPanel that implements KeyListener. I added a JTextArea to which I added as the KeyListener: this, meaning the main panel. I made the JTextArea fill the entire main panel because I want to catch a key press anywhere in the main panel.I catch the key presses and the program does what I want it to.
I added a JToolBar to the program; it is working just fine.Now that I have two components on the main panel - toolbar and panel with textarea -, the textarea must have the focus before it will send the KeyEvent and call keyPressed(). I don't want to expect the user to click on the main window to get the program to start or after each time they use the toolbar.
I have tried calling both requestFocus() and requestFocusInWindow() on the textarea; neither call worked. I put the toolbar at PAGE_END instead of PAGE_START; this worked to allow the program to start but I don't want to have the toolbar at the bottom and once I clicked on a toolbar button, the textarea lost the focus.
I need to be able to give the textarea the focus when the program starts and after the user uses a toolbar button. (I suspect that if I solve the problem when the program starts, I can use the same method after handling a button press.)
I want to switch panel on click of a button and code for switching panels is written in update method (Which gets called from notify observer of another class as part of Observer pattern.
playGame in Panel 1 of class 1 calls another class (class 2)and data comes in update method of class 1(Observer interface).
Now for switching panels code is in gameControllerDataProcessing . I am not able to switch the panels when this functionality runs.
However if i dont call the unoGameController.playGame(playerFirst.getText(), playerSecond.getText() and directly call the update method or directly write the switching panel code . then it works fine.
In JButton's click event, I wanto to show a JPanel to print the message "Processing" on the screen. Before JButton's click logic end, hide the JPanel.
Actually, JPanel is not displayed. I do not know why.When msgPanel .setVisible(false); is commented out, JPanel is normally displayed .But do not know how to hide it when JButton's click logic is finished.
Here is the code.
loadBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { JPanel msgPanel = new JPanel(rootFrame); // Show the message JPanel
I am trying to read Point objects from .drw file which contains endpoints of line segments, and draw lines making a square on panel when I run the program. This is what I have got so far. how to get the points using array for drawing ?
// inside the method to read points objects from .drw file try { fos = new FileInputStream("square.drw"); oos = new ObjectInputStream(fos); // creating an object of Point class endPoints = new Point[sampleSize];
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.
I have a JPanel that's using a simple GridBagLayout.
JPanel panel = new JPanel(); GridBagLayout qPanelLayout = new GridBagLayout(); qPanelLayout.columnWidths = new int[] { 0 }; qPanelLayout.rowHeights = new int[] { 0 }; qPanelLayout.columnWeights = new double[] { Double.MIN_VALUE }; qPanelLayout.rowWeights = new double[] { 0.0 }; panel.setLayout(qPanelLayout); componentCount = 0;
Based on user input I am adding sub-panels to the panel. These sub-panels may vary in height. They take up the full width of the Panel.
public void add(Component comp) { GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(2,2,2,2); gbc.gridx = 0; gbc.gridy = componentCount++; panel.add(comp, gbc_questionPane1); }
The odd behaviour I'm seeing is that if the height of the new sub-panel I'm adding is less than the height of the largest sub-panel currently displayed then the main panel does not repaint. If its height is equal or greater then the Panel does repaint, and any sub-panels that were added but not visible before are now painted. What have I missed?
I need to store the data of a bunch of objects of a particular class in files in a predefined directory. Later, I want to get all the files from the directory and turn them into the objects again. Ideally, I'd like to have one file per object and have the files be human-readable and editable without too much difficulty. The class used by the objects will likely be subject to change in the future, as well. To keep things simple, all the data members are either primitives, Strings, or arrays of them. What is the best library/API to use to deal with this situation? Or should I write my own classes for these operations?
I read into serialization, but I read that it doesn't deal well with classes that are frequently modified. I also found articles on Preferences, but none of the ones I saw seem to explain how to best handle reading and writing to and from multiple objects, especially when I don't know a prior all the objects that were written to disk.
I've been unable to figure out how to access an objects data from another class. I ended up missing a lesson in java and haven't been able to catch up on this topic on my own through my textbook.
Error: has private access
Code:
public class TestCoffeeDrinker { public static void main(String[] args) { Coffee latte = new Coffee("Starbucks Tall Latte", 2.85); Coffee mocha = new Coffee("Starbucks Grande Mocha", 3.95); Coffee mcdonalds = new Coffee("McDonalds McCafe", 0.99); System.out.println(mcdonalds.toString());
I have been asked to write a program with 3 classes(an interface, a store and a product class) and I have been going ok until I need to display data on the interface that is held in the product class. At the moment the code will compile fine but when I run the program and try to use the writeOutput() method I get a stack overflow error.
I realise now that it is because of a non-terminating recursive call, however I can not think of a solution on how to fix the problem. And just to clarify, what I am aiming to do is have the MatesTerminal class display the data for name that is stored in the Product class(I have no way of determining which product to display at this time, so I would like to be able to display the data for all three products if possible). Anyway this is what I have so far:
The method from the MatesTerminal Class:
private void writeOutput() { int productChoice; Scanner console = new Scanner(System.in);