swing,uinavigationitem , Navigation Bar Back Button Arrow Font Swift

Navigation Bar Back Button Arrow Font Swift


Tag: swing,uinavigationitem

So I manage to change the font of the back button as said in this post but now I have two arrows(<), one is the back button default arrow and the other is the button title arrow ("< Back").

How do I remove/change the back button default arrow to the font want?


One way is to create a transparent graphic and set it as the background image of your Backbutton. So your code should look like this:

    let backButton = UIBarButtonItem(title: "< back", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
    backButton.setTitleTextAttributes([NSFontAttributeName: UIFont(name: "RobotoCondensed-Light", size: 20)!], forState: UIControlState.Normal)
    backButton.setBackButtonBackgroundImage(UIImage(named: "transparent_1px.png"), forState: UIControlState.Normal, barMetrics: UIBarMetrics(rawValue: 0)!)
    navigationItem.backBarButtonItem = backButton


Clojure invokeLater null pointer

This code: (import 'javax.swing.SwingUtilities) (SwingUtilities/invokeLater (print "hi")) Causes this error: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) ... I don't know if this is a problem, since the code itself actually works (printing to the REPL) despite the error. However, modifying swing components does not seem to work properly: a...

Java JButton.setAction(…) null's button text

The following code renders a JButton without text: public abstract class Test { public static void main(String... args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { e.printStackTrace(); } SwingUtilities.invokeLater(() -> { JFrame frame = new JFrame(); JPanel panel = new JPanel(); String text...

Putting text from JTextField to JLabel

I 'm working on code that takes a string from a JTextField and puts it on a JLabel. But my problem is always the string shown is missing the last character. private void jTextField1KeyTyped(java.awt.event.KeyEvent evt) { String ch=jTextField1.getText(); jLabel1.setText(ch); } ...

dispose() vs setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

I have been searching around quite a bit about this topic but never got any satisfaction about any answers so ended up asking a question here :). Anyways, from this similar post it was clear that dispose() does not terminate all the processes and still has remains in the...

How can I make an entire row have a border when a cell in the row receives focus?

I have a JTable with 4 columns. Each column has it's own customized cell renderer. When a cell receives the focus, it gets a border around it. How can I make the entire row have a border and not just one cell?

Array JLabel ActionListener multiple JPanels

I have an array of JLabels and I want to add an ActionListener to them. Every label should display a panel and the other should be removed. How can I realize this?

Buttons and paint method

I'm having trouble with my buttons. I know they're working because I've tested them out by exiting the problem through System.exit. Here is what my output looks like: http://imgur.com/Ks7mIFa When I click the close button, the handle on the switch should redraw to the other side and the close button...

“Terminal” font used in Paint for Windows 8 [closed]

I want to use the Terminal font that I've been using for a few headers I made in Paint. I know that Java doesn't support bitmap fonts. I'm trying to find a way to get a TrueType version of the above font and I'm getting absolutely nowhere. The last resort...

Coloring Text in JTable Cell

I want to color text in a JTable cell. I'm using a DefaultTableCellRender with HTML Tags to color multible words/text. I'm using Regex to find words/text and replacing them by adding HTML Tags. The problem here is that the HTML tags them selves should not match by the regex. example:...

JButton listener not firing

I seperated my codes into MVC model and now my confirm button action listener is not printing the username and password even though I added a Actionlistener for it. please help thanks. Codes LoginDialog.java import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JDialog;...

Animation not adding to JFrame

I'm new to java swing, so forgive me if my mistake is extremely obvious. What my code is supposed to do here is create one JFrame and animate two boxes moving upwards through the frame side by side. However, I'm seeing only one box (the blue box created by the...

JFrame wrong location with Ubuntu (Unity ?)

It seems that there is a bug with Ubuntu (maybe only unity). The decoration of the JFrame is taken into account for getLocation() and getSize(), but not for setLocation() and setSize(). This leads to weird behaviour. For instance, if you use pack() after the frame is displayed and the dimensions...

Why textPane.getDocument().getText() Returns Empty String?

What am I doing wrong here in an attempt to get text (with newline characters at their places) from a JTextPane component with content-type "text/html"? textPane.getText() returns HTML but with empty head and body. textPane.getDocument().getText() returns an empty string. P.S.: I am also having no line-wrap and other issues in...

How to keep GridBagLayout from changing the size of a button

In my FlashCardPanel class, I have a subpanel,LabelPanel, with a Grid Bag Layout. It consists of a constructor with an edit button, a button to "flip" the card, and the label to display the term/definition. My problem is that every time I click my "Flip" Button to display the definition...

Java Swing JFrame launch another JFrame for game

I am developping a little game using Java. I have a main JFrame for my application that can create another Window (the game window) by clicking on a JButton. I have already teste my game window alone and everything is ok. Here is my game window constructor: public GameWindow(final GameController...

UINavigationItem setLeftBarButtonItems Delay

I have a rather confusing problem: In my application I am checking for network connectivity and if the user is not connected to the internet I am showing a little red exclamation mark in the navigation bar. The Code that is used to show the exclamation mark looks like this:...

I am able to capture the TAB in a jtable, but how do I capture the SHIFT+TAB?

I have a JTable that I need to change the traversal inside such that a TAB keystroke advances row by row. (Normally, the TAB keystroke advances cell by cell.) I was able to change the forward traversal on the TAB keystroke. I tried the same thing for reverse traversal on...

How to draw 2d arrows with Java Swing?

I'm trying to draw some rotatable arrows with Swing 2d, there are some sample code online, so I copied and combined them into one app, but there is something wrong with each of the 3 methods : 1st one doesn't rotate from it's center, the other 2 don't look correctly...

Screen flickers when setting background

I'm trying to make a simple GUI program without using JComponents. Currently, I have a BufferedImage that I draw to off screen so that it doesn't flicker (or so I thought). I made a new program here to replicate the issue: package Main; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import...

java Swing: how to keep one component left aligned with another component centered with respect to parent

Say I have two components, A and B, in a JPanel. I want Component A to stay left aligned, while Component B does its best to stay in the middle of the panel. I mocked up the following demo (sorry for the quality, I made it in paint): What I...

JFileChooser select just directories

I am using JFileChooser to allow the user of my application to select a directory for file storage. Per the documentation and other StackOverflow questions I have researched I have added this bit of code: fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); Doing this does return the directory that I need, but to select that directory...

Calling a java class from a parent directory

I have two java classes SortsGui.java import javax.swing.*; import java.awt.*; import net.miginfocom.swing.MigLayout; import Sorts.*; import javax.swing.event.*; import java.awt.event.*; public class SortsGui { JFrame myMainWindow = new JFrame("Sorts"); JPanel sortPanel = new JPanel(); MyMenuBar mbr = new MyMenuBar(); //first panel components JTextField txtField = new JTextField(); JTextField txtField2 = new JTextField();...

How To Initialize a JComboBox Whose Items are added Dynamically?

I have Created a JComboBox and its item are being added dynamically through a LinkedList, how to initialize its selected value. Suppose "list" contains A->B->C->D->null I want to intialize the ComboBox selected index with B (i.e 2nd Item In the list). I have tried to do it as below ComboBox.setSelectedIndex(1);...

JRadioButtons before every line

I have this program that reads questions with multiple choice answers from a text file and then displays a random set of them in a JOptionPane (very question in a new Pane). In my text file the questions and the 4 options of answers are all in one line and...

Why doesn't my JFrame repaint when I set a new Synthetica theme?

I just set my applications theme to Synthetica Alu Oxide but some reason the JFrame doesn't repaint but another Synthetica theme will repaint the JFrame. This is what mine looks like. http://i.imgur.com/SOBDTs4.png This is what its suppose to look like. http://www.jyloo.com/images/screenshots/syntheticaAluOxide/democenter2.png public MainPanel() { JFrame frame = new JFrame(); frame.setTitle("Asteria...

IOS rightBarButtonItem on UINavigationController in swift

I'm trying to put a rightBarButtonItem on a second view controller of an UINavigationViewController stack. I'm creating and setting the button in viewDidLoad of the view controller that I want to show. My actual code looks like this: override func viewDidLoad() { super.viewDidLoad() menu_button_ = UIBarButtonItem(image: UIImage(named: "menu"), style: UIBarButtonItemStyle.Plain...

JTable not updating values as new rows are added

This is the screen of my system where it lists the available Magazines("revistas") and Books("livros") from ArrayLists of String[] containing Name,Availability,Code. Everything is working fine, except the table is showing blank. This is my class, I've cropped the variable declarations. Function "listar" at the bottom is what loads the JTable...

Search Icon inside a Editable JComboBox / JTextField

I have an Editable JComboBox search field in one of my Java swing application. I wanted to save space of the search box header and put in search icon inside the editable jcombobox to depict it as a search field. Which should look quite similar to a Facebook search...

How to open a JFrame that was previously hidden from another class?

I have 2 frames and in the first one, I press a button to go to the other and then I hide the frame with: frame1.this.hide(); How can I set that frame visible without creating a new one? I know that I can make an instance to open a new...

JFrame not adding graphics from separate class

I'm quite new to swing, and I'm having an issue with graphics not showing up in my JFrame. What I should be seeing is a blue rectangle slowly moving downwards through the frame, and behind it is a plain white background. However, when I run my main class, all I...

Java: Add Place Holder on JTextField

Guys is there a way or method in which we can add placeholder in j text field.I want to add placeholder "Enter Your Number" in field but how can i do this.I check all methods but didn't working. Code: public class Loop extends JFrame{ private JTextField t1; public L(){ getContentPane().setLayout(null);...

I want to make a dockable frame In java Swing Desktop application [closed]

I am new in java technology, so not enough idea to how start this application or you can say that is any extra configuration or jar required or it make as simple desktop swing application.

How to highlight all the occurrence of a particular string in a web page?

I am writing a swing application. In this application there is a table with some HTTP links. When I click a row a new browser window opens. To this point everything works good. Now I would like to know if it is possible to have all the occurrences of a...

how to get name of a accessible parent(panel) in swing?

When i click the button, it will print the accessible parent name. is there any way is to do that?. I have tried some codes, but its printing null. Can anyone point out my mistake. Container c = cancel.getParent(); System.out.println("Parent Name = "+c.getName()); ...

Text in JLabel doesn't get updated on pressing a JButton

I am working on a project but the program seems to have a bug that I can not find. Here is an MCVE which reproduces the problem: import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JButton; import java.awt.FlowLayout; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class SO{ JLabel label; JButton button; JPanel panel;...

How to add system time(running) to a Jpanel?

I am quite new to java coding. So don't know much of it. I am trying to add system clock(running) to my frame. I am using a jpanel to do so. Here is my code, import javax.swing.*; import java.util.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class Emp_Try implements ActionListener,...

addActionLister parameter

I am getting expected output when i am using "this" reference in addActionListener() call, how can I achieve it using the object call directly ? When i am using jb.addActionListener(new EventHandling1()); I am getting error -"Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException". Also which object needs to be passed to this method...

Manipulating components in a separate class java

I have three java classes StitchSorts import Sorts.*; public class StitchSorts { public static void main(String[] args) { StitchSorts sS = new StitchSorts(); SortsGui.main(args); } } SortsGui package Sorts; import javax.swing.*; import java.awt.*; import net.miginfocom.swing.MigLayout; import Sorts.*; import javax.swing.event.*; import java.awt.event.*; public class SortsGui { JFrame myMainWindow = new JFrame("Sorts");...

Errors trying to add rectangles to JPanel

I am trying to draw a grid of rectangles on a JPanel that already has a few JButtons on it. I get a big list of errors when I try to run it. Here's my code: package GameOfLife; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.*;...

how to refresh JFrame after after adding java 2d components

in this code i added two components to the jframe and also used revalidate and repaint but only one of the components is being viewed. i need a way to refresh the jframe class A extends JPanel{ int i ,j; A(int i,int j){ this.i = i; this.j = j; }...

Recognizing Blocked Swing EDT

How to know that EDT is blocked (not visually but by inspecting the thread itself)? is there a way? I'm on the way to my final university task for graduation that have bunch of charts , but have little knowledge of Swing EDT (Java generally). have look at this piece:...

Custom JComponent to set preferred scrollable viewport size

So I am trying to create a custom component so I can set the size of my scroll pane. Here is the part with the scroll pane: JScrollPane scrollPane = new JScrollPane(leftTop); customScroll t1 = new customScroll(); scrollPane.add(t1); left.add(scrollPane); leftTop is a nested panel inside of left. Here is my...

populate a 'JTable' with values from a '.txt' file

I'm new to java and I have a text file like this 0786160384|P. K.|Tharindu|912921549v|Colombo| 0711495765|P. K.|Gamini|657414589v|Colombo| 0114756199|H. P.|Weerasigha|657895478v|Kandy| I want to populate my 'jTable' with with the data from this text file. below is my code so far which doesn't work. When I execute the program nothing is displayed on...

Adding a scroll pane to GridBagLayout

I am trying to add two scroll pane along with one label and one button in a JPanel using GridBagLayout. While the first scroll pane containing a JList and the second scroll pane containing a JTable. Below is the code: JPanel capabilityPanel = new JPanel(new GridBagLayout()); GridBagConstraints constraints = new...

How to prevent memory leak in JTextPane.setCaretPosition(int)?

I'm working on a Java application with Swing-based GUI. The application uses JTextPane to output log messages as follows: 1) truncate existing text to keep total text size under the limit; 2) append new text; 3) scroll to the end (actual logic is slightly different, but it's irrelevant here). I...

Updating jTextArea in while loop

I am having a problem writing/updating the textarea. I am getting a value from the readtemp function, and i can see the result after calling the system out function, but nothing appears in the Textarea. What could be the problem? private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { URL temp; try { temp...

Why this indeterminate jProgressBar don't work in this simple code?

I want use an indeterminate jProgressBar on a JForm but I don't know why in my code don't work. The jProgressBar must be in the indeterminate status until the thread receives a latch.await() signal. This is the simple part of code when I push a button: private void jButton5ActionPerformed(java.awt.event.ActionEvent evt)...

Dynamic width and fixed height of rows in JPanel

I am trying to use Java layout managers (I have no external libraries, and am using Java 7) to create a layout where data is provided in rows, where the rows have a fixed height, but the width fills to fit the window. An example is provided below: The idea...

Why is java.awt.Graphics.drawLine exceptionally slow?

I am trying to achieve the following 'grid' layout. The class is extending java.awt.Canvas, and drawing these shapes (or lines) in the paint function. Why Canvas? Check here, trying to do something similar inititally. Updated MCVE Code for getting the above 'layout': import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Canvas; import java.awt.Color;...

Setting font in JOptionPane without using HTML

I tried this: Code Zip Sorry for the inconvenience but I could not attach the whole code (though it's not too big) and could not provide .java extension link so you have to get the zip and it open in html where code is with syntax highlighting. I read these:...